From 5065839da7d993419ecb297ef9dc43b87b70288b Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Mon, 20 May 2019 18:27:38 -0700 Subject: Upstream the Quantizer tool (part 4). This adds the basic passes needed and ties them into mlir-opt. Also adds two specific unit tests that exercise them. Next step is a standalone quantizer tool and additional cleanup. Tested: ninja check-mlir -- PiperOrigin-RevId: 249167690 --- .../Transforms/AddDefaultStatsTestPass.cpp | 128 +++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp (limited to 'mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp') diff --git a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp new file mode 100644 index 00000000000..75c082fd8ce --- /dev/null +++ b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp @@ -0,0 +1,128 @@ +//===- AddDefaultStatsTestPass.cpp - Testing pass to add default stats ----===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= +// +// This file defines a testing pass to add default statistics nodes to every +// quantization eligible op. Useful for unit testing. +// +//===----------------------------------------------------------------------===// + +#include "mlir/Dialect/QuantOps/QuantOps.h" +#include "mlir/Dialect/QuantOps/QuantTypes.h" +#include "mlir/IR/Attributes.h" +#include "mlir/IR/Builders.h" +#include "mlir/Quantizer/Configurations/FxpMathConfig.h" +#include "mlir/Quantizer/Support/Configuration.h" +#include "mlir/Quantizer/Support/ConstraintAnalysisGraph.h" +#include "mlir/Quantizer/Support/ConstraintAnalysisGraphTraits.h" +#include "mlir/Quantizer/Transforms/Passes.h" +#include "mlir/Support/LogicalResult.h" +#include "llvm/Support/GraphWriter.h" +#include "llvm/Support/raw_ostream.h" + +using namespace mlir; +using namespace mlir::quantizer; +using namespace mlir::quant; + +namespace { + +class AddDefaultStatsPass : public FunctionPass { +public: + AddDefaultStatsPass() = default; + AddDefaultStatsPass(SolverContext &solverContext, + const TargetConfiguration &config) + : explicitSolverContext(&solverContext), explicitConfig(&config) {} + + void runOnFunction() override; + void runWithConfig(SolverContext &solverContext, + const TargetConfiguration &config); + +private: + SolverContext *explicitSolverContext = nullptr; + const TargetConfiguration *explicitConfig = nullptr; +}; + +} // end anonymous namespace + +void AddDefaultStatsPass::runOnFunction() { + if (explicitSolverContext && explicitConfig) { + // If explicitly constructed with a config and context. + runWithConfig(*explicitSolverContext, *explicitConfig); + return; + } + // For global pass registration, use defaults. + SolverContext solverContext(*getFunction().getContext()); + auto config = FxpMathTargetConfig::create(solverContext); + runWithConfig(solverContext, *config); +} + +void AddDefaultStatsPass::runWithConfig(SolverContext &solverContext, + const TargetConfiguration &config) { + auto &func = getFunction(); + + // Insert stats for each argument. + for (auto *arg : func.getArguments()) { + if (!config.isHandledType(arg->getType())) + continue; + FuncBuilder b(func); + APFloat minValue(-1.0f); + APFloat maxValue(1.0f); + ElementsAttr layerStats = DenseFPElementsAttr::get( + b.getTensorType({2}, b.getF32Type()), {minValue, maxValue}); + auto statsOp = + b.create(func.getLoc(), arg, layerStats, nullptr); + arg->replaceAllUsesWith(statsOp); + + // StatsOp contained a use to 'arg' so make sure to reset it after replacing + // all of the uses of 'arg'. + statsOp.getOperation()->replaceUsesOfWith(statsOp, arg); + } + + // Walk the ops and insert stats. + func.walk([&](Operation *op) { + if (!config.isRequireStatsOp(op)) { + return; + } + assert(op->getNumResults() == 1); + + auto originalResult = op->getResult(0); + if (!config.isHandledType(originalResult->getType())) + return; + + FuncBuilder b(op->getBlock(), ++op->getIterator()); + + APFloat minValue(-1.0f); + APFloat maxValue(1.0f); + ElementsAttr layerStats = DenseFPElementsAttr::get( + b.getTensorType({2}, b.getF32Type()), {minValue, maxValue}); + auto statsOp = b.create(op->getLoc(), op->getResult(0), + layerStats, nullptr); + originalResult->replaceAllUsesWith(statsOp); + + // StatsOp contained a use to 'op' so make sure to reset it after replacing + // all of the uses of 'op'. + statsOp.getOperation()->replaceUsesOfWith(statsOp, originalResult); + }); +} + +FunctionPassBase *mlir::quantizer::createAddDefaultStatsPass() { + return new AddDefaultStatsPass(); +} + +static PassRegistration pass( + "quantizer-add-default-stats-test", + "Adds default (dummy) statistics to all ops that can benefit from " + "runtime statistics. This is meant to help in early stage bootstrapping."); -- cgit v1.2.3 From f1b848e4701a4cd3fa781c259e3728faff1c31df Mon Sep 17 00:00:00 2001 From: River Riddle Date: Tue, 4 Jun 2019 19:18:23 -0700 Subject: NFC: Rename FuncBuilder to OpBuilder and refactor to take a top level region instead of a function. PiperOrigin-RevId: 251563898 --- mlir/bindings/python/pybind.cpp | 4 +- .../Linalg/Linalg1/lib/ConvertToLLVMDialect.cpp | 3 +- mlir/examples/Linalg/Linalg2/Example.cpp | 4 +- mlir/examples/Linalg/Linalg2/lib/Transforms.cpp | 4 +- mlir/examples/Linalg/Linalg3/Conversion.cpp | 2 +- mlir/examples/Linalg/Linalg3/Example.cpp | 2 +- mlir/examples/Linalg/Linalg3/Execution.cpp | 2 +- .../Linalg/Linalg3/lib/ConvertToLLVMDialect.cpp | 5 +-- mlir/examples/Linalg/Linalg3/lib/TensorOps.cpp | 10 ++--- mlir/examples/Linalg/Linalg3/lib/Transforms.cpp | 6 +-- mlir/examples/Linalg/Linalg4/Example.cpp | 6 +-- mlir/examples/Linalg/Linalg4/lib/Transforms.cpp | 2 +- mlir/examples/toy/Ch2/mlir/MLIRGen.cpp | 4 +- mlir/examples/toy/Ch3/mlir/MLIRGen.cpp | 4 +- mlir/examples/toy/Ch4/mlir/MLIRGen.cpp | 4 +- mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp | 2 +- mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp | 4 +- mlir/examples/toy/Ch5/mlir/LateLowering.cpp | 10 ++--- mlir/examples/toy/Ch5/mlir/MLIRGen.cpp | 4 +- mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp | 2 +- mlir/g3doc/Tutorials/Linalg/LLVMConversion.md | 14 +++---- mlir/g3doc/Tutorials/Toy/Ch-2.md | 2 +- mlir/g3doc/Tutorials/Toy/Ch-3.md | 4 +- mlir/g3doc/Tutorials/Toy/Ch-5.md | 2 +- mlir/include/mlir/AffineOps/AffineOps.h | 7 ++-- mlir/include/mlir/Analysis/VectorAnalysis.h | 2 +- mlir/include/mlir/EDSC/Builders.h | 18 ++++----- mlir/include/mlir/IR/Block.h | 15 ++++++++ mlir/include/mlir/IR/Builders.h | 43 ++++++++++------------ mlir/include/mlir/IR/PatternMatch.h | 4 +- mlir/include/mlir/Linalg/IR/LinalgOps.h | 10 ++--- mlir/include/mlir/Linalg/Utils/Utils.h | 2 +- mlir/include/mlir/Transforms/DialectConversion.h | 1 - mlir/include/mlir/Transforms/LoopUtils.h | 4 +- mlir/include/mlir/Transforms/Utils.h | 6 +-- mlir/lib/AffineOps/AffineOps.cpp | 6 +-- mlir/lib/Analysis/LoopAnalysis.cpp | 2 +- mlir/lib/Analysis/TestParallelismDetection.cpp | 2 +- mlir/lib/Analysis/Utils.cpp | 2 +- mlir/lib/EDSC/Builders.cpp | 9 ++--- mlir/lib/GPU/Transforms/KernelOutlining.cpp | 16 ++++---- mlir/lib/IR/Block.cpp | 18 +++++++++ mlir/lib/IR/Builders.cpp | 12 +++--- mlir/lib/IR/Function.cpp | 4 +- mlir/lib/IR/Operation.cpp | 3 +- .../lib/LLVMIR/Transforms/ConvertToLLVMDialect.cpp | 2 +- mlir/lib/Linalg/IR/LinalgOps.cpp | 2 +- mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp | 2 +- mlir/lib/Linalg/Transforms/LowerToLoops.cpp | 4 +- mlir/lib/Linalg/Transforms/Tiling.cpp | 6 +-- mlir/lib/Linalg/Utils/Utils.cpp | 6 +-- mlir/lib/Parser/Parser.cpp | 4 +- .../Transforms/AddDefaultStatsTestPass.cpp | 4 +- .../Transforms/InferQuantizedTypesPass.cpp | 4 +- mlir/lib/Transforms/DialectConversion.cpp | 8 ++-- mlir/lib/Transforms/DmaGeneration.cpp | 10 ++--- mlir/lib/Transforms/LoopFusion.cpp | 4 +- mlir/lib/Transforms/LoopInvariantCodeMotion.cpp | 2 +- mlir/lib/Transforms/LoopTiling.cpp | 6 +-- mlir/lib/Transforms/LoopUnrollAndJam.cpp | 5 +-- mlir/lib/Transforms/LowerAffine.cpp | 16 ++++---- mlir/lib/Transforms/MaterializeVectors.cpp | 14 +++---- mlir/lib/Transforms/PipelineDataTransfer.cpp | 6 +-- mlir/lib/Transforms/Utils/FoldUtils.cpp | 2 +- .../Utils/GreedyPatternRewriteDriver.cpp | 12 +++--- mlir/lib/Transforms/Utils/LoopUtils.cpp | 25 ++++++------- mlir/lib/Transforms/Utils/Utils.cpp | 4 +- .../Vectorization/VectorizerTestPass.cpp | 2 +- mlir/lib/Transforms/Vectorize.cpp | 10 ++--- mlir/test/EDSC/builder-api-test.cpp | 26 ++++++------- 70 files changed, 249 insertions(+), 229 deletions(-) (limited to 'mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp') diff --git a/mlir/bindings/python/pybind.cpp b/mlir/bindings/python/pybind.cpp index 76cec271621..6ec0860ff7f 100644 --- a/mlir/bindings/python/pybind.cpp +++ b/mlir/bindings/python/pybind.cpp @@ -248,7 +248,7 @@ struct PythonFunctionContext { PythonFunction enter() { assert(function.function && "function is not set up"); auto *mlirFunc = static_cast(function.function); - contextBuilder.emplace(mlirFunc); + contextBuilder.emplace(mlirFunc->getBody()); context = new mlir::edsc::ScopedContext(*contextBuilder, mlirFunc->getLoc()); return function; @@ -262,7 +262,7 @@ struct PythonFunctionContext { PythonFunction function; mlir::edsc::ScopedContext *context; - llvm::Optional contextBuilder; + llvm::Optional contextBuilder; }; PythonFunctionContext PythonMLIRModule::makeFunctionContext( diff --git a/mlir/examples/Linalg/Linalg1/lib/ConvertToLLVMDialect.cpp b/mlir/examples/Linalg/Linalg1/lib/ConvertToLLVMDialect.cpp index 8cd970c56f1..d13f7f3de92 100644 --- a/mlir/examples/Linalg/Linalg1/lib/ConvertToLLVMDialect.cpp +++ b/mlir/examples/Linalg/Linalg1/lib/ConvertToLLVMDialect.cpp @@ -121,8 +121,7 @@ Type linalg::convertLinalgType(Type t) { // Create an array attribute containing integer attributes with values provided // in `position`. -static ArrayAttr makePositionAttr(FuncBuilder &builder, - ArrayRef position) { +static ArrayAttr makePositionAttr(OpBuilder &builder, ArrayRef position) { SmallVector attrs; attrs.reserve(position.size()); for (auto p : position) diff --git a/mlir/examples/Linalg/Linalg2/Example.cpp b/mlir/examples/Linalg/Linalg2/Example.cpp index 0de8a9044e1..10f4bf7e905 100644 --- a/mlir/examples/Linalg/Linalg2/Example.cpp +++ b/mlir/examples/Linalg/Linalg2/Example.cpp @@ -39,7 +39,7 @@ TEST_FUNC(linalg_ops) { mlir::Function *f = makeFunction(module, "linalg_ops", {indexType, indexType, indexType}, {}); - FuncBuilder builder(f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); // clang-format off @@ -78,7 +78,7 @@ TEST_FUNC(linalg_ops_folded_slices) { mlir::Function *f = makeFunction(module, "linalg_ops_folded_slices", {indexType, indexType, indexType}, {}); - FuncBuilder builder(f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); // clang-format off diff --git a/mlir/examples/Linalg/Linalg2/lib/Transforms.cpp b/mlir/examples/Linalg/Linalg2/lib/Transforms.cpp index 4523830129c..f4d3d68d28a 100644 --- a/mlir/examples/Linalg/Linalg2/lib/Transforms.cpp +++ b/mlir/examples/Linalg/Linalg2/lib/Transforms.cpp @@ -31,8 +31,8 @@ using llvm::ArrayRef; using llvm::cast; using llvm::isa; using llvm::SmallVector; -using mlir::FuncBuilder; using mlir::MemRefType; +using mlir::OpBuilder; using mlir::Value; using mlir::edsc::ScopedContext; using mlir::edsc::ValueHandle; @@ -101,7 +101,7 @@ static mlir::Value *createFullyComposedIndexing(unsigned dim, } ViewOp linalg::emitAndReturnFullyComposedView(Value *v) { - FuncBuilder builder(v->getDefiningOp()); + OpBuilder builder(v->getDefiningOp()); ScopedContext scope(builder, v->getDefiningOp()->getLoc()); assert(v->getType().isa() && "must be a ViewType"); auto *memRef = getViewSupportingMemRef(v); diff --git a/mlir/examples/Linalg/Linalg3/Conversion.cpp b/mlir/examples/Linalg/Linalg3/Conversion.cpp index 0d7b22b0fe9..37d1b51f53e 100644 --- a/mlir/examples/Linalg/Linalg3/Conversion.cpp +++ b/mlir/examples/Linalg/Linalg3/Conversion.cpp @@ -44,7 +44,7 @@ Function *makeFunctionWithAMatmulOp(Module &module, StringRef name) { module, name, {dynamic2DMemRefType, dynamic2DMemRefType, dynamic2DMemRefType}, {}); - FuncBuilder builder(f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); // clang-format off ValueHandle diff --git a/mlir/examples/Linalg/Linalg3/Example.cpp b/mlir/examples/Linalg/Linalg3/Example.cpp index cf77785532b..f02aef920e4 100644 --- a/mlir/examples/Linalg/Linalg3/Example.cpp +++ b/mlir/examples/Linalg/Linalg3/Example.cpp @@ -41,7 +41,7 @@ Function *makeFunctionWithAMatmulOp(Module &module, StringRef name) { module, name, {dynamic2DMemRefType, dynamic2DMemRefType, dynamic2DMemRefType}, {}); - mlir::FuncBuilder builder(f); + mlir::OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); // clang-format off ValueHandle diff --git a/mlir/examples/Linalg/Linalg3/Execution.cpp b/mlir/examples/Linalg/Linalg3/Execution.cpp index 902ea67abe1..00d571cbc99 100644 --- a/mlir/examples/Linalg/Linalg3/Execution.cpp +++ b/mlir/examples/Linalg/Linalg3/Execution.cpp @@ -44,7 +44,7 @@ Function *makeFunctionWithAMatmulOp(Module &module, StringRef name) { module, name, {dynamic2DMemRefType, dynamic2DMemRefType, dynamic2DMemRefType}, {}); - mlir::FuncBuilder builder(f); + mlir::OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); // clang-format off ValueHandle diff --git a/mlir/examples/Linalg/Linalg3/lib/ConvertToLLVMDialect.cpp b/mlir/examples/Linalg/Linalg3/lib/ConvertToLLVMDialect.cpp index 60fdf60039f..ef0d8581a99 100644 --- a/mlir/examples/Linalg/Linalg3/lib/ConvertToLLVMDialect.cpp +++ b/mlir/examples/Linalg/Linalg3/lib/ConvertToLLVMDialect.cpp @@ -41,8 +41,7 @@ using namespace mlir; // Create an array attribute containing integer attributes with values provided // in `position`. -static ArrayAttr makePositionAttr(FuncBuilder &builder, - ArrayRef position) { +static ArrayAttr makePositionAttr(Builder &builder, ArrayRef position) { SmallVector attrs; attrs.reserve(position.size()); for (auto p : position) @@ -64,7 +63,7 @@ public: // descriptor to emit IR iteratively computing the actual offset, followed by // a getelementptr. Value *obtainDataPtr(Operation *op, Value *viewDescriptor, - ArrayRef indices, FuncBuilder &rewriter) const { + ArrayRef indices, Builder &rewriter) const { auto loadOp = cast(op); auto elementType = loadOp.getViewType().template cast().getElementType(); diff --git a/mlir/examples/Linalg/Linalg3/lib/TensorOps.cpp b/mlir/examples/Linalg/Linalg3/lib/TensorOps.cpp index f539c702549..778f2ea5540 100644 --- a/mlir/examples/Linalg/Linalg3/lib/TensorOps.cpp +++ b/mlir/examples/Linalg/Linalg3/lib/TensorOps.cpp @@ -64,7 +64,7 @@ void linalg::DotOp::emitScalarImplementation( using edsc::intrinsics::select; // Account for affine.terminator in loop. - FuncBuilder builder(body, std::prev(body->end(), 1)); + OpBuilder builder(body, std::prev(body->end(), 1)); ScopedContext scope(builder, innermostLoop.getLoc()); FloatType fTy = getOperand(0) ->getType() @@ -107,7 +107,7 @@ void linalg::MatvecOp::writeAsFinerGrainTensorContraction() { assert( llvm::isa_and_nonnull(indexingPosPair.first->getDefiningOp())); // clang-format off - FuncBuilder builder(op); + OpBuilder builder(op); ScopedContext scope(builder, op->getLoc()); IndexHandle i; using linalg::common::LoopNestRangeBuilder; @@ -132,7 +132,7 @@ void linalg::MatvecOp::emitScalarImplementation( using edsc::op::operator==; using edsc::intrinsics::select; // Account for affine.terminator in loop. - FuncBuilder builder(body, std::prev(body->end(), 1)); + OpBuilder builder(body, std::prev(body->end(), 1)); ScopedContext scope(builder, innermostLoop.getLoc()); FloatType fTy = getOperand(0) ->getType() @@ -181,7 +181,7 @@ void linalg::MatmulOp::writeAsFinerGrainTensorContraction() { llvm::isa_and_nonnull(indexingPosPair.first->getDefiningOp())); using linalg::common::LoopNestRangeBuilder; // clang-format off - FuncBuilder builder(op); + OpBuilder builder(op); ScopedContext scope(builder, op->getLoc()); IndexHandle j; LoopNestRangeBuilder(&j, ValueHandle(indexingPosPair.first))( @@ -205,7 +205,7 @@ void linalg::MatmulOp::emitScalarImplementation( using edsc::op::operator==; using edsc::intrinsics::select; // Account for affine.terminator in loop. - FuncBuilder builder(body, std::prev(body->end(), 1)); + OpBuilder builder(body, std::prev(body->end(), 1)); ScopedContext scope(builder, innermostLoop.getLoc()); FloatType fTy = getOperand(0) ->getType() diff --git a/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp b/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp index 3a11c6d17d9..5b16ce0eda5 100644 --- a/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp +++ b/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp @@ -161,7 +161,7 @@ linalg::makeGenericLoopRanges(AffineMap operandRangesToLoopMaps, template static SmallVector writeContractionAsLoops(ContractionOp contraction) { - FuncBuilder builder(contraction.getOperation()); + OpBuilder builder(contraction.getOperation()); ScopedContext scope(builder, contraction.getLoc()); auto allRanges = getRanges(contraction); auto loopRanges = @@ -274,7 +274,7 @@ Rewriter::matchAndRewrite(linalg::LoadOp load, SliceOp slice = dyn_cast(load.getView()->getDefiningOp()); ViewOp view = slice ? emitAndReturnFullyComposedView(slice.getResult()) : cast(load.getView()->getDefiningOp()); - FuncBuilder builder(load); + OpBuilder builder(load); ScopedContext scope(builder, load.getLoc()); auto *memRef = view.getSupportingMemRef(); auto operands = emitAndReturnLoadStoreOperands(load, view); @@ -289,7 +289,7 @@ Rewriter::matchAndRewrite(linalg::StoreOp store, SliceOp slice = dyn_cast(store.getView()->getDefiningOp()); ViewOp view = slice ? emitAndReturnFullyComposedView(slice.getResult()) : cast(store.getView()->getDefiningOp()); - FuncBuilder builder(store); + OpBuilder builder(store); ScopedContext scope(builder, store.getLoc()); auto *valueToStore = store.getValueToStore(); auto *memRef = view.getSupportingMemRef(); diff --git a/mlir/examples/Linalg/Linalg4/Example.cpp b/mlir/examples/Linalg/Linalg4/Example.cpp index 73e75706f11..cdc05a1cc21 100644 --- a/mlir/examples/Linalg/Linalg4/Example.cpp +++ b/mlir/examples/Linalg/Linalg4/Example.cpp @@ -41,7 +41,7 @@ Function *makeFunctionWithAMatmulOp(Module &module, StringRef name) { module, name, {dynamic2DMemRefType, dynamic2DMemRefType, dynamic2DMemRefType}, {}); - FuncBuilder builder(f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); // clang-format off @@ -97,7 +97,7 @@ TEST_FUNC(matmul_tiled_views) { MLIRContext context; Module module(&context); mlir::Function *f = makeFunctionWithAMatmulOp(module, "matmul_tiled_views"); - FuncBuilder b(f); + OpBuilder b(f->getBody()); lowerToTiledViews(f, {b.create(f->getLoc(), 8), b.create(f->getLoc(), 9)}); composeSliceOps(f); @@ -127,7 +127,7 @@ TEST_FUNC(matmul_tiled_views_as_loops) { Module module(&context); mlir::Function *f = makeFunctionWithAMatmulOp(module, "matmul_tiled_views_as_loops"); - FuncBuilder b(f); + OpBuilder b(f->getBody()); lowerToTiledViews(f, {b.create(f->getLoc(), 8), b.create(f->getLoc(), 9)}); composeSliceOps(f); diff --git a/mlir/examples/Linalg/Linalg4/lib/Transforms.cpp b/mlir/examples/Linalg/Linalg4/lib/Transforms.cpp index 3df6f4b00ac..11cd6e5cd9a 100644 --- a/mlir/examples/Linalg/Linalg4/lib/Transforms.cpp +++ b/mlir/examples/Linalg/Linalg4/lib/Transforms.cpp @@ -148,7 +148,7 @@ writeContractionAsTiledViews(TensorContractionBase &contraction, contraction.getNumParallelDims() + contraction.getNumReductionDims()); auto *op = static_cast(&contraction); - mlir::FuncBuilder builder(op->getOperation()); + mlir::OpBuilder builder(op->getOperation()); ScopedContext scope(builder, op->getLoc()); SmallVector ivs(tileSizes.size()); auto pivs = IndexHandle::makeIndexHandlePointers(ivs); diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp index 5eb8cd089f5..df09cd0921e 100644 --- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp @@ -104,7 +104,7 @@ private: /// convenience for emitting individual operations. /// The builder is stateful, in particular it keeeps an "insertion point": /// this is where the next operations will be introduced. - std::unique_ptr builder; + std::unique_ptr builder; /// The symbol table maps a variable name to a value in the current scope. /// Entering a function creates a new scope, and the function arguments are @@ -174,7 +174,7 @@ private: // Create a builder for the function, it will be used throughout the codegen // to create operations in this function. - builder = llvm::make_unique(function.get()); + builder = llvm::make_unique(function->getBody()); // Emit the body of the function. if (!mlirGen(*funcAST.getBody())) diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp index 7c580d25488..4001b308a3c 100644 --- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp @@ -105,7 +105,7 @@ private: /// convenience for emitting individual operations. /// The builder is stateful, in particular it keeeps an "insertion point": /// this is where the next operations will be introduced. - std::unique_ptr builder; + std::unique_ptr builder; /// The symbol table maps a variable name to a value in the current scope. /// Entering a function creates a new scope, and the function arguments are @@ -175,7 +175,7 @@ private: // Create a builder for the function, it will be used throughout the codegen // to create operations in this function. - builder = llvm::make_unique(function.get()); + builder = llvm::make_unique(function->getBody()); // Emit the body of the function. if (!mlirGen(*funcAST.getBody())) diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp index e2001fb575e..e091cbd9ec2 100644 --- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp @@ -105,7 +105,7 @@ private: /// convenience for emitting individual operations. /// The builder is stateful, in particular it keeeps an "insertion point": /// this is where the next operations will be introduced. - std::unique_ptr builder; + std::unique_ptr builder; /// The symbol table maps a variable name to a value in the current scope. /// Entering a function creates a new scope, and the function arguments are @@ -175,7 +175,7 @@ private: // Create a builder for the function, it will be used throughout the codegen // to create operations in this function. - builder = llvm::make_unique(function.get()); + builder = llvm::make_unique(function->getBody()); // Emit the body of the function. if (!mlirGen(*funcAST.getBody())) diff --git a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp index 2c06526ec7b..440e3d8be00 100644 --- a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp @@ -315,7 +315,7 @@ public: // Found a specialized callee! Let's turn this into a normal call // operation. SmallVector operands(op->getOperands()); - mlir::FuncBuilder builder(op); + mlir::OpBuilder builder(op); auto newCall = builder.create(op->getLoc(), mangledCallee, operands); if (newCall.getNumResults()) { diff --git a/mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp b/mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp index 45d608d72a5..189add05ee3 100644 --- a/mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp +++ b/mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp @@ -57,7 +57,7 @@ namespace { /// time both side of the cast (producer and consumer) will be lowered to a /// dialect like LLVM and end up with the same LLVM representation, at which /// point this becomes a no-op and is eliminated. -Value *typeCast(FuncBuilder &builder, Value *val, Type destTy) { +Value *typeCast(PatternRewriter &builder, Value *val, Type destTy) { if (val->getType() == destTy) return val; return builder.create(val->getLoc(), val, destTy) @@ -67,7 +67,7 @@ Value *typeCast(FuncBuilder &builder, Value *val, Type destTy) { /// Create a type cast to turn a toy.array into a memref. The Toy Array will be /// lowered to a memref during buffer allocation, at which point the type cast /// becomes useless. -Value *memRefTypeCast(FuncBuilder &builder, Value *val) { +Value *memRefTypeCast(PatternRewriter &builder, Value *val) { if (val->getType().isa()) return val; auto toyArrayTy = val->getType().dyn_cast(); diff --git a/mlir/examples/toy/Ch5/mlir/LateLowering.cpp b/mlir/examples/toy/Ch5/mlir/LateLowering.cpp index d682d12b253..ecf6c9df05d 100644 --- a/mlir/examples/toy/Ch5/mlir/LateLowering.cpp +++ b/mlir/examples/toy/Ch5/mlir/LateLowering.cpp @@ -57,7 +57,7 @@ namespace { /// time both side of the cast (producer and consumer) will be lowered to a /// dialect like LLVM and end up with the same LLVM representation, at which /// point this becomes a no-op and is eliminated. -Value *typeCast(FuncBuilder &builder, Value *val, Type destTy) { +Value *typeCast(PatternRewriter &builder, Value *val, Type destTy) { if (val->getType() == destTy) return val; return builder.create(val->getLoc(), val, destTy) @@ -67,7 +67,7 @@ Value *typeCast(FuncBuilder &builder, Value *val, Type destTy) { /// Create a type cast to turn a toy.array into a memref. The Toy Array will be /// lowered to a memref during buffer allocation, at which point the type cast /// becomes useless. -Value *memRefTypeCast(FuncBuilder &builder, Value *val) { +Value *memRefTypeCast(PatternRewriter &builder, Value *val) { if (val->getType().isa()) return val; auto toyArrayTy = val->getType().dyn_cast(); @@ -183,7 +183,7 @@ public: private: // Turn a string into a toy.alloc (malloc/free abstraction) and a sequence // of stores into the buffer, and return a MemRef into the buffer. - Value *getConstantCharBuffer(FuncBuilder &builder, Location loc, + Value *getConstantCharBuffer(PatternRewriter &builder, Location loc, StringRef data) const { auto retTy = builder.getMemRefType(data.size() + 1, builder.getIntegerType(8)); @@ -405,7 +405,7 @@ struct LateLoweringPass : public ModulePass { /// operating in a brand new function: we don't have the return to hook the /// dealloc operations. Value *allocTensor(toy::AllocOp alloc) { - FuncBuilder builder(alloc); + OpBuilder builder(alloc); auto retTy = alloc.getResult()->getType(); auto memRefTy = retTy.dyn_cast(); @@ -420,7 +420,7 @@ struct LateLoweringPass : public ModulePass { // Insert a `dealloc` operation right before the `return` operations, unless // it is returned itself in which case the caller is responsible for it. - builder.getFunction()->walk([&](Operation *op) { + builder.getRegion()->walk([&](Operation *op) { auto returnOp = dyn_cast(op); if (!returnOp) return; diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp index e2001fb575e..e091cbd9ec2 100644 --- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp @@ -105,7 +105,7 @@ private: /// convenience for emitting individual operations. /// The builder is stateful, in particular it keeeps an "insertion point": /// this is where the next operations will be introduced. - std::unique_ptr builder; + std::unique_ptr builder; /// The symbol table maps a variable name to a value in the current scope. /// Entering a function creates a new scope, and the function arguments are @@ -175,7 +175,7 @@ private: // Create a builder for the function, it will be used throughout the codegen // to create operations in this function. - builder = llvm::make_unique(function.get()); + builder = llvm::make_unique(function->getBody()); // Emit the body of the function. if (!mlirGen(*funcAST.getBody())) diff --git a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp index c9da85f8106..4294f7bbbbf 100644 --- a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp @@ -319,7 +319,7 @@ public: // Found a specialized callee! Let's turn this into a normal call // operation. SmallVector operands(op->getOperands()); - mlir::FuncBuilder builder(f); + mlir::OpBuilder builder(f->getBody()); builder.setInsertionPoint(op); auto newCall = builder.create(op->getLoc(), mangledCallee, operands); diff --git a/mlir/g3doc/Tutorials/Linalg/LLVMConversion.md b/mlir/g3doc/Tutorials/Linalg/LLVMConversion.md index 83a2a319713..af34c9ceec4 100644 --- a/mlir/g3doc/Tutorials/Linalg/LLVMConversion.md +++ b/mlir/g3doc/Tutorials/Linalg/LLVMConversion.md @@ -233,7 +233,7 @@ public: // needs to define as many value as the original operation, but their types // may be different. SmallVector rewrite(Operation *op, ArrayRef operands, - FuncBuilder &rewriter) const override; + OpBuilder &rewriter) const override; } ``` @@ -296,7 +296,7 @@ operates. ```c++ SmallVector ViewOpConversion::rewrite( Operation *op, ArrayRef operands, - FuncBuilder &rewriter) const override { + OpBuilder &rewriter) const override { // Obtain the typed operation (we know we matched only one type). auto viewOp = op->cast(); @@ -437,7 +437,7 @@ struct ViewDescriptor { } // The builder into which we emit code. - FuncBuilder &builder; + OpBuilder &builder; // The actual descriptor. Value *d; @@ -450,7 +450,7 @@ rules described above: ```c++ SmallVector SliceOpConversion::rewrite( Operation *op, ArrayRef operands, - FuncBuilder &rewriter) const override { + OpBuilder &rewriter) const override { // Obtain the typed operation (we know we matched only one type). auto sliceOp = op->cast(); @@ -528,7 +528,7 @@ for the view descriptor: ```c++ Value *obtainDataPtr(Location loc, int rank, Value *viewDescriptorVal, - ArrayRef indices, FuncBuilder &rewriter) { + ArrayRef indices, OpBuilder &rewriter) { // Create the context object (RAII) in which we can use declarative builders. // Bring all the builders into the namespace. using namespace intrinsics; @@ -560,7 +560,7 @@ conversions for load and store operations. // Load Operation Conversion. SmallVector LoadOpConversion::rewrite( Operation *op, ArrayRef operands, - FuncBuilder &rewriter) const override { + OpBuilder &rewriter) const override { // Obtain the typed operation (we know we matched only one type). auto loadOp = op->cast(); @@ -582,7 +582,7 @@ SmallVector LoadOpConversion::rewrite( // Store Operation Conversion SmallVector StoreOpConversion::rewrite( Operation *op, ArrayRef operands, - FuncBuilder &rewriter) const override { + OpBuilder &rewriter) const override { // Obtain the typed operation (we know we matched only one type). auto loadOp = op->cast(); diff --git a/mlir/g3doc/Tutorials/Toy/Ch-2.md b/mlir/g3doc/Tutorials/Toy/Ch-2.md index 4a8b8dc4454..9b07385bb89 100644 --- a/mlir/g3doc/Tutorials/Toy/Ch-2.md +++ b/mlir/g3doc/Tutorials/Toy/Ch-2.md @@ -123,7 +123,7 @@ generation through a simple depth-first search traversal of the Toy AST. Here is how we create a `toy.transpose` operation: ``` -mlir::Operation *createTransposeOp(FuncBuilder *builder, +mlir::Operation *createTransposeOp(OpBuilder *builder, mlir::Value *input_array) { // We bundle our custom type in a `toy` dialect. auto toyDialect = mlir::Identifier::get("toy", builder->getContext()); diff --git a/mlir/g3doc/Tutorials/Toy/Ch-3.md b/mlir/g3doc/Tutorials/Toy/Ch-3.md index 498438ad03c..9ff6c401b55 100644 --- a/mlir/g3doc/Tutorials/Toy/Ch-3.md +++ b/mlir/g3doc/Tutorials/Toy/Ch-3.md @@ -202,11 +202,11 @@ class GenericCallOp bool verify(); /// Interface to the builder to allow: - /// mlir::FuncBuilder::create(...) + /// mlir::OpBuilder::create(...) /// This method populate the `state` that MLIR use to create operations. /// The `toy.generic_call` operation accepts a callee name and a list of /// arguments for the call. - static void build(mlir::FuncBuilder *builder, mlir::OperationState *state, + static void build(mlir::OpBuilder *builder, mlir::OperationState *state, llvm::StringRef callee, llvm::ArrayRef arguments); diff --git a/mlir/g3doc/Tutorials/Toy/Ch-5.md b/mlir/g3doc/Tutorials/Toy/Ch-5.md index 24612755ce0..2681720e0fc 100644 --- a/mlir/g3doc/Tutorials/Toy/Ch-5.md +++ b/mlir/g3doc/Tutorials/Toy/Ch-5.md @@ -80,7 +80,7 @@ public: /// The results created by the new IR with the builder are returned, and their /// number must match the number of result of `op`. SmallVector rewrite(Operation *op, ArrayRef operands, - FuncBuilder &rewriter) const override { + OpBuilder &rewriter) const override { ... // Return the newly allocated buffer, it will be used as an operand when diff --git a/mlir/include/mlir/AffineOps/AffineOps.h b/mlir/include/mlir/AffineOps/AffineOps.h index a3749a389cb..8fcd0abe920 100644 --- a/mlir/include/mlir/AffineOps/AffineOps.h +++ b/mlir/include/mlir/AffineOps/AffineOps.h @@ -32,7 +32,7 @@ namespace mlir { class AffineBound; class AffineValueMap; class FlatAffineConstraints; -class FuncBuilder; +class OpBuilder; /// A utility function to check if a value is defined at the top level of a /// function. A value defined at the top level is always a valid symbol. @@ -143,7 +143,7 @@ public: /// Return a Builder set up to insert operations immediately before the /// terminator. - FuncBuilder getBodyBuilder(); + OpBuilder getBodyBuilder(); /// Get the body of the AffineForOp. Block *getBody() { return &getRegion().front(); } @@ -361,8 +361,7 @@ void canonicalizeMapAndOperands(AffineMap *map, /// Returns a composed AffineApplyOp by composing `map` and `operands` with /// other AffineApplyOps supplying those operands. The operands of the resulting /// AffineApplyOp do not change the length of AffineApplyOp chains. -AffineApplyOp makeComposedAffineApply(FuncBuilder *b, Location loc, - AffineMap map, +AffineApplyOp makeComposedAffineApply(OpBuilder *b, Location loc, AffineMap map, llvm::ArrayRef operands); /// Given an affine map `map` and its input `operands`, this method composes diff --git a/mlir/include/mlir/Analysis/VectorAnalysis.h b/mlir/include/mlir/Analysis/VectorAnalysis.h index bf070e81be8..1f4e50c1178 100644 --- a/mlir/include/mlir/Analysis/VectorAnalysis.h +++ b/mlir/include/mlir/Analysis/VectorAnalysis.h @@ -27,9 +27,9 @@ namespace mlir { class AffineApplyOp; class AffineForOp; class AffineMap; -class FuncBuilder; class Location; class MemRefType; +class OpBuilder; class Operation; class Value; class VectorType; diff --git a/mlir/include/mlir/EDSC/Builders.h b/mlir/include/mlir/EDSC/Builders.h index c925e0a39e7..aa5c321627d 100644 --- a/mlir/include/mlir/EDSC/Builders.h +++ b/mlir/include/mlir/EDSC/Builders.h @@ -50,17 +50,17 @@ class ValueHandle; /// setting and restoring of insertion points. class ScopedContext { public: - ScopedContext(FuncBuilder &builder, Location location); + ScopedContext(OpBuilder &builder, Location location); /// Sets the insertion point of the builder to 'newInsertPt' for the duration /// of the scope. The existing insertion point of the builder is restored on /// destruction. - ScopedContext(FuncBuilder &builder, FuncBuilder::InsertPoint newInsertPt, + ScopedContext(OpBuilder &builder, OpBuilder::InsertPoint newInsertPt, Location location); ~ScopedContext(); static MLIRContext *getContext(); - static FuncBuilder *getBuilder(); + static OpBuilder *getBuilder(); static Location getLocation(); private: @@ -74,10 +74,10 @@ private: static ScopedContext *&getCurrentScopedContext(); - /// Top level FuncBuilder. - FuncBuilder &builder; + /// Top level OpBuilder. + OpBuilder &builder; /// The previous insertion point of the builder. - llvm::Optional prevBuilderInsertPoint; + llvm::Optional prevBuilderInsertPoint; /// Current location. Location location; /// Parent context we return into. @@ -116,20 +116,20 @@ protected: /// Enter an mlir::Block and setup a ScopedContext to insert operations at /// the end of it. Since we cannot use c++ language-level scoping to implement /// scoping itself, we use enter/exit pairs of operations. - /// As a consequence we must allocate a new FuncBuilder + ScopedContext and + /// As a consequence we must allocate a new OpBuilder + ScopedContext and /// let the escape. /// Step back "prev" times from the end of the block to set up the insertion /// point, which is useful for non-empty blocks. void enter(mlir::Block *block, int prev = 0) { bodyScope = new ScopedContext( *ScopedContext::getBuilder(), - FuncBuilder::InsertPoint(block, std::prev(block->end(), prev)), + OpBuilder::InsertPoint(block, std::prev(block->end(), prev)), ScopedContext::getLocation()); bodyScope->nestedBuilder = this; } /// Exit the current mlir::Block by explicitly deleting the dynamically - /// allocated FuncBuilder and ScopedContext. + /// allocated OpBuilder and ScopedContext. void exit() { // Reclaim now to exit the scope. bodyScope->nestedBuilder = nullptr; diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h index 3c627b4ef3f..381a790cfe7 100644 --- a/mlir/include/mlir/IR/Block.h +++ b/mlir/include/mlir/IR/Block.h @@ -344,6 +344,14 @@ public: explicit Region(Operation *container); ~Region(); + /// Return the context this region is inserted in. The region must have a + /// valid parent container. + MLIRContext *getContext(); + + /// Return a location for this region. This is the location attached to the + /// parent container. The region must have a valid parent container. + Location getLoc(); + using RegionType = llvm::iplist; RegionType &getBlocks() { return blocks; } @@ -409,6 +417,13 @@ public: /// the operation with an offending use. bool isIsolatedAbove(llvm::Optional noteLoc = llvm::None); + /// Walk the operations in this block in postorder, calling the callback for + /// each operation. + void walk(const std::function &callback) { + for (auto &block : *this) + block.walk(callback); + } + private: RegionType blocks; diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h index b869dcdaf4a..09eaf5669a6 100644 --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -181,40 +181,37 @@ protected: MLIRContext *context; }; -/// This class helps build a Function. Operations that are created are -/// automatically inserted at an insertion point. The builder is copyable. -class FuncBuilder : public Builder { +/// This class helps build Operations. Operations that are created are +/// automatically inserted at an insertion point. The builder is copyable. +class OpBuilder : public Builder { public: - /// Create a function builder and set the insertion point to the start of - /// the function. - explicit FuncBuilder(Function *func) - : Builder(func->getContext()), function(func) { - if (!func->empty()) - setInsertionPoint(&func->front(), func->front().begin()); + /// Create a builder and set the insertion point to the start of the region. + explicit OpBuilder(Region *region) + : Builder(region->getContext()), region(region) { + if (!region->empty()) + setInsertionPoint(®ion->front(), region->front().begin()); else clearInsertionPoint(); } + explicit OpBuilder(Region ®ion) : OpBuilder(®ion) {} - explicit FuncBuilder(Function &func) : FuncBuilder(&func) {} - virtual ~FuncBuilder(); + virtual ~OpBuilder(); - /// Create a function builder and set insertion point to the given - /// operation, which will cause subsequent insertions to go right before it. - FuncBuilder(Operation *op) : FuncBuilder(op->getFunction()) { + /// Create a builder and set insertion point to the given operation, which + /// will cause subsequent insertions to go right before it. + OpBuilder(Operation *op) : OpBuilder(op->getContainingRegion()) { setInsertionPoint(op); } - FuncBuilder(Block *block) : FuncBuilder(block->getFunction()) { - setInsertionPoint(block, block->end()); - } + OpBuilder(Block *block) : OpBuilder(block, block->end()) {} - FuncBuilder(Block *block, Block::iterator insertPoint) - : FuncBuilder(block->getFunction()) { + OpBuilder(Block *block, Block::iterator insertPoint) + : OpBuilder(block->getParent()) { setInsertionPoint(block, insertPoint); } - /// Return the function this builder is referring to. - Function *getFunction() const { return function; } + /// Return the region this builder is referring to. + Region *getRegion() const { return region; } /// This class represents a saved insertion point. class InsertPoint { @@ -291,7 +288,7 @@ public: /// Add new block and set the insertion point to the end of it. If an /// 'insertBefore' block is passed, the block will be placed before the /// specified block. If not, the block will be appended to the end of the - /// current function. + /// current region. Block *createBlock(Block *insertBefore = nullptr); /// Returns the current block of the builder. @@ -342,7 +339,7 @@ public: } private: - Function *function; + Region *region; Block *block = nullptr; Block::iterator insertPoint; }; diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h index bbca58bf521..08fb4905e37 100644 --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -266,7 +266,7 @@ template struct OpRewritePattern : public RewritePattern { /// to apply patterns and observe their effects (e.g. to keep worklists or /// other data structures up to date). /// -class PatternRewriter : public FuncBuilder { +class PatternRewriter : public OpBuilder { public: /// Create operation of specific op type at the current insertion point /// without verifying to see if it is valid. @@ -342,7 +342,7 @@ public: ArrayRef valuesToRemoveIfDead = {}); protected: - PatternRewriter(Function *fn) : FuncBuilder(fn) {} + PatternRewriter(Region ®ion) : OpBuilder(region) {} virtual ~PatternRewriter(); // These are the callback methods that subclasses can choose to implement if diff --git a/mlir/include/mlir/Linalg/IR/LinalgOps.h b/mlir/include/mlir/Linalg/IR/LinalgOps.h index 92f2630dae0..9b023448240 100644 --- a/mlir/include/mlir/Linalg/IR/LinalgOps.h +++ b/mlir/include/mlir/Linalg/IR/LinalgOps.h @@ -113,9 +113,9 @@ public: /// Return a Builder set up to insert operations immediately before the /// terminator. - FuncBuilder getBodyBuilder() { + OpBuilder getBodyBuilder() { Block *body = getBody(); - return FuncBuilder(body, std::prev(body->end())); + return OpBuilder(body, std::prev(body->end())); } /// Get the body of the ForOp. @@ -408,7 +408,7 @@ public: unsigned getNumInputsAndOutputs() { return impl->getNumInputsAndOutputs(getOperation()); } - Operation *create(FuncBuilder &builder, Location loc, + Operation *create(OpBuilder &builder, Location loc, ArrayRef operands) { return impl->create(builder, loc, operands); } @@ -425,7 +425,7 @@ private: virtual unsigned getNumReductionLoops(Operation *op) = 0; virtual unsigned getNumWindowLoops(Operation *op) = 0; virtual unsigned getNumLoops(Operation *op) = 0; - virtual Operation *create(FuncBuilder &builder, Location loc, + virtual Operation *create(OpBuilder &builder, Location loc, ArrayRef operands) = 0; }; @@ -458,7 +458,7 @@ private: unsigned getNumLoops(Operation *op) override { return cast(op).getNumLoops(); } - Operation *create(FuncBuilder &builder, Location loc, + Operation *create(OpBuilder &builder, Location loc, ArrayRef operands) override { return builder.create(loc, operands); } diff --git a/mlir/include/mlir/Linalg/Utils/Utils.h b/mlir/include/mlir/Linalg/Utils/Utils.h index 31963b243b0..594a9d116ca 100644 --- a/mlir/include/mlir/Linalg/Utils/Utils.h +++ b/mlir/include/mlir/Linalg/Utils/Utils.h @@ -88,7 +88,7 @@ SmallVector getViewSizes(LinalgOp &linalgOp); /// Returns the values obtained by applying `map` to the list of values. /// Performs simplifications and foldings where possible. -SmallVector applyMapToValues(FuncBuilder *b, Location loc, +SmallVector applyMapToValues(OpBuilder *b, Location loc, AffineMap map, ArrayRef values, FunctionConstants &state); diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index 3886f0c7a0a..8b476c0dc3e 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -31,7 +31,6 @@ namespace mlir { // Forward declarations. class Block; -class FuncBuilder; class MLIRContext; class Operation; class Type; diff --git a/mlir/include/mlir/Transforms/LoopUtils.h b/mlir/include/mlir/Transforms/LoopUtils.h index 1105688aa55..8a255228893 100644 --- a/mlir/include/mlir/Transforms/LoopUtils.h +++ b/mlir/include/mlir/Transforms/LoopUtils.h @@ -31,7 +31,7 @@ namespace mlir { class AffineMap; class AffineForOp; class Function; -class FuncBuilder; +class OpBuilder; class Value; /// Unrolls this for operation completely if the trip count is known to be @@ -80,7 +80,7 @@ void promoteSingleIterationLoops(Function *f); void getCleanupLoopLowerBound(AffineForOp forOp, unsigned unrollFactor, AffineMap *map, SmallVectorImpl *operands, - FuncBuilder *builder); + OpBuilder *builder); /// Skew the operations in the body of a 'affine.for' operation with the /// specified operation-wise shifts. The shifts are with respect to the diff --git a/mlir/include/mlir/Transforms/Utils.h b/mlir/include/mlir/Transforms/Utils.h index 75407ad59b5..1b32a98206c 100644 --- a/mlir/include/mlir/Transforms/Utils.h +++ b/mlir/include/mlir/Transforms/Utils.h @@ -34,11 +34,9 @@ namespace mlir { class AffineApplyOp; class AffineForOp; -class FuncBuilder; class Location; class Module; - -class Function; +class OpBuilder; /// Replaces all "deferencing" uses of oldMemRef with newMemRef while optionally /// remapping the old memref's indices using the supplied affine map, @@ -83,7 +81,7 @@ bool replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, /// these will also be collected into a single (multi-result) affine apply op. /// The final results of the composed AffineApplyOp are returned in output /// parameter 'results'. Returns the affine apply op created. -Operation *createComposedAffineApplyOp(FuncBuilder *builder, Location loc, +Operation *createComposedAffineApplyOp(OpBuilder *builder, Location loc, ArrayRef operands, ArrayRef affineApplyOps, SmallVectorImpl *results); diff --git a/mlir/lib/AffineOps/AffineOps.cpp b/mlir/lib/AffineOps/AffineOps.cpp index 28594a34d45..9189acf5f50 100644 --- a/mlir/lib/AffineOps/AffineOps.cpp +++ b/mlir/lib/AffineOps/AffineOps.cpp @@ -544,7 +544,7 @@ void mlir::fullyComposeAffineMapAndOperands( } } -AffineApplyOp mlir::makeComposedAffineApply(FuncBuilder *b, Location loc, +AffineApplyOp mlir::makeComposedAffineApply(OpBuilder *b, Location loc, AffineMap map, ArrayRef operands) { AffineMap normalizedMap = map; @@ -1069,9 +1069,9 @@ void AffineForOp::getCanonicalizationPatterns(OwningRewritePatternList &results, results.push_back(llvm::make_unique(context)); } -FuncBuilder AffineForOp::getBodyBuilder() { +OpBuilder AffineForOp::getBodyBuilder() { Block *body = getBody(); - return FuncBuilder(body, std::prev(body->end())); + return OpBuilder(body, std::prev(body->end())); } AffineBound AffineForOp::getLowerBound() { diff --git a/mlir/lib/Analysis/LoopAnalysis.cpp b/mlir/lib/Analysis/LoopAnalysis.cpp index 117cf6e109e..16e092b8205 100644 --- a/mlir/lib/Analysis/LoopAnalysis.cpp +++ b/mlir/lib/Analysis/LoopAnalysis.cpp @@ -54,7 +54,7 @@ void mlir::buildTripCountMapAndOperands( int64_t loopSpan; int64_t step = forOp.getStep(); - FuncBuilder b(forOp.getOperation()); + OpBuilder b(forOp.getOperation()); if (forOp.hasConstantBounds()) { int64_t lb = forOp.getConstantLowerBound(); diff --git a/mlir/lib/Analysis/TestParallelismDetection.cpp b/mlir/lib/Analysis/TestParallelismDetection.cpp index ae5551db215..cbda6d40224 100644 --- a/mlir/lib/Analysis/TestParallelismDetection.cpp +++ b/mlir/lib/Analysis/TestParallelismDetection.cpp @@ -44,7 +44,7 @@ FunctionPassBase *mlir::createParallelismDetectionTestPass() { // parallel. void TestParallelismDetection::runOnFunction() { Function &f = getFunction(); - FuncBuilder b(f); + OpBuilder b(f.getBody()); f.walk([&](AffineForOp forOp) { if (isLoopParallel(forOp)) forOp.emitRemark("parallel loop"); diff --git a/mlir/lib/Analysis/Utils.cpp b/mlir/lib/Analysis/Utils.cpp index 476c7c87aec..aa842364f26 100644 --- a/mlir/lib/Analysis/Utils.cpp +++ b/mlir/lib/Analysis/Utils.cpp @@ -749,7 +749,7 @@ mlir::insertBackwardComputationSlice(Operation *srcOpInst, Operation *dstOpInst, // Clone src loop nest and insert it a the beginning of the operation block // of the loop at 'dstLoopDepth' in 'dstLoopIVs'. auto dstAffineForOp = dstLoopIVs[dstLoopDepth - 1]; - FuncBuilder b(dstAffineForOp.getBody(), dstAffineForOp.getBody()->begin()); + OpBuilder b(dstAffineForOp.getBody(), dstAffineForOp.getBody()->begin()); auto sliceLoopNest = cast(b.clone(*srcLoopIVs[0].getOperation())); diff --git a/mlir/lib/EDSC/Builders.cpp b/mlir/lib/EDSC/Builders.cpp index 22f91399498..6f6363ffcc5 100644 --- a/mlir/lib/EDSC/Builders.cpp +++ b/mlir/lib/EDSC/Builders.cpp @@ -24,8 +24,7 @@ using namespace mlir; using namespace mlir::edsc; -mlir::edsc::ScopedContext::ScopedContext(FuncBuilder &builder, - Location location) +mlir::edsc::ScopedContext::ScopedContext(OpBuilder &builder, Location location) : builder(builder), location(location), enclosingScopedContext(ScopedContext::getCurrentScopedContext()), nestedBuilder(nullptr) { @@ -35,8 +34,8 @@ mlir::edsc::ScopedContext::ScopedContext(FuncBuilder &builder, /// Sets the insertion point of the builder to 'newInsertPt' for the duration /// of the scope. The existing insertion point of the builder is restored on /// destruction. -mlir::edsc::ScopedContext::ScopedContext(FuncBuilder &builder, - FuncBuilder::InsertPoint newInsertPt, +mlir::edsc::ScopedContext::ScopedContext(OpBuilder &builder, + OpBuilder::InsertPoint newInsertPt, Location location) : builder(builder), prevBuilderInsertPoint(builder.saveInsertionPoint()), location(location), @@ -59,7 +58,7 @@ ScopedContext *&mlir::edsc::ScopedContext::getCurrentScopedContext() { return context; } -FuncBuilder *mlir::edsc::ScopedContext::getBuilder() { +OpBuilder *mlir::edsc::ScopedContext::getBuilder() { assert(ScopedContext::getCurrentScopedContext() && "Unexpected Null ScopedContext"); return &ScopedContext::getCurrentScopedContext()->builder; diff --git a/mlir/lib/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/GPU/Transforms/KernelOutlining.cpp index 163a7cf6b6c..86fab1a20f1 100644 --- a/mlir/lib/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/GPU/Transforms/KernelOutlining.cpp @@ -30,7 +30,7 @@ using namespace mlir; namespace { template -void createForAllDimensions(FuncBuilder &builder, Location loc, +void createForAllDimensions(OpBuilder &builder, Location loc, SmallVectorImpl &values) { for (StringRef dim : {"x", "y", "z"}) { Value *v = builder.create(loc, builder.getIndexType(), @@ -42,12 +42,12 @@ void createForAllDimensions(FuncBuilder &builder, Location loc, // Add operations generating block/thread ids and gird/block dimensions at the // beginning of `kernelFunc` and replace uses of the respective function args. void injectGpuIndexOperations(Location loc, Function &kernelFunc) { - FuncBuilder funcBuilder(kernelFunc); + OpBuilder OpBuilder(kernelFunc.getBody()); SmallVector indexOps; - createForAllDimensions(funcBuilder, loc, indexOps); - createForAllDimensions(funcBuilder, loc, indexOps); - createForAllDimensions(funcBuilder, loc, indexOps); - createForAllDimensions(funcBuilder, loc, indexOps); + createForAllDimensions(OpBuilder, loc, indexOps); + createForAllDimensions(OpBuilder, loc, indexOps); + createForAllDimensions(OpBuilder, loc, indexOps); + createForAllDimensions(OpBuilder, loc, indexOps); // Replace the leading 12 function args with the respective thread/block index // operations. Iterate backwards since args are erased and indices change. for (int i = 11; i >= 0; --i) { @@ -78,10 +78,10 @@ Function *outlineKernelFunc(Module &module, gpu::LaunchOp &launchOp) { // Replace `gpu.launch` operations with an `gpu.launch_func` operation launching // `kernelFunc`. void convertToLaunchFuncOp(gpu::LaunchOp &launchOp, Function &kernelFunc) { - FuncBuilder funcBuilder(launchOp); + OpBuilder OpBuilder(launchOp); SmallVector kernelOperandValues( launchOp.getKernelOperandValues()); - funcBuilder.create( + OpBuilder.create( launchOp.getLoc(), &kernelFunc, launchOp.getGridSizeOperandValues(), launchOp.getBlockSizeOperandValues(), kernelOperandValues); launchOp.erase(); diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp index cf85cc86ef0..9595a72c226 100644 --- a/mlir/lib/IR/Block.cpp +++ b/mlir/lib/IR/Block.cpp @@ -282,6 +282,24 @@ Region::~Region() { bb.dropAllReferences(); } +/// Return the context this region is inserted in. The region must have a valid +/// parent container. +MLIRContext *Region::getContext() { + assert(!container.isNull() && "region is not attached to a container"); + if (auto *inst = getContainingOp()) + return inst->getContext(); + return getContainingFunction()->getContext(); +} + +/// Return a location for this region. This is the location attached to the +/// parent container. The region must have a valid parent container. +Location Region::getLoc() { + assert(!container.isNull() && "region is not attached to a container"); + if (auto *inst = getContainingOp()) + return inst->getLoc(); + return getContainingFunction()->getLoc(); +} + Region *Region::getContainingRegion() { if (auto *inst = getContainingOp()) return inst->getContainingRegion(); diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp index 4accfb54e28..d32e705785a 100644 --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -332,31 +332,31 @@ AffineMap Builder::getShiftedAffineMap(AffineMap map, int64_t shift) { } //===----------------------------------------------------------------------===// -// Operations. +// OpBuilder. //===----------------------------------------------------------------------===// -FuncBuilder::~FuncBuilder() {} +OpBuilder::~OpBuilder() {} /// Add new block and set the insertion point to the end of it. If an /// 'insertBefore' block is passed, the block will be placed before the /// specified block. If not, the block will be appended to the end of the /// current function. -Block *FuncBuilder::createBlock(Block *insertBefore) { +Block *OpBuilder::createBlock(Block *insertBefore) { Block *b = new Block(); // If we are supposed to insert before a specific block, do so, otherwise add // the block to the end of the function. if (insertBefore) - function->getBlocks().insert(Function::iterator(insertBefore), b); + region->getBlocks().insert(Function::iterator(insertBefore), b); else - function->push_back(b); + region->push_back(b); setInsertionPointToEnd(b); return b; } /// Create an operation given the fields represented as an OperationState. -Operation *FuncBuilder::createOperation(const OperationState &state) { +Operation *OpBuilder::createOperation(const OperationState &state) { assert(block && "createOperation() called without setting builder's block"); auto *op = Operation::create(state); block->getOperations().insert(insertPoint, op); diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp index f53c7156825..6ab5a6febf0 100644 --- a/mlir/lib/IR/Function.cpp +++ b/mlir/lib/IR/Function.cpp @@ -214,9 +214,7 @@ void Function::addEntryBlock() { } void Function::walk(const std::function &callback) { - // Walk each of the blocks within the function. - for (auto &block : getBlocks()) - block.walk(callback); + getBody().walk(callback); } //===----------------------------------------------------------------------===// diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp index 64fb8bcd0e2..5804770a88f 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -312,8 +312,7 @@ void Operation::replaceUsesOfWith(Value *from, Value *to) { void Operation::walk(const std::function &callback) { // Visit any internal operations. for (auto ®ion : getRegions()) - for (auto &block : region) - block.walk(callback); + region.walk(callback); // Visit the current operation. callback(this); diff --git a/mlir/lib/LLVMIR/Transforms/ConvertToLLVMDialect.cpp b/mlir/lib/LLVMIR/Transforms/ConvertToLLVMDialect.cpp index 0e30a8e147e..1b50320071c 100644 --- a/mlir/lib/LLVMIR/Transforms/ConvertToLLVMDialect.cpp +++ b/mlir/lib/LLVMIR/Transforms/ConvertToLLVMDialect.cpp @@ -889,7 +889,7 @@ static void ensureDistinctSuccessors(Block &bb) { position != end; ++position) { auto *dummyBlock = new Block(); bb.getParent()->push_back(dummyBlock); - auto builder = FuncBuilder(dummyBlock); + auto builder = OpBuilder(dummyBlock); SmallVector operands( terminator->getSuccessorOperands(*position)); builder.create(terminator->getLoc(), successor.first, operands); diff --git a/mlir/lib/Linalg/IR/LinalgOps.cpp b/mlir/lib/Linalg/IR/LinalgOps.cpp index 55a791a6d63..3b3a04012fd 100644 --- a/mlir/lib/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Linalg/IR/LinalgOps.cpp @@ -773,7 +773,7 @@ void mlir::linalg::emitScalarImplementation( using edsc::intrinsics::select; // account for affine.terminator in loop. - FuncBuilder b(body, std::prev(body->end(), 1)); + OpBuilder b(body, std::prev(body->end(), 1)); ScopedContext scope(b, innermostLoop.getLoc()); auto *op = linalgOp.getOperation(); if (isa(op)) { diff --git a/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp b/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp index 60c0daf7938..b3857ac5171 100644 --- a/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp +++ b/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp @@ -621,7 +621,7 @@ static void lowerLinalgForToCFG(Function &f) { auto *op = forOp.getOperation(); auto loc = op->getLoc(); using namespace edsc::op; - FuncBuilder builder(op); + OpBuilder builder(op); ScopedContext scope(builder, loc); ValueHandle lb(forOp.getLowerBound()), ub(forOp.getUpperBound()), step(forOp.getStep()); diff --git a/mlir/lib/Linalg/Transforms/LowerToLoops.cpp b/mlir/lib/Linalg/Transforms/LowerToLoops.cpp index b2f59c43da1..5e22f8601fc 100644 --- a/mlir/lib/Linalg/Transforms/LowerToLoops.cpp +++ b/mlir/lib/Linalg/Transforms/LowerToLoops.cpp @@ -35,7 +35,7 @@ using namespace mlir::linalg; // Creates a number of ranges equal to the number of results in `map`. // The returned ranges correspond to the loop ranges, in the proper order, for // which new loops will be created. -static SmallVector emitLoopRanges(FuncBuilder *b, Location loc, +static SmallVector emitLoopRanges(OpBuilder *b, Location loc, AffineMap map, ArrayRef allViewSizes, FunctionConstants &state) { @@ -51,7 +51,7 @@ static SmallVector emitLoopRanges(FuncBuilder *b, Location loc, } static void emitLinalgOpAsLoops(LinalgOp &linalgOp, FunctionConstants &state) { - FuncBuilder b(linalgOp.getOperation()); + OpBuilder b(linalgOp.getOperation()); ScopedContext scope(b, linalgOp.getOperation()->getLoc()); auto loopRanges = emitLoopRanges( scope.getBuilder(), scope.getLocation(), diff --git a/mlir/lib/Linalg/Transforms/Tiling.cpp b/mlir/lib/Linalg/Transforms/Tiling.cpp index 22090ca6aac..bc2ed2b60de 100644 --- a/mlir/lib/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Linalg/Transforms/Tiling.cpp @@ -58,7 +58,7 @@ static bool isZero(Value *v) { // The returned ranges correspond to the loop ranges, in the proper order, that // are tiled and for which new loops will be created. static SmallVector -makeTiledLoopRanges(FuncBuilder *b, Location loc, AffineMap map, +makeTiledLoopRanges(OpBuilder *b, Location loc, AffineMap map, ArrayRef allViewSizes, ArrayRef allTileSizes, FunctionConstants &state) { assert(allTileSizes.size() == map.getNumResults()); @@ -127,7 +127,7 @@ static Value *foldRange(Value *view, unsigned dim) { return nullptr; } -static SmallVector makeTiledViews(FuncBuilder *b, Location loc, +static SmallVector makeTiledViews(OpBuilder *b, Location loc, LinalgOp &linalgOp, ArrayRef ivs, ArrayRef tileSizes, @@ -210,7 +210,7 @@ static LogicalResult tileLinalgOp(LinalgOp &op, ArrayRef tileSizes, tileSizes.size() && "expected matching number of tile sizes and loops"); - FuncBuilder builder(op.getOperation()); + OpBuilder builder(op.getOperation()); ScopedContext scope(builder, op.getLoc()); auto loopRanges = makeTiledLoopRanges( scope.getBuilder(), scope.getLocation(), diff --git a/mlir/lib/Linalg/Utils/Utils.cpp b/mlir/lib/Linalg/Utils/Utils.cpp index f19e61c5531..81fad1c870a 100644 --- a/mlir/lib/Linalg/Utils/Utils.cpp +++ b/mlir/lib/Linalg/Utils/Utils.cpp @@ -109,7 +109,7 @@ static Value *tryFold(AffineMap map, ArrayRef operands, return nullptr; } -static Value *emitOrFoldComposedAffineApply(FuncBuilder *b, Location loc, +static Value *emitOrFoldComposedAffineApply(OpBuilder *b, Location loc, AffineMap map, ArrayRef operandsRef, FunctionConstants &state) { @@ -121,7 +121,7 @@ static Value *emitOrFoldComposedAffineApply(FuncBuilder *b, Location loc, } SmallVector -mlir::linalg::applyMapToValues(FuncBuilder *b, Location loc, AffineMap map, +mlir::linalg::applyMapToValues(OpBuilder *b, Location loc, AffineMap map, ArrayRef values, FunctionConstants &state) { SmallVector res; @@ -141,7 +141,7 @@ Value *FunctionConstants::getOrCreateIndex(int64_t v) { auto it = map.find(v); if (it != map.end()) return it->second; - FuncBuilder builder(f); + OpBuilder builder(f.getBody()); edsc::ScopedContext s(builder, f.getLoc()); return map.insert(std::make_pair(v, edsc::intrinsics::constant_index(v))) .first->getSecond(); diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index 6cc933a8169..a3d44f9935e 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -2302,11 +2302,11 @@ public: /// more specific builder type. #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wshadow-field" - FuncBuilder builder; + OpBuilder builder; #pragma clang diagnostic pop FunctionParser(ParserState &state, Function *function) - : Parser(state), builder(function), function(function) {} + : Parser(state), builder(function->getBody()), function(function) {} ~FunctionParser(); diff --git a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp index 75c082fd8ce..375a64d8f2d 100644 --- a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp +++ b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp @@ -77,7 +77,7 @@ void AddDefaultStatsPass::runWithConfig(SolverContext &solverContext, for (auto *arg : func.getArguments()) { if (!config.isHandledType(arg->getType())) continue; - FuncBuilder b(func); + OpBuilder b(func.getBody()); APFloat minValue(-1.0f); APFloat maxValue(1.0f); ElementsAttr layerStats = DenseFPElementsAttr::get( @@ -102,7 +102,7 @@ void AddDefaultStatsPass::runWithConfig(SolverContext &solverContext, if (!config.isHandledType(originalResult->getType())) return; - FuncBuilder b(op->getBlock(), ++op->getIterator()); + OpBuilder b(op->getBlock(), ++op->getIterator()); APFloat minValue(-1.0f); APFloat maxValue(1.0f); diff --git a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp index 94bac98598c..c443354714f 100644 --- a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp +++ b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp @@ -184,7 +184,7 @@ void InferQuantizedTypesPass::transformOperandType(CAGOperandAnchor *anchor, Type newType) { Value *inputValue = anchor->getValue(); Operation *op = anchor->getOp(); - FuncBuilder b(op->getBlock(), Block::iterator(op)); + OpBuilder b(op->getBlock(), Block::iterator(op)); SmallVector removeValuesIfDead; @@ -240,7 +240,7 @@ void InferQuantizedTypesPass::transformResultType(CAGResultAnchor *anchor, Type newType) { Value *origResultValue = anchor->getValue(); Operation *op = origResultValue->getDefiningOp(); - FuncBuilder b(op->getBlock(), ++Block::iterator(op)); + OpBuilder b(op->getBlock(), ++Block::iterator(op)); Value *replacedResultValue = nullptr; Value *newResultValue = nullptr; diff --git a/mlir/lib/Transforms/DialectConversion.cpp b/mlir/lib/Transforms/DialectConversion.cpp index 6002cadd37d..1deedc1520c 100644 --- a/mlir/lib/Transforms/DialectConversion.cpp +++ b/mlir/lib/Transforms/DialectConversion.cpp @@ -108,8 +108,8 @@ struct DialectConversionRewriter final : public PatternRewriter { SmallVector newValues; }; - DialectConversionRewriter(Function *fn) - : PatternRewriter(fn), argConverter(fn->getContext()) {} + DialectConversionRewriter(Region ®ion) + : PatternRewriter(region), argConverter(region.getContext()) {} ~DialectConversionRewriter() = default; /// Cleanup and destroy any generated rewrite operations. This method is @@ -151,7 +151,7 @@ struct DialectConversionRewriter final : public PatternRewriter { /// PatternRewriter hook for creating a new operation. Operation *createOperation(const OperationState &state) override { - auto *result = FuncBuilder::createOperation(state); + auto *result = OpBuilder::createOperation(state); createdOps.push_back(result); return result; } @@ -572,7 +572,7 @@ LogicalResult FunctionConverter::convertFunction(Function *f) { return success(); // Rewrite the function body. - DialectConversionRewriter rewriter(f); + DialectConversionRewriter rewriter(f->getBody()); if (failed(convertRegion(rewriter, f->getBody(), f->getLoc()))) { // Reset any of the generated rewrites. rewriter.discardRewrites(); diff --git a/mlir/lib/Transforms/DmaGeneration.cpp b/mlir/lib/Transforms/DmaGeneration.cpp index 1ead2e5c8e2..7c745aa1a0b 100644 --- a/mlir/lib/Transforms/DmaGeneration.cpp +++ b/mlir/lib/Transforms/DmaGeneration.cpp @@ -240,14 +240,14 @@ bool DmaGeneration::generateDma(const MemRefRegion ®ion, Block *block, return true; // DMAs for read regions are going to be inserted just before the for loop. - FuncBuilder prologue(block, begin); + OpBuilder prologue(block, begin); // DMAs for write regions are going to be inserted just after the for loop. - FuncBuilder epilogue(block, end); - FuncBuilder *b = region.isWrite() ? &epilogue : &prologue; + OpBuilder epilogue(block, end); + OpBuilder *b = region.isWrite() ? &epilogue : &prologue; // Builder to create constants at the top level. auto *func = block->getFunction(); - FuncBuilder top(func); + OpBuilder top(func->getBody()); auto loc = region.loc; auto *memref = region.memref; @@ -759,7 +759,7 @@ uint64_t DmaGeneration::runOnBlock(Block::iterator begin, Block::iterator end) { void DmaGeneration::runOnFunction() { Function &f = getFunction(); - FuncBuilder topBuilder(f); + OpBuilder topBuilder(f.getBody()); zeroIndex = topBuilder.create(f.getLoc(), 0); // Override default is a command line option is provided. diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index b7b69fa54fe..0f39e52eefb 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -1006,9 +1006,9 @@ static Value *createPrivateMemRef(AffineForOp forOp, Operation *srcStoreOpInst, auto *forInst = forOp.getOperation(); // Create builder to insert alloc op just before 'forOp'. - FuncBuilder b(forInst); + OpBuilder b(forInst); // Builder to create constants at the top level. - FuncBuilder top(forInst->getFunction()); + OpBuilder top(forInst->getFunction()->getBody()); // Create new memref type based on slice bounds. auto *oldMemRef = cast(srcStoreOpInst).getMemRef(); auto oldMemRefType = oldMemRef->getType().cast(); diff --git a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp index 31875664922..c4c1184fa82 100644 --- a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp +++ b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp @@ -203,7 +203,7 @@ void LoopInvariantCodeMotion::runOnAffineForOp(AffineForOp forOp) { SmallPtrSet definedOps; // This is the place where hoisted instructions would reside. - FuncBuilder b(forOp.getOperation()); + OpBuilder b(forOp.getOperation()); SmallPtrSet opsToHoist; SmallVector opsToMove; diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp index 5233081b5f1..c1be6e8f6b1 100644 --- a/mlir/lib/Transforms/LoopTiling.cpp +++ b/mlir/lib/Transforms/LoopTiling.cpp @@ -112,7 +112,7 @@ constructTiledIndexSetHyperRect(MutableArrayRef origLoops, assert(!origLoops.empty()); assert(origLoops.size() == tileSizes.size()); - FuncBuilder b(origLoops[0].getOperation()); + OpBuilder b(origLoops[0].getOperation()); unsigned width = origLoops.size(); // Bounds for tile space loops. @@ -207,7 +207,7 @@ LogicalResult mlir::tileCodeGen(MutableArrayRef band, // Add intra-tile (or point) loops. for (unsigned i = 0; i < width; i++) { - FuncBuilder b(topLoop); + OpBuilder b(topLoop); // Loop bounds will be set later. auto pointLoop = b.create(loc, 0, 0); pointLoop.getBody()->getOperations().splice( @@ -221,7 +221,7 @@ LogicalResult mlir::tileCodeGen(MutableArrayRef band, // Add tile space loops; for (unsigned i = width; i < 2 * width; i++) { - FuncBuilder b(topLoop); + OpBuilder b(topLoop); // Loop bounds will be set later. auto tileSpaceLoop = b.create(loc, 0, 0); tileSpaceLoop.getBody()->getOperations().splice( diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp index 731464bd7c1..409eb397df4 100644 --- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp +++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp @@ -185,8 +185,7 @@ LogicalResult mlir::loopUnrollJamByFactor(AffineForOp forOp, // unrollJamFactor. if (getLargestDivisorOfTripCount(forOp) % unrollJamFactor != 0) { // Insert the cleanup loop right after 'forOp'. - FuncBuilder builder(forInst->getBlock(), - std::next(Block::iterator(forInst))); + OpBuilder builder(forInst->getBlock(), std::next(Block::iterator(forInst))); auto cleanupAffineForOp = cast(builder.clone(*forInst)); // Adjust the lower bound of the cleanup loop; its upper bound is the same // as the original loop's upper bound. @@ -212,7 +211,7 @@ LogicalResult mlir::loopUnrollJamByFactor(AffineForOp forOp, for (auto &subBlock : subBlocks) { // Builder to insert unroll-jammed bodies. Insert right at the end of // sub-block. - FuncBuilder builder(subBlock.first->getBlock(), std::next(subBlock.second)); + OpBuilder builder(subBlock.first->getBlock(), std::next(subBlock.second)); // Unroll and jam (appends unrollJamFactor-1 additional copies). for (unsigned i = 1; i < unrollJamFactor; i++) { diff --git a/mlir/lib/Transforms/LowerAffine.cpp b/mlir/lib/Transforms/LowerAffine.cpp index 4dcc82f1178..b890b43da81 100644 --- a/mlir/lib/Transforms/LowerAffine.cpp +++ b/mlir/lib/Transforms/LowerAffine.cpp @@ -41,7 +41,7 @@ class AffineApplyExpander public: // This internal class expects arguments to be non-null, checks must be // performed at the call site. - AffineApplyExpander(FuncBuilder *builder, ArrayRef dimValues, + AffineApplyExpander(OpBuilder *builder, ArrayRef dimValues, ArrayRef symbolValues, Location loc) : builder(*builder), dimValues(dimValues), symbolValues(symbolValues), loc(loc) {} @@ -206,7 +206,7 @@ public: } private: - FuncBuilder &builder; + OpBuilder &builder; ArrayRef dimValues; ArrayRef symbolValues; @@ -216,7 +216,7 @@ private: // Create a sequence of operations that implement the `expr` applied to the // given dimension and symbol values. -static mlir::Value *expandAffineExpr(FuncBuilder *builder, Location loc, +static mlir::Value *expandAffineExpr(OpBuilder *builder, Location loc, AffineExpr expr, ArrayRef dimValues, ArrayRef symbolValues) { @@ -226,7 +226,7 @@ static mlir::Value *expandAffineExpr(FuncBuilder *builder, Location loc, // Create a sequence of operations that implement the `affineMap` applied to // the given `operands` (as it it were an AffineApplyOp). Optional> static expandAffineMap( - FuncBuilder *builder, Location loc, AffineMap affineMap, + OpBuilder *builder, Location loc, AffineMap affineMap, ArrayRef operands) { auto numDims = affineMap.getNumDims(); auto expanded = functional::map( @@ -260,7 +260,7 @@ struct LowerAffinePass : public FunctionPass { // recognize as a reduction by the subsequent passes. static Value *buildMinMaxReductionSeq(Location loc, CmpIPredicate predicate, ArrayRef values, - FuncBuilder &builder) { + OpBuilder &builder) { assert(!llvm::empty(values) && "empty min/max chain"); auto valueIt = values.begin(); @@ -348,7 +348,7 @@ static LogicalResult lowerAffineFor(AffineForOp forOp) { // Append the induction variable stepping logic and branch back to the exit // condition block. Construct an affine expression f : (x -> x+step) and // apply this expression to the induction variable. - FuncBuilder builder(bodyBlock); + OpBuilder builder(bodyBlock); auto affStep = builder.getAffineConstantExpr(forOp.getStep()); auto affDim = builder.getAffineDimExpr(0); auto stepped = expandAffineExpr(&builder, loc, affDim + affStep, iv, {}); @@ -482,7 +482,7 @@ static LogicalResult lowerAffineIf(AffineIfOp ifOp) { std::prev(oldThen->end())); } - FuncBuilder builder(thenBlock); + OpBuilder builder(thenBlock); builder.create(loc, continueBlock); // Handle the 'else' block the same way, but we skip it if we have no else @@ -569,7 +569,7 @@ static LogicalResult lowerAffineIf(AffineIfOp ifOp) { // Convert an "affine.apply" operation into a sequence of arithmetic // operations using the StandardOps dialect. Return true on error. static LogicalResult lowerAffineApply(AffineApplyOp op) { - FuncBuilder builder(op.getOperation()); + OpBuilder builder(op.getOperation()); auto maybeExpandedMap = expandAffineMap(&builder, op.getLoc(), op.getAffineMap(), llvm::to_vector<8>(op.getOperands())); diff --git a/mlir/lib/Transforms/MaterializeVectors.cpp b/mlir/lib/Transforms/MaterializeVectors.cpp index 80e080f8fa6..0d8cfea7312 100644 --- a/mlir/lib/Transforms/MaterializeVectors.cpp +++ b/mlir/lib/Transforms/MaterializeVectors.cpp @@ -238,7 +238,7 @@ static SmallVector delinearize(unsigned linearIndex, return res; } -static Operation *instantiate(FuncBuilder *b, Operation *opInst, +static Operation *instantiate(OpBuilder *b, Operation *opInst, VectorType hwVectorType, DenseMap *substitutionsMap); @@ -257,7 +257,7 @@ static Value *substitute(Value *v, VectorType hwVectorType, if (it == substitutionsMap->end()) { auto *opInst = v->getDefiningOp(); if (isa(opInst)) { - FuncBuilder b(opInst); + OpBuilder b(opInst); auto *op = instantiate(&b, opInst, hwVectorType, substitutionsMap); auto res = substitutionsMap->insert(std::make_pair(v, op->getResult(0))); assert(res.second && "Insertion failed"); @@ -331,7 +331,7 @@ static Value *substitute(Value *v, VectorType hwVectorType, /// TODO(ntv): these implementation details should be captured in a /// vectorization trait at the op level directly. static SmallVector -reindexAffineIndices(FuncBuilder *b, VectorType hwVectorType, +reindexAffineIndices(OpBuilder *b, VectorType hwVectorType, ArrayRef hwVectorInstance, ArrayRef memrefIndices) { auto vectorShape = hwVectorType.getShape(); @@ -404,7 +404,7 @@ materializeAttributes(Operation *opInst, VectorType hwVectorType) { /// substitutionsMap. /// /// If the underlying substitution fails, this fails too and returns nullptr. -static Operation *instantiate(FuncBuilder *b, Operation *opInst, +static Operation *instantiate(OpBuilder *b, Operation *opInst, VectorType hwVectorType, DenseMap *substitutionsMap) { assert(!isa(opInst) && @@ -481,7 +481,7 @@ static AffineMap projectedPermutationMap(VectorTransferOpTy transfer, /// `hwVectorType` int the covering of the super-vector type. For a more /// detailed description of the problem, see the description of /// reindexAffineIndices. -static Operation *instantiate(FuncBuilder *b, VectorTransferReadOp read, +static Operation *instantiate(OpBuilder *b, VectorTransferReadOp read, VectorType hwVectorType, ArrayRef hwVectorInstance, DenseMap *substitutionsMap) { @@ -505,7 +505,7 @@ static Operation *instantiate(FuncBuilder *b, VectorTransferReadOp read, /// `hwVectorType` int the covering of th3e super-vector type. For a more /// detailed description of the problem, see the description of /// reindexAffineIndices. -static Operation *instantiate(FuncBuilder *b, VectorTransferWriteOp write, +static Operation *instantiate(OpBuilder *b, VectorTransferWriteOp write, VectorType hwVectorType, ArrayRef hwVectorInstance, DenseMap *substitutionsMap) { @@ -547,7 +547,7 @@ static bool instantiateMaterialization(Operation *op, LLVM_DEBUG(dbgs() << "\ninstantiate: " << *op); // Create a builder here for unroll-and-jam effects. - FuncBuilder b(op); + OpBuilder b(op); // AffineApplyOp are ignored: instantiating the proper vector op will take // care of AffineApplyOps by composing them properly. if (isa(op)) { diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp index de8038c931c..d0e0d18d586 100644 --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -73,7 +73,7 @@ static unsigned getTagMemRefPos(Operation &dmaInst) { /// modulo 2. Returns false if such a replacement cannot be performed. static bool doubleBuffer(Value *oldMemRef, AffineForOp forOp) { auto *forBody = forOp.getBody(); - FuncBuilder bInner(forBody, forBody->begin()); + OpBuilder bInner(forBody, forBody->begin()); bInner.setInsertionPoint(forBody, forBody->begin()); // Doubles the shape with a leading dimension extent of 2. @@ -94,7 +94,7 @@ static bool doubleBuffer(Value *oldMemRef, AffineForOp forOp) { // The double buffer is allocated right before 'forInst'. auto *forInst = forOp.getOperation(); - FuncBuilder bOuter(forInst); + OpBuilder bOuter(forInst); // Put together alloc operands for any dynamic dimensions of the memref. SmallVector allocOperands; unsigned dynamicDimCount = 0; @@ -360,7 +360,7 @@ void PipelineDataTransfer::runOnAffineForOp(AffineForOp forOp) { // Tagging operations with shifts for debugging purposes. LLVM_DEBUG({ - FuncBuilder b(&op); + OpBuilder b(&op); op.setAttr("shift", b.getI64IntegerAttr(shifts[s - 1])); }); } diff --git a/mlir/lib/Transforms/Utils/FoldUtils.cpp b/mlir/lib/Transforms/Utils/FoldUtils.cpp index fbf1a2ae9c1..3983dda98fd 100644 --- a/mlir/lib/Transforms/Utils/FoldUtils.cpp +++ b/mlir/lib/Transforms/Utils/FoldUtils.cpp @@ -110,7 +110,7 @@ LogicalResult OperationFolder::tryToFold(Operation *op, assert(foldResults.size() == op->getNumResults()); // Create the result constants and replace the results. - FuncBuilder builder(op); + OpBuilder builder(op); for (unsigned i = 0, e = op->getNumResults(); i != e; ++i) { assert(!foldResults[i].isNull() && "expected valid OpFoldResult"); diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp index a2e64271c46..0cd32255561 100644 --- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp +++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp @@ -46,7 +46,7 @@ class GreedyPatternRewriteDriver : public PatternRewriter { public: explicit GreedyPatternRewriteDriver(Function &fn, OwningRewritePatternList &&patterns) - : PatternRewriter(&fn), matcher(std::move(patterns)) { + : PatternRewriter(fn.getBody()), matcher(std::move(patterns)) { worklist.reserve(64); } @@ -88,7 +88,7 @@ protected: // Implement the hook for creating operations, and make sure that newly // created ops are added to the worklist for processing. Operation *createOperation(const OperationState &state) override { - auto *result = FuncBuilder::createOperation(state); + auto *result = OpBuilder::createOperation(state); addToWorklist(result); return result; } @@ -142,14 +142,16 @@ private: /// Perform the rewrites. bool GreedyPatternRewriteDriver::simplifyFunction(int maxIterations) { - Function *fn = getFunction(); - OperationFolder helper(fn); + Region *region = getRegion(); + + // TODO(riverriddle) OperationFolder should take a region to insert into. + OperationFolder helper(region->getContainingFunction()); bool changed = false; int i = 0; do { // Add all operations to the worklist. - fn->walk([&](Operation *op) { addToWorklist(op); }); + region->walk([&](Operation *op) { addToWorklist(op); }); // These are scratch vectors used in the folding loop below. SmallVector originalOperands, resultValues; diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index d5bdcea2c55..23375e7b472 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -46,7 +46,7 @@ using namespace mlir; void mlir::getCleanupLoopLowerBound(AffineForOp forOp, unsigned unrollFactor, AffineMap *map, SmallVectorImpl *operands, - FuncBuilder *b) { + OpBuilder *b) { auto lbMap = forOp.getLowerBoundMap(); // Single result lower bound map only. @@ -125,15 +125,14 @@ LogicalResult mlir::promoteIfSingleIteration(AffineForOp forOp) { Operation *op = forOp.getOperation(); if (!iv->use_empty()) { if (forOp.hasConstantLowerBound()) { - auto *mlFunc = op->getFunction(); - FuncBuilder topBuilder(mlFunc); + OpBuilder topBuilder(op->getFunction()->getBody()); auto constOp = topBuilder.create( forOp.getLoc(), forOp.getConstantLowerBound()); iv->replaceAllUsesWith(constOp); } else { AffineBound lb = forOp.getLowerBound(); SmallVector lbOperands(lb.operand_begin(), lb.operand_end()); - FuncBuilder builder(op->getBlock(), Block::iterator(op)); + OpBuilder builder(op->getBlock(), Block::iterator(op)); if (lb.getMap() == builder.getDimIdentityMap()) { // No need of generating an affine.apply. iv->replaceAllUsesWith(lbOperands[0]); @@ -173,7 +172,7 @@ static AffineForOp generateLoop(AffineMap lbMap, AffineMap ubMap, const std::vector>> &instGroupQueue, - unsigned offset, AffineForOp srcForInst, FuncBuilder *b) { + unsigned offset, AffineForOp srcForInst, OpBuilder *b) { SmallVector lbOperands(srcForInst.getLowerBoundOperands()); SmallVector ubOperands(srcForInst.getUpperBoundOperands()); @@ -188,7 +187,7 @@ generateLoop(AffineMap lbMap, AffineMap ubMap, BlockAndValueMapping operandMap; - FuncBuilder bodyBuilder = loopChunk.getBodyBuilder(); + OpBuilder bodyBuilder = loopChunk.getBodyBuilder(); for (auto it = instGroupQueue.begin() + offset, e = instGroupQueue.end(); it != e; ++it) { uint64_t shift = it->first; @@ -291,7 +290,7 @@ LogicalResult mlir::instBodySkew(AffineForOp forOp, ArrayRef shifts, auto origLbMap = forOp.getLowerBoundMap(); uint64_t lbShift = 0; - FuncBuilder b(forOp.getOperation()); + OpBuilder b(forOp.getOperation()); for (uint64_t d = 0, e = sortedInstGroups.size(); d < e; ++d) { // If nothing is shifted by d, continue. if (sortedInstGroups[d].empty()) @@ -424,7 +423,7 @@ LogicalResult mlir::loopUnrollByFactor(AffineForOp forOp, // Generate the cleanup loop if trip count isn't a multiple of unrollFactor. Operation *op = forOp.getOperation(); if (getLargestDivisorOfTripCount(forOp) % unrollFactor != 0) { - FuncBuilder builder(op->getBlock(), ++Block::iterator(op)); + OpBuilder builder(op->getBlock(), ++Block::iterator(op)); auto cleanupForInst = cast(builder.clone(*op)); AffineMap cleanupMap; SmallVector cleanupOperands; @@ -448,7 +447,7 @@ LogicalResult mlir::loopUnrollByFactor(AffineForOp forOp, // Builder to insert unrolled bodies just before the terminator of the body of // 'forOp'. - FuncBuilder builder = forOp.getBodyBuilder(); + OpBuilder builder = forOp.getBodyBuilder(); // Keep a pointer to the last non-terminator operation in the original block // so that we know what to clone (since we are doing this in-place). @@ -647,7 +646,7 @@ void mlir::sinkLoop(AffineForOp forOp, unsigned loopDepth) { // ... // } // ``` -static void augmentMapAndBounds(FuncBuilder *b, Value *iv, AffineMap *map, +static void augmentMapAndBounds(OpBuilder *b, Value *iv, AffineMap *map, SmallVector *operands, int64_t offset = 0) { auto bounds = llvm::to_vector<4>(map->getResults()); @@ -665,7 +664,7 @@ static void cloneLoopBodyInto(AffineForOp forOp, Value *oldIv, AffineForOp newForOp) { BlockAndValueMapping map; map.map(oldIv, newForOp.getInductionVar()); - FuncBuilder b = newForOp.getBodyBuilder(); + OpBuilder b = newForOp.getBodyBuilder(); for (auto &op : *forOp.getBody()) { // Step over newForOp in case it is nested under forOp. if (&op == newForOp.getOperation()) { @@ -704,7 +703,7 @@ stripmineSink(AffineForOp forOp, uint64_t factor, forOp.setStep(scaledStep); auto *op = forOp.getOperation(); - FuncBuilder b(op->getBlock(), ++Block::iterator(op)); + OpBuilder b(op->getBlock(), ++Block::iterator(op)); // Lower-bound map creation. auto lbMap = forOp.getLowerBoundMap(); @@ -720,7 +719,7 @@ stripmineSink(AffineForOp forOp, uint64_t factor, SmallVector innerLoops; for (auto t : targets) { // Insert newForOp before the terminator of `t`. - FuncBuilder b = t.getBodyBuilder(); + OpBuilder b = t.getBodyBuilder(); auto newForOp = b.create(t.getLoc(), lbOperands, lbMap, ubOperands, ubMap, originalStep); cloneLoopBodyInto(t, forOp.getInductionVar(), newForOp); diff --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp index 13e5b2f2f08..2e2bc08b24d 100644 --- a/mlir/lib/Transforms/Utils/Utils.cpp +++ b/mlir/lib/Transforms/Utils/Utils.cpp @@ -123,7 +123,7 @@ bool mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, opInst->operand_begin() + memRefOperandPos); state.operands.push_back(newMemRef); - FuncBuilder builder(opInst); + OpBuilder builder(opInst); for (auto *extraIndex : extraIndices) { assert(extraIndex->getDefiningOp()->getNumResults() == 1 && "single result op's expected to generate these indices"); @@ -249,7 +249,7 @@ void mlir::createAffineComputationSlice( if (localized) return; - FuncBuilder builder(opInst); + OpBuilder builder(opInst); SmallVector composedOpOperands(subOperands); auto composedMap = builder.getMultiDimIdentityMap(composedOpOperands.size()); fullyComposeAffineMapAndOperands(&composedMap, &composedOpOperands); diff --git a/mlir/lib/Transforms/Vectorization/VectorizerTestPass.cpp b/mlir/lib/Transforms/Vectorization/VectorizerTestPass.cpp index aeaea02dad0..9220b7bb751 100644 --- a/mlir/lib/Transforms/Vectorization/VectorizerTestPass.cpp +++ b/mlir/lib/Transforms/Vectorization/VectorizerTestPass.cpp @@ -240,7 +240,7 @@ void VectorizerTestPass::testNormalizeMaps() { pattern.match(f, &matches); for (auto m : matches) { auto app = cast(m.getMatchedOperation()); - FuncBuilder b(m.getMatchedOperation()); + OpBuilder b(m.getMatchedOperation()); SmallVector operands(app.getOperands()); makeComposedAffineApply(&b, app.getLoc(), app.getAffineMap(), operands); } diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp index ddaf112dece..a96713be547 100644 --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -805,7 +805,7 @@ static LogicalResult vectorizeRootOrTerminal(Value *iv, return LogicalResult::Failure; LLVM_DEBUG(dbgs() << "\n[early-vect]+++++ permutationMap: "); LLVM_DEBUG(permutationMap.print(dbgs())); - FuncBuilder b(opInst); + OpBuilder b(opInst); auto transfer = b.create( opInst->getLoc(), vectorType, memoryOp.getMemRef(), map(makePtrDynCaster(), memoryOp.getIndices()), permutationMap); @@ -920,7 +920,7 @@ static Value *vectorizeConstant(Operation *op, ConstantOp constant, Type type) { !VectorType::isValidElementType(constant.getType())) { return nullptr; } - FuncBuilder b(op); + OpBuilder b(op); Location loc = op->getLoc(); auto vectorType = type.cast(); auto attr = SplatElementsAttr::get(vectorType, constant.getValue()); @@ -1015,7 +1015,7 @@ static Operation *vectorizeOneOperation(Operation *opInst, auto *value = store.getValueToStore(); auto *vectorValue = vectorizeOperand(value, opInst, state); auto indices = map(makePtrDynCaster(), store.getIndices()); - FuncBuilder b(opInst); + OpBuilder b(opInst); auto permutationMap = makePermutationMap(opInst, state->strategy->loopToVectorDim); if (!permutationMap) @@ -1054,7 +1054,7 @@ static Operation *vectorizeOneOperation(Operation *opInst, // name that works both in scalar mode and vector mode. // TODO(ntv): Is it worth considering an Operation.clone operation which // changes the type so we can promote an Operation with less boilerplate? - FuncBuilder b(opInst); + OpBuilder b(opInst); OperationState newOp(b.getContext(), opInst->getLoc(), opInst->getName().getStringRef(), vectorOperands, vectorTypes, opInst->getAttrs(), /*successors=*/{}, @@ -1136,7 +1136,7 @@ static LogicalResult vectorizeRootMatch(NestedMatch m, /// maintains a clone for handling failure and restores the proper state via /// RAII. auto *loopInst = loop.getOperation(); - FuncBuilder builder(loopInst); + OpBuilder builder(loopInst); auto clonedLoop = cast(builder.clone(*loopInst)); struct Guard { LogicalResult failure() { diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp index 55c457443e5..6018abe0043 100644 --- a/mlir/test/EDSC/builder-api-test.cpp +++ b/mlir/test/EDSC/builder-api-test.cpp @@ -62,7 +62,7 @@ TEST_FUNC(builder_dynamic_for_func_args) { auto f = makeFunction("builder_dynamic_for_func_args", {}, {indexType, indexType}); - FuncBuilder builder(*f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); ValueHandle i(indexType), j(indexType), lb(f->getArgument(0)), ub(f->getArgument(1)); @@ -113,7 +113,7 @@ TEST_FUNC(builder_dynamic_for) { auto f = makeFunction("builder_dynamic_for", {}, {indexType, indexType, indexType, indexType}); - FuncBuilder builder(*f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); ValueHandle i(indexType), a(f->getArgument(0)), b(f->getArgument(1)), c(f->getArgument(2)), d(f->getArgument(3)); @@ -136,7 +136,7 @@ TEST_FUNC(builder_max_min_for) { auto f = makeFunction("builder_max_min_for", {}, {indexType, indexType, indexType, indexType}); - FuncBuilder builder(*f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); ValueHandle i(indexType), lb1(f->getArgument(0)), lb2(f->getArgument(1)), ub1(f->getArgument(2)), ub2(f->getArgument(3)); @@ -157,7 +157,7 @@ TEST_FUNC(builder_blocks) { using namespace edsc::op; auto f = makeFunction("builder_blocks"); - FuncBuilder builder(*f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); ValueHandle c1(ValueHandle::create(42, 32)), c2(ValueHandle::create(1234, 32)); @@ -201,7 +201,7 @@ TEST_FUNC(builder_blocks_eager) { using namespace edsc::op; auto f = makeFunction("builder_blocks_eager"); - FuncBuilder builder(*f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); ValueHandle c1(ValueHandle::create(42, 32)), c2(ValueHandle::create(1234, 32)); @@ -244,7 +244,7 @@ TEST_FUNC(builder_cond_branch) { auto f = makeFunction("builder_cond_branch", {}, {IntegerType::get(1, &globalContext())}); - FuncBuilder builder(*f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); ValueHandle funcArg(f->getArgument(0)); ValueHandle c32(ValueHandle::create(32, 32)), @@ -281,7 +281,7 @@ TEST_FUNC(builder_cond_branch_eager) { auto f = makeFunction("builder_cond_branch_eager", {}, {IntegerType::get(1, &globalContext())}); - FuncBuilder builder(*f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); ValueHandle funcArg(f->getArgument(0)); ValueHandle c32(ValueHandle::create(32, 32)), @@ -321,7 +321,7 @@ TEST_FUNC(builder_helpers) { auto f = makeFunction("builder_helpers", {}, {memrefType, memrefType, memrefType}); - FuncBuilder builder(*f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); // clang-format off ValueHandle f7( @@ -373,7 +373,7 @@ TEST_FUNC(custom_ops) { auto indexType = IndexType::get(&globalContext()); auto f = makeFunction("custom_ops", {}, {indexType, indexType}); - FuncBuilder builder(*f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); CustomOperation MY_CUSTOM_OP("my_custom_op"); CustomOperation MY_CUSTOM_OP_0("my_custom_op_0"); @@ -412,7 +412,7 @@ TEST_FUNC(insertion_in_block) { auto indexType = IndexType::get(&globalContext()); auto f = makeFunction("insertion_in_block", {}, {indexType, indexType}); - FuncBuilder builder(*f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); BlockHandle b1; // clang-format off @@ -438,7 +438,7 @@ TEST_FUNC(select_op) { auto memrefType = MemRefType::get({-1, -1, -1}, f32Type, {}, 0); auto f = makeFunction("select_op", {}, {memrefType}); - FuncBuilder builder(*f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); // clang-format off ValueHandle zero = constant_index(0), one = constant_index(1); @@ -474,7 +474,7 @@ TEST_FUNC(tile_2d) { MemRefType::get({-1, -1, -1}, FloatType::getF32(&globalContext()), {}, 0); auto f = makeFunction("tile_2d", {}, {memrefType, memrefType, memrefType}); - FuncBuilder builder(*f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); ValueHandle zero = constant_index(0); MemRefView vA(f->getArgument(0)), vB(f->getArgument(1)), @@ -548,7 +548,7 @@ TEST_FUNC(vectorize_2d) { mlir::Module module(&globalContext()); module.getFunctions().push_back(f); - FuncBuilder builder(f); + OpBuilder builder(f->getBody()); ScopedContext scope(builder, f->getLoc()); ValueHandle zero = constant_index(0); MemRefView vA(f->getArgument(0)), vB(f->getArgument(1)), -- cgit v1.2.3 From 54cd6a7e97a226738e2c85b86559918dd9e3cd5d Mon Sep 17 00:00:00 2001 From: River Riddle Date: Mon, 1 Jul 2019 10:29:09 -0700 Subject: NFC: Refactor Function to be value typed. Move the data members out of Function and into a new impl storage class 'FunctionStorage'. This allows for Function to become value typed, which will greatly simplify the transition of Function to FuncOp(given that FuncOp is also value typed). PiperOrigin-RevId: 255983022 --- mlir/bindings/python/pybind.cpp | 35 +-- .../Linalg/Linalg1/include/linalg1/Common.h | 24 +-- mlir/examples/Linalg/Linalg2/Example.cpp | 20 +- mlir/examples/Linalg/Linalg3/Conversion.cpp | 22 +- mlir/examples/Linalg/Linalg3/Example.cpp | 32 +-- mlir/examples/Linalg/Linalg3/Execution.cpp | 22 +- .../Linalg/Linalg3/include/linalg3/Transforms.h | 6 +- .../Linalg/Linalg3/lib/ConvertToLLVMDialect.cpp | 2 +- mlir/examples/Linalg/Linalg3/lib/Transforms.cpp | 12 +- mlir/examples/Linalg/Linalg4/Example.cpp | 40 ++-- .../Linalg/Linalg4/include/linalg4/Transforms.h | 4 +- mlir/examples/Linalg/Linalg4/lib/Transforms.cpp | 9 +- mlir/examples/toy/Ch2/mlir/MLIRGen.cpp | 28 +-- mlir/examples/toy/Ch3/mlir/MLIRGen.cpp | 28 +-- mlir/examples/toy/Ch4/mlir/MLIRGen.cpp | 28 +-- mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp | 54 ++--- mlir/examples/toy/Ch5/mlir/LateLowering.cpp | 22 +- mlir/examples/toy/Ch5/mlir/MLIRGen.cpp | 28 +-- mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp | 54 ++--- mlir/include/mlir/Analysis/Dominance.h | 4 +- mlir/include/mlir/Analysis/NestedMatcher.h | 4 +- mlir/include/mlir/ExecutionEngine/MemRefUtils.h | 2 +- mlir/include/mlir/GPU/GPUDialect.h | 6 +- mlir/include/mlir/IR/Attributes.h | 3 +- mlir/include/mlir/IR/Block.h | 2 +- mlir/include/mlir/IR/Builders.h | 2 +- mlir/include/mlir/IR/Dialect.h | 10 +- mlir/include/mlir/IR/Function.h | 234 ++++++++++++++------- mlir/include/mlir/IR/Module.h | 66 ++++-- mlir/include/mlir/IR/Operation.h | 2 +- mlir/include/mlir/IR/PatternMatch.h | 2 +- mlir/include/mlir/IR/Region.h | 11 +- mlir/include/mlir/IR/SymbolTable.h | 12 +- mlir/include/mlir/IR/Value.h | 4 +- mlir/include/mlir/LLVMIR/LLVMDialect.h | 2 +- mlir/include/mlir/Pass/AnalysisManager.h | 18 +- mlir/include/mlir/Pass/Pass.h | 17 +- mlir/include/mlir/Pass/PassInstrumentation.h | 10 +- mlir/include/mlir/StandardOps/Ops.td | 4 +- mlir/include/mlir/Transforms/DialectConversion.h | 4 +- mlir/include/mlir/Transforms/LowerAffine.h | 2 +- mlir/include/mlir/Transforms/ViewFunctionGraph.h | 4 +- mlir/lib/AffineOps/AffineOps.cpp | 2 +- mlir/lib/Analysis/Dominance.cpp | 9 +- mlir/lib/Analysis/OpStats.cpp | 2 +- mlir/lib/Analysis/TestParallelismDetection.cpp | 2 +- mlir/lib/Analysis/Verifier.cpp | 14 +- .../GPUToCUDA/ConvertKernelFuncToCubin.cpp | 6 +- .../GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp | 106 +++++----- .../GPUToCUDA/GenerateCubinAccessors.cpp | 26 +-- .../StandardToLLVM/ConvertStandardToLLVM.cpp | 18 +- .../FxpMathOps/Transforms/LowerUniformRealMath.cpp | 4 +- .../Dialect/QuantOps/Transforms/ConvertConst.cpp | 2 +- .../QuantOps/Transforms/ConvertSimQuant.cpp | 2 +- mlir/lib/ExecutionEngine/MemRefUtils.cpp | 10 +- mlir/lib/GPU/IR/GPUDialect.cpp | 18 +- mlir/lib/GPU/Transforms/KernelOutlining.cpp | 28 +-- mlir/lib/IR/AsmPrinter.cpp | 50 ++--- mlir/lib/IR/Attributes.cpp | 5 - mlir/lib/IR/Block.cpp | 2 +- mlir/lib/IR/Builders.cpp | 4 +- mlir/lib/IR/Dialect.cpp | 15 ++ mlir/lib/IR/Function.cpp | 59 +++--- mlir/lib/IR/Operation.cpp | 9 +- mlir/lib/IR/Region.cpp | 10 +- mlir/lib/IR/SymbolTable.cpp | 22 +- mlir/lib/IR/Value.cpp | 8 +- mlir/lib/LLVMIR/IR/LLVMDialect.cpp | 4 +- mlir/lib/Linalg/Transforms/Fusion.cpp | 2 +- mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp | 69 +++--- mlir/lib/Linalg/Transforms/LowerToLoops.cpp | 3 +- mlir/lib/Linalg/Transforms/Tiling.cpp | 2 +- mlir/lib/Parser/Parser.cpp | 28 +-- mlir/lib/Pass/IRPrinting.cpp | 12 +- mlir/lib/Pass/Pass.cpp | 23 +- mlir/lib/Pass/PassDetail.h | 2 +- .../Transforms/AddDefaultStatsTestPass.cpp | 2 +- .../Transforms/InferQuantizedTypesPass.cpp | 2 +- .../Transforms/RemoveInstrumentationPass.cpp | 2 +- mlir/lib/SPIRV/Serialization/ConvertFromBinary.cpp | 6 +- mlir/lib/SPIRV/Serialization/ConvertToBinary.cpp | 2 +- .../SPIRV/Transforms/StdOpsToSPIRVConversion.cpp | 2 +- mlir/lib/StandardOps/Ops.cpp | 12 +- mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp | 31 +-- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 4 +- mlir/lib/Transforms/Canonicalizer.cpp | 2 +- mlir/lib/Transforms/DialectConversion.cpp | 54 ++--- mlir/lib/Transforms/DmaGeneration.cpp | 10 +- mlir/lib/Transforms/LoopFusion.cpp | 12 +- mlir/lib/Transforms/LoopTiling.cpp | 2 +- mlir/lib/Transforms/LoopUnroll.cpp | 8 +- mlir/lib/Transforms/LowerAffine.cpp | 2 +- mlir/lib/Transforms/MaterializeVectors.cpp | 12 +- mlir/lib/Transforms/MemRefDataFlowOpt.cpp | 2 +- mlir/lib/Transforms/StripDebugInfo.cpp | 2 +- .../Utils/GreedyPatternRewriteDriver.cpp | 4 +- mlir/lib/Transforms/Utils/LoopUtils.cpp | 2 +- mlir/lib/Transforms/Vectorize.cpp | 4 +- mlir/lib/Transforms/ViewFunctionGraph.cpp | 4 +- mlir/test/EDSC/builder-api-test.cpp | 150 +++++++------ .../test/lib/Transforms/TestVectorizationUtils.cpp | 16 +- mlir/tools/mlir-cpu-runner/mlir-cpu-runner-lib.cpp | 18 +- mlir/unittests/Pass/AnalysisManagerTest.cpp | 20 +- 103 files changed, 986 insertions(+), 874 deletions(-) (limited to 'mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp') diff --git a/mlir/bindings/python/pybind.cpp b/mlir/bindings/python/pybind.cpp index 222ef52b9be..cdf4a7fe89c 100644 --- a/mlir/bindings/python/pybind.cpp +++ b/mlir/bindings/python/pybind.cpp @@ -17,6 +17,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" +#include "llvm/IR/Function.h" #include "llvm/IR/Module.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" @@ -110,13 +111,14 @@ struct PythonValueHandle { struct PythonFunction { PythonFunction() : function{nullptr} {} PythonFunction(mlir_func_t f) : function{f} {} - PythonFunction(mlir::Function *f) : function{f} {} + PythonFunction(mlir::Function f) + : function(const_cast(f.getAsOpaquePointer())) {} operator mlir_func_t() { return function; } std::string str() { - mlir::Function *f = reinterpret_cast(function); + mlir::Function f = mlir::Function::getFromOpaquePointer(function); std::string res; llvm::raw_string_ostream os(res); - f->print(os); + f.print(os); return res; } @@ -124,18 +126,18 @@ struct PythonFunction { // declaration, add the entry block, transforming the declaration into a // definition. Return true if the block was added, false otherwise. bool define() { - auto *f = reinterpret_cast(function); - if (!f->getBlocks().empty()) + auto f = mlir::Function::getFromOpaquePointer(function); + if (!f.getBlocks().empty()) return false; - f->addEntryBlock(); + f.addEntryBlock(); return true; } PythonValueHandle arg(unsigned index) { - Function *f = static_cast(function); - assert(index < f->getNumArguments() && "argument index out of bounds"); - return PythonValueHandle(ValueHandle(f->getArgument(index))); + auto f = mlir::Function::getFromOpaquePointer(function); + assert(index < f.getNumArguments() && "argument index out of bounds"); + return PythonValueHandle(ValueHandle(f.getArgument(index))); } mlir_func_t function; @@ -250,10 +252,9 @@ struct PythonFunctionContext { PythonFunction enter() { assert(function.function && "function is not set up"); - auto *mlirFunc = static_cast(function.function); - contextBuilder.emplace(mlirFunc->getBody()); - context = - new mlir::edsc::ScopedContext(*contextBuilder, mlirFunc->getLoc()); + auto mlirFunc = mlir::Function::getFromOpaquePointer(function.function); + contextBuilder.emplace(mlirFunc.getBody()); + context = new mlir::edsc::ScopedContext(*contextBuilder, mlirFunc.getLoc()); return function; } @@ -594,7 +595,7 @@ PythonMLIRModule::declareFunction(const std::string &name, } // Create the function itself. - auto *func = new mlir::Function( + auto func = mlir::Function::create( UnknownLoc::get(&mlirContext), name, mlir::Type::getFromOpaquePointer(funcType).cast(), attrs, inputAttrs); @@ -652,9 +653,9 @@ PYBIND11_MODULE(pybind, m) { return ValueHandle::create(value, floatType); }); m.def("constant_function", [](PythonFunction func) -> PythonValueHandle { - auto *function = reinterpret_cast(func.function); - auto attr = FunctionAttr::get(function); - return ValueHandle::create(function->getType(), attr); + auto function = Function::getFromOpaquePointer(func.function); + auto attr = FunctionAttr::get(function.getName(), function.getContext()); + return ValueHandle::create(function.getType(), attr); }); m.def("appendTo", [](const PythonBlockHandle &handle) { return PythonBlockAppender(handle); diff --git a/mlir/examples/Linalg/Linalg1/include/linalg1/Common.h b/mlir/examples/Linalg/Linalg1/include/linalg1/Common.h index ddd6df9fb89..1f129c6b283 100644 --- a/mlir/examples/Linalg/Linalg1/include/linalg1/Common.h +++ b/mlir/examples/Linalg/Linalg1/include/linalg1/Common.h @@ -57,15 +57,15 @@ inline mlir::MemRefType floatMemRefType(mlir::MLIRContext *context, } /// A basic function builder -inline mlir::Function *makeFunction(mlir::Module &module, llvm::StringRef name, - llvm::ArrayRef types, - llvm::ArrayRef resultTypes) { +inline mlir::Function makeFunction(mlir::Module &module, llvm::StringRef name, + llvm::ArrayRef types, + llvm::ArrayRef resultTypes) { auto *context = module.getContext(); - auto *function = new mlir::Function( + auto function = mlir::Function::create( mlir::UnknownLoc::get(context), name, mlir::FunctionType::get({types}, resultTypes, context)); - function->addEntryBlock(); - module.getFunctions().push_back(function); + function.addEntryBlock(); + module.push_back(function); return function; } @@ -83,19 +83,19 @@ inline std::unique_ptr cleanupPassManager() { /// llvm::outs() for FileCheck'ing. /// If an error occurs, dump to llvm::errs() and do not print to llvm::outs() /// which will make the associated FileCheck test fail. -inline void cleanupAndPrintFunction(mlir::Function *f) { +inline void cleanupAndPrintFunction(mlir::Function f) { bool printToOuts = true; - auto check = [f, &printToOuts](mlir::LogicalResult result) { + auto check = [&f, &printToOuts](mlir::LogicalResult result) { if (failed(result)) { - f->emitError("Verification and cleanup passes failed"); + f.emitError("Verification and cleanup passes failed"); printToOuts = false; } }; auto pm = cleanupPassManager(); - check(f->getModule()->verify()); - check(pm->run(f->getModule())); + check(f.getModule()->verify()); + check(pm->run(f.getModule())); if (printToOuts) - f->print(llvm::outs()); + f.print(llvm::outs()); } /// Helper class to sugar building loop nests from indexings that appear in diff --git a/mlir/examples/Linalg/Linalg2/Example.cpp b/mlir/examples/Linalg/Linalg2/Example.cpp index a415daebdf5..9534711f1f4 100644 --- a/mlir/examples/Linalg/Linalg2/Example.cpp +++ b/mlir/examples/Linalg/Linalg2/Example.cpp @@ -36,14 +36,14 @@ TEST_FUNC(linalg_ops) { MLIRContext context; Module module(&context); auto indexType = mlir::IndexType::get(&context); - mlir::Function *f = + mlir::Function f = makeFunction(module, "linalg_ops", {indexType, indexType, indexType}, {}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); // clang-format off - ValueHandle M(f->getArgument(0)), N(f->getArgument(1)), K(f->getArgument(2)), + ValueHandle M(f.getArgument(0)), N(f.getArgument(1)), K(f.getArgument(2)), rM = range(constant_index(0), M, constant_index(1)), rN = range(constant_index(0), N, constant_index(1)), rK = range(constant_index(0), K, constant_index(1)), @@ -75,14 +75,14 @@ TEST_FUNC(linalg_ops_folded_slices) { MLIRContext context; Module module(&context); auto indexType = mlir::IndexType::get(&context); - mlir::Function *f = makeFunction(module, "linalg_ops_folded_slices", - {indexType, indexType, indexType}, {}); + mlir::Function f = makeFunction(module, "linalg_ops_folded_slices", + {indexType, indexType, indexType}, {}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); // clang-format off - ValueHandle M(f->getArgument(0)), N(f->getArgument(1)), K(f->getArgument(2)), + ValueHandle M(f.getArgument(0)), N(f.getArgument(1)), K(f.getArgument(2)), rM = range(constant_index(0), M, constant_index(1)), rN = range(constant_index(0), N, constant_index(1)), rK = range(constant_index(0), K, constant_index(1)), @@ -104,7 +104,7 @@ TEST_FUNC(linalg_ops_folded_slices) { // CHECK-NEXT: linalg.dot({{.*}}, {{.*}}, {{.*}}) : !linalg.view // clang-format on - f->walk([](SliceOp slice) { + f.walk([](SliceOp slice) { auto *sliceResult = slice.getResult(); auto viewOp = emitAndReturnFullyComposedView(sliceResult); sliceResult->replaceAllUsesWith(viewOp.getResult()); diff --git a/mlir/examples/Linalg/Linalg3/Conversion.cpp b/mlir/examples/Linalg/Linalg3/Conversion.cpp index 37d1b51f53e..23d1cfef5dc 100644 --- a/mlir/examples/Linalg/Linalg3/Conversion.cpp +++ b/mlir/examples/Linalg/Linalg3/Conversion.cpp @@ -37,26 +37,26 @@ using namespace linalg; using namespace linalg::common; using namespace linalg::intrinsics; -Function *makeFunctionWithAMatmulOp(Module &module, StringRef name) { +Function makeFunctionWithAMatmulOp(Module &module, StringRef name) { MLIRContext *context = module.getContext(); auto dynamic2DMemRefType = floatMemRefType<2>(context); - mlir::Function *f = linalg::common::makeFunction( + mlir::Function f = linalg::common::makeFunction( module, name, {dynamic2DMemRefType, dynamic2DMemRefType, dynamic2DMemRefType}, {}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); // clang-format off ValueHandle - M = dim(f->getArgument(0), 0), - N = dim(f->getArgument(2), 1), - K = dim(f->getArgument(0), 1), + M = dim(f.getArgument(0), 0), + N = dim(f.getArgument(2), 1), + K = dim(f.getArgument(0), 1), rM = range(constant_index(0), M, constant_index(1)), rN = range(constant_index(0), N, constant_index(1)), rK = range(constant_index(0), K, constant_index(1)), - vA = view(f->getArgument(0), {rM, rK}), - vB = view(f->getArgument(1), {rK, rN}), - vC = view(f->getArgument(2), {rM, rN}); + vA = view(f.getArgument(0), {rM, rK}), + vB = view(f.getArgument(1), {rK, rN}), + vC = view(f.getArgument(2), {rM, rN}); matmul(vA, vB, vC); ret(); // clang-format on @@ -67,7 +67,7 @@ Function *makeFunctionWithAMatmulOp(Module &module, StringRef name) { TEST_FUNC(foo) { MLIRContext context; Module module(&context); - mlir::Function *f = makeFunctionWithAMatmulOp(module, "matmul_as_loops"); + mlir::Function f = makeFunctionWithAMatmulOp(module, "matmul_as_loops"); lowerToLoops(f); convertLinalg3ToLLVM(module); diff --git a/mlir/examples/Linalg/Linalg3/Example.cpp b/mlir/examples/Linalg/Linalg3/Example.cpp index f02aef920e4..8b04344b19e 100644 --- a/mlir/examples/Linalg/Linalg3/Example.cpp +++ b/mlir/examples/Linalg/Linalg3/Example.cpp @@ -34,26 +34,26 @@ using namespace linalg; using namespace linalg::common; using namespace linalg::intrinsics; -Function *makeFunctionWithAMatmulOp(Module &module, StringRef name) { +Function makeFunctionWithAMatmulOp(Module &module, StringRef name) { MLIRContext *context = module.getContext(); auto dynamic2DMemRefType = floatMemRefType<2>(context); - mlir::Function *f = linalg::common::makeFunction( + mlir::Function f = linalg::common::makeFunction( module, name, {dynamic2DMemRefType, dynamic2DMemRefType, dynamic2DMemRefType}, {}); - mlir::OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + mlir::OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); // clang-format off ValueHandle - M = dim(f->getArgument(0), 0), - N = dim(f->getArgument(2), 1), - K = dim(f->getArgument(0), 1), + M = dim(f.getArgument(0), 0), + N = dim(f.getArgument(2), 1), + K = dim(f.getArgument(0), 1), rM = range(constant_index(0), M, constant_index(1)), rN = range(constant_index(0), N, constant_index(1)), rK = range(constant_index(0), K, constant_index(1)), - vA = view(f->getArgument(0), {rM, rK}), - vB = view(f->getArgument(1), {rK, rN}), - vC = view(f->getArgument(2), {rM, rN}); + vA = view(f.getArgument(0), {rM, rK}), + vB = view(f.getArgument(1), {rK, rN}), + vC = view(f.getArgument(2), {rM, rN}); matmul(vA, vB, vC); ret(); // clang-format on @@ -64,7 +64,7 @@ Function *makeFunctionWithAMatmulOp(Module &module, StringRef name) { TEST_FUNC(matmul_as_matvec) { MLIRContext context; Module module(&context); - mlir::Function *f = makeFunctionWithAMatmulOp(module, "matmul_as_matvec"); + mlir::Function f = makeFunctionWithAMatmulOp(module, "matmul_as_matvec"); lowerToFinerGrainedTensorContraction(f); composeSliceOps(f); // clang-format off @@ -82,7 +82,7 @@ TEST_FUNC(matmul_as_matvec) { TEST_FUNC(matmul_as_dot) { MLIRContext context; Module module(&context); - mlir::Function *f = makeFunctionWithAMatmulOp(module, "matmul_as_dot"); + mlir::Function f = makeFunctionWithAMatmulOp(module, "matmul_as_dot"); lowerToFinerGrainedTensorContraction(f); lowerToFinerGrainedTensorContraction(f); composeSliceOps(f); @@ -103,7 +103,7 @@ TEST_FUNC(matmul_as_dot) { TEST_FUNC(matmul_as_loops) { MLIRContext context; Module module(&context); - mlir::Function *f = makeFunctionWithAMatmulOp(module, "matmul_as_loops"); + mlir::Function f = makeFunctionWithAMatmulOp(module, "matmul_as_loops"); lowerToLoops(f); composeSliceOps(f); // clang-format off @@ -135,7 +135,7 @@ TEST_FUNC(matmul_as_loops) { TEST_FUNC(matmul_as_matvec_as_loops) { MLIRContext context; Module module(&context); - mlir::Function *f = + mlir::Function f = makeFunctionWithAMatmulOp(module, "matmul_as_matvec_as_loops"); lowerToFinerGrainedTensorContraction(f); lowerToLoops(f); @@ -166,14 +166,14 @@ TEST_FUNC(matmul_as_matvec_as_loops) { TEST_FUNC(matmul_as_matvec_as_affine) { MLIRContext context; Module module(&context); - mlir::Function *f = + mlir::Function f = makeFunctionWithAMatmulOp(module, "matmul_as_matvec_as_affine"); lowerToFinerGrainedTensorContraction(f); composeSliceOps(f); lowerToLoops(f); PassManager pm; pm.addPass(createLowerLinalgLoadStorePass()); - if (succeeded(pm.run(f->getModule()))) + if (succeeded(pm.run(f.getModule()))) cleanupAndPrintFunction(f); // clang-format off diff --git a/mlir/examples/Linalg/Linalg3/Execution.cpp b/mlir/examples/Linalg/Linalg3/Execution.cpp index 00d571cbc99..94b233a56b0 100644 --- a/mlir/examples/Linalg/Linalg3/Execution.cpp +++ b/mlir/examples/Linalg/Linalg3/Execution.cpp @@ -37,26 +37,26 @@ using namespace linalg; using namespace linalg::common; using namespace linalg::intrinsics; -Function *makeFunctionWithAMatmulOp(Module &module, StringRef name) { +Function makeFunctionWithAMatmulOp(Module &module, StringRef name) { MLIRContext *context = module.getContext(); auto dynamic2DMemRefType = floatMemRefType<2>(context); - mlir::Function *f = linalg::common::makeFunction( + mlir::Function f = linalg::common::makeFunction( module, name, {dynamic2DMemRefType, dynamic2DMemRefType, dynamic2DMemRefType}, {}); - mlir::OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + mlir::OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); // clang-format off ValueHandle - M = dim(f->getArgument(0), 0), - N = dim(f->getArgument(2), 1), - K = dim(f->getArgument(0), 1), + M = dim(f.getArgument(0), 0), + N = dim(f.getArgument(2), 1), + K = dim(f.getArgument(0), 1), rM = range(constant_index(0), M, constant_index(1)), rN = range(constant_index(0), N, constant_index(1)), rK = range(constant_index(0), K, constant_index(1)), - vA = view(f->getArgument(0), {rM, rK}), - vB = view(f->getArgument(1), {rK, rN}), - vC = view(f->getArgument(2), {rM, rN}); + vA = view(f.getArgument(0), {rM, rK}), + vB = view(f.getArgument(1), {rK, rN}), + vC = view(f.getArgument(2), {rM, rN}); matmul(vA, vB, vC); ret(); // clang-format on @@ -110,7 +110,7 @@ TEST_FUNC(execution) { // dialect through partial conversions. MLIRContext context; Module module(&context); - mlir::Function *f = makeFunctionWithAMatmulOp(module, "matmul_as_loops"); + mlir::Function f = makeFunctionWithAMatmulOp(module, "matmul_as_loops"); lowerToLoops(f); convertLinalg3ToLLVM(module); diff --git a/mlir/examples/Linalg/Linalg3/include/linalg3/Transforms.h b/mlir/examples/Linalg/Linalg3/include/linalg3/Transforms.h index 9af528e8c51..6c0aec0b000 100644 --- a/mlir/examples/Linalg/Linalg3/include/linalg3/Transforms.h +++ b/mlir/examples/Linalg/Linalg3/include/linalg3/Transforms.h @@ -55,11 +55,11 @@ makeGenericLoopRanges(mlir::AffineMap operandRangesToLoopMaps, /// Traverses `f` and rewrites linalg.slice, and the operations it depends on, /// to only use linalg.view operations. -void composeSliceOps(mlir::Function *f); +void composeSliceOps(mlir::Function f); /// Traverses `f` and rewrites linalg.matmul(resp. linalg.matvec) /// as linalg.matvec(resp. linalg.dot). -void lowerToFinerGrainedTensorContraction(mlir::Function *f); +void lowerToFinerGrainedTensorContraction(mlir::Function f); /// Operation-wise writing of linalg operations to loop form. /// It is the caller's responsibility to erase the `op` if necessary. @@ -69,7 +69,7 @@ llvm::Optional> writeAsLoops(mlir::Operation *op); /// Traverses `f` and rewrites linalg operations in loop form. -void lowerToLoops(mlir::Function *f); +void lowerToLoops(mlir::Function f); /// Creates a pass that rewrites linalg.load and linalg.store to affine.load and /// affine.store operations. diff --git a/mlir/examples/Linalg/Linalg3/lib/ConvertToLLVMDialect.cpp b/mlir/examples/Linalg/Linalg3/lib/ConvertToLLVMDialect.cpp index 7b559bf2f21..96b0f371ef1 100644 --- a/mlir/examples/Linalg/Linalg3/lib/ConvertToLLVMDialect.cpp +++ b/mlir/examples/Linalg/Linalg3/lib/ConvertToLLVMDialect.cpp @@ -148,7 +148,7 @@ static void populateLinalg3ToLLVMConversionPatterns( void linalg::convertLinalg3ToLLVM(Module &module) { // Remove affine constructs. - for (auto &func : module) { + for (auto func : module) { auto rr = lowerAffineConstructs(func); (void)rr; assert(succeeded(rr) && "affine loop lowering failed"); diff --git a/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp b/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp index d5c8641acbe..7b9e5ffee96 100644 --- a/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp +++ b/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp @@ -35,8 +35,8 @@ using namespace mlir::edsc::intrinsics; using namespace linalg; using namespace linalg::intrinsics; -void linalg::composeSliceOps(mlir::Function *f) { - f->walk([](SliceOp sliceOp) { +void linalg::composeSliceOps(mlir::Function f) { + f.walk([](SliceOp sliceOp) { auto *sliceResult = sliceOp.getResult(); auto viewOp = emitAndReturnFullyComposedView(sliceResult); sliceResult->replaceAllUsesWith(viewOp.getResult()); @@ -44,8 +44,8 @@ void linalg::composeSliceOps(mlir::Function *f) { }); } -void linalg::lowerToFinerGrainedTensorContraction(mlir::Function *f) { - f->walk([](Operation *op) { +void linalg::lowerToFinerGrainedTensorContraction(mlir::Function f) { + f.walk([](Operation *op) { if (auto matmulOp = dyn_cast(op)) { matmulOp.writeAsFinerGrainTensorContraction(); } else if (auto matvecOp = dyn_cast(op)) { @@ -211,8 +211,8 @@ linalg::writeAsLoops(Operation *op) { return llvm::None; } -void linalg::lowerToLoops(mlir::Function *f) { - f->walk([](Operation *op) { +void linalg::lowerToLoops(mlir::Function f) { + f.walk([](Operation *op) { if (writeAsLoops(op)) op->erase(); }); diff --git a/mlir/examples/Linalg/Linalg4/Example.cpp b/mlir/examples/Linalg/Linalg4/Example.cpp index cdc05a1cc21..873e57e78f3 100644 --- a/mlir/examples/Linalg/Linalg4/Example.cpp +++ b/mlir/examples/Linalg/Linalg4/Example.cpp @@ -34,27 +34,27 @@ using namespace linalg; using namespace linalg::common; using namespace linalg::intrinsics; -Function *makeFunctionWithAMatmulOp(Module &module, StringRef name) { +Function makeFunctionWithAMatmulOp(Module &module, StringRef name) { MLIRContext *context = module.getContext(); auto dynamic2DMemRefType = floatMemRefType<2>(context); - mlir::Function *f = linalg::common::makeFunction( + mlir::Function f = linalg::common::makeFunction( module, name, {dynamic2DMemRefType, dynamic2DMemRefType, dynamic2DMemRefType}, {}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); // clang-format off ValueHandle - M = dim(f->getArgument(0), 0), - N = dim(f->getArgument(2), 1), - K = dim(f->getArgument(0), 1), + M = dim(f.getArgument(0), 0), + N = dim(f.getArgument(2), 1), + K = dim(f.getArgument(0), 1), rM = range(constant_index(0), M, constant_index(1)), rN = range(constant_index(0), N, constant_index(1)), rK = range(constant_index(0), K, constant_index(1)), - vA = view(f->getArgument(0), {rM, rK}), - vB = view(f->getArgument(1), {rK, rN}), - vC = view(f->getArgument(2), {rM, rN}); + vA = view(f.getArgument(0), {rM, rK}), + vB = view(f.getArgument(1), {rK, rN}), + vC = view(f.getArgument(2), {rM, rN}); matmul(vA, vB, vC); ret(); // clang-format on @@ -65,11 +65,11 @@ Function *makeFunctionWithAMatmulOp(Module &module, StringRef name) { TEST_FUNC(matmul_tiled_loops) { MLIRContext context; Module module(&context); - mlir::Function *f = makeFunctionWithAMatmulOp(module, "matmul_tiled_loops"); + mlir::Function f = makeFunctionWithAMatmulOp(module, "matmul_tiled_loops"); lowerToTiledLoops(f, {8, 9}); PassManager pm; pm.addPass(createLowerLinalgLoadStorePass()); - if (succeeded(pm.run(f->getModule()))) + if (succeeded(pm.run(f.getModule()))) cleanupAndPrintFunction(f); // clang-format off @@ -96,10 +96,10 @@ TEST_FUNC(matmul_tiled_loops) { TEST_FUNC(matmul_tiled_views) { MLIRContext context; Module module(&context); - mlir::Function *f = makeFunctionWithAMatmulOp(module, "matmul_tiled_views"); - OpBuilder b(f->getBody()); - lowerToTiledViews(f, {b.create(f->getLoc(), 8), - b.create(f->getLoc(), 9)}); + mlir::Function f = makeFunctionWithAMatmulOp(module, "matmul_tiled_views"); + OpBuilder b(f.getBody()); + lowerToTiledViews(f, {b.create(f.getLoc(), 8), + b.create(f.getLoc(), 9)}); composeSliceOps(f); // clang-format off @@ -125,11 +125,11 @@ TEST_FUNC(matmul_tiled_views) { TEST_FUNC(matmul_tiled_views_as_loops) { MLIRContext context; Module module(&context); - mlir::Function *f = + mlir::Function f = makeFunctionWithAMatmulOp(module, "matmul_tiled_views_as_loops"); - OpBuilder b(f->getBody()); - lowerToTiledViews(f, {b.create(f->getLoc(), 8), - b.create(f->getLoc(), 9)}); + OpBuilder b(f.getBody()); + lowerToTiledViews(f, {b.create(f.getLoc(), 8), + b.create(f.getLoc(), 9)}); composeSliceOps(f); lowerToLoops(f); // This cannot lower below linalg.load and linalg.store due to lost diff --git a/mlir/examples/Linalg/Linalg4/include/linalg4/Transforms.h b/mlir/examples/Linalg/Linalg4/include/linalg4/Transforms.h index 2165cab6ac1..ba7273e409d 100644 --- a/mlir/examples/Linalg/Linalg4/include/linalg4/Transforms.h +++ b/mlir/examples/Linalg/Linalg4/include/linalg4/Transforms.h @@ -34,12 +34,12 @@ writeAsTiledViews(mlir::Operation *op, llvm::ArrayRef tileSizes); /// Apply `writeAsTiledLoops` on all linalg ops. This is a convenience function /// and is not exposed as a pass because a fixed set of tile sizes for all ops /// in a function can generally not be specified. -void lowerToTiledLoops(mlir::Function *f, llvm::ArrayRef tileSizes); +void lowerToTiledLoops(mlir::Function f, llvm::ArrayRef tileSizes); /// Apply `writeAsTiledViews` on all linalg ops. This is a convenience function /// and is not exposed as a pass because a fixed set of tile sizes for all ops /// in a function can generally not be specified. -void lowerToTiledViews(mlir::Function *f, +void lowerToTiledViews(mlir::Function f, llvm::ArrayRef tileSizes); } // namespace linalg diff --git a/mlir/examples/Linalg/Linalg4/lib/Transforms.cpp b/mlir/examples/Linalg/Linalg4/lib/Transforms.cpp index 1a308df1313..16b395da506 100644 --- a/mlir/examples/Linalg/Linalg4/lib/Transforms.cpp +++ b/mlir/examples/Linalg/Linalg4/lib/Transforms.cpp @@ -43,9 +43,8 @@ linalg::writeAsTiledLoops(Operation *op, ArrayRef tileSizes) { return llvm::None; } -void linalg::lowerToTiledLoops(mlir::Function *f, - ArrayRef tileSizes) { - f->walk([tileSizes](Operation *op) { +void linalg::lowerToTiledLoops(mlir::Function f, ArrayRef tileSizes) { + f.walk([tileSizes](Operation *op) { if (writeAsTiledLoops(op, tileSizes).hasValue()) op->erase(); }); @@ -185,8 +184,8 @@ linalg::writeAsTiledViews(Operation *op, ArrayRef tileSizes) { return llvm::None; } -void linalg::lowerToTiledViews(mlir::Function *f, ArrayRef tileSizes) { - f->walk([tileSizes](Operation *op) { +void linalg::lowerToTiledViews(mlir::Function f, ArrayRef tileSizes) { + f.walk([tileSizes](Operation *op) { if (auto matmulOp = dyn_cast(op)) { writeAsTiledViews(matmulOp, tileSizes); } else if (auto matvecOp = dyn_cast(op)) { diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp index 842c7a1d0f8..73789fa41a4 100644 --- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp @@ -75,7 +75,7 @@ public: auto func = mlirGen(F); if (!func) return nullptr; - theModule->getFunctions().push_back(func.release()); + theModule->push_back(func); } // FIXME: (in the next chapter...) without registering a dialect in MLIR, @@ -129,40 +129,40 @@ private: /// Create the prototype for an MLIR function with as many arguments as the /// provided Toy AST prototype. - mlir::Function *mlirGen(PrototypeAST &proto) { + mlir::Function mlirGen(PrototypeAST &proto) { // This is a generic function, the return type will be inferred later. llvm::SmallVector ret_types; // Arguments type is uniformly a generic array. llvm::SmallVector arg_types(proto.getArgs().size(), getType(VarType{})); auto func_type = mlir::FunctionType::get(arg_types, ret_types, &context); - auto *function = new mlir::Function(loc(proto.loc()), proto.getName(), - func_type, /* attrs = */ {}); + auto function = mlir::Function::create(loc(proto.loc()), proto.getName(), + func_type, /* attrs = */ {}); // Mark the function as generic: it'll require type specialization for every // call site. - if (function->getNumArguments()) - function->setAttr("toy.generic", mlir::BoolAttr::get(true, &context)); + if (function.getNumArguments()) + function.setAttr("toy.generic", mlir::BoolAttr::get(true, &context)); return function; } /// Emit a new function and add it to the MLIR module. - std::unique_ptr mlirGen(FunctionAST &funcAST) { + mlir::Function mlirGen(FunctionAST &funcAST) { // Create a scope in the symbol table to hold variable declarations. ScopedHashTableScope var_scope(symbolTable); // Create an MLIR function for the given prototype. - std::unique_ptr function(mlirGen(*funcAST.getProto())); + mlir::Function function(mlirGen(*funcAST.getProto())); if (!function) return nullptr; // Let's start the body of the function now! // In MLIR the entry block of the function is special: it must have the same // argument list as the function itself. - function->addEntryBlock(); + function.addEntryBlock(); - auto &entryBlock = function->front(); + auto &entryBlock = function.front(); auto &protoArgs = funcAST.getProto()->getArgs(); // Declare all the function arguments in the symbol table. for (const auto &name_value : @@ -172,16 +172,18 @@ private: // Create a builder for the function, it will be used throughout the codegen // to create operations in this function. - builder = llvm::make_unique(function->getBody()); + builder = llvm::make_unique(function.getBody()); // Emit the body of the function. - if (!mlirGen(*funcAST.getBody())) + if (!mlirGen(*funcAST.getBody())) { + function.erase(); return nullptr; + } // Implicitly return void if no return statement was emitted. // FIXME: we may fix the parser instead to always return the last expression // (this would possibly help the REPL case later) - if (function->getBlocks().back().back().getName().getStringRef() != + if (function.getBlocks().back().back().getName().getStringRef() != "toy.return") { ReturnExprAST fakeRet(funcAST.getProto()->loc(), llvm::None); mlirGen(fakeRet); diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp index e365f37f8c8..23cb85309c2 100644 --- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp @@ -76,7 +76,7 @@ public: auto func = mlirGen(F); if (!func) return nullptr; - theModule->getFunctions().push_back(func.release()); + theModule->push_back(func); } // FIXME: (in the next chapter...) without registering a dialect in MLIR, @@ -130,40 +130,40 @@ private: /// Create the prototype for an MLIR function with as many arguments as the /// provided Toy AST prototype. - mlir::Function *mlirGen(PrototypeAST &proto) { + mlir::Function mlirGen(PrototypeAST &proto) { // This is a generic function, the return type will be inferred later. llvm::SmallVector ret_types; // Arguments type is uniformly a generic array. llvm::SmallVector arg_types(proto.getArgs().size(), getType(VarType{})); auto func_type = mlir::FunctionType::get(arg_types, ret_types, &context); - auto *function = new mlir::Function(loc(proto.loc()), proto.getName(), - func_type, /* attrs = */ {}); + auto function = mlir::Function::create(loc(proto.loc()), proto.getName(), + func_type, /* attrs = */ {}); // Mark the function as generic: it'll require type specialization for every // call site. - if (function->getNumArguments()) - function->setAttr("toy.generic", mlir::BoolAttr::get(true, &context)); + if (function.getNumArguments()) + function.setAttr("toy.generic", mlir::BoolAttr::get(true, &context)); return function; } /// Emit a new function and add it to the MLIR module. - std::unique_ptr mlirGen(FunctionAST &funcAST) { + mlir::Function mlirGen(FunctionAST &funcAST) { // Create a scope in the symbol table to hold variable declarations. ScopedHashTableScope var_scope(symbolTable); // Create an MLIR function for the given prototype. - std::unique_ptr function(mlirGen(*funcAST.getProto())); + mlir::Function function(mlirGen(*funcAST.getProto())); if (!function) return nullptr; // Let's start the body of the function now! // In MLIR the entry block of the function is special: it must have the same // argument list as the function itself. - function->addEntryBlock(); + function.addEntryBlock(); - auto &entryBlock = function->front(); + auto &entryBlock = function.front(); auto &protoArgs = funcAST.getProto()->getArgs(); // Declare all the function arguments in the symbol table. for (const auto &name_value : @@ -173,16 +173,18 @@ private: // Create a builder for the function, it will be used throughout the codegen // to create operations in this function. - builder = llvm::make_unique(function->getBody()); + builder = llvm::make_unique(function.getBody()); // Emit the body of the function. - if (!mlirGen(*funcAST.getBody())) + if (!mlirGen(*funcAST.getBody())) { + function.erase(); return nullptr; + } // Implicitly return void if no return statement was emitted. // FIXME: we may fix the parser instead to always return the last expression // (this would possibly help the REPL case later) - if (function->getBlocks().back().back().getName().getStringRef() != + if (function.getBlocks().back().back().getName().getStringRef() != "toy.return") { ReturnExprAST fakeRet(funcAST.getProto()->loc(), llvm::None); mlirGen(fakeRet); diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp index 032766a547f..f2132c29c33 100644 --- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp @@ -76,7 +76,7 @@ public: auto func = mlirGen(F); if (!func) return nullptr; - theModule->getFunctions().push_back(func.release()); + theModule->push_back(func); } // FIXME: (in the next chapter...) without registering a dialect in MLIR, @@ -130,40 +130,40 @@ private: /// Create the prototype for an MLIR function with as many arguments as the /// provided Toy AST prototype. - mlir::Function *mlirGen(PrototypeAST &proto) { + mlir::Function mlirGen(PrototypeAST &proto) { // This is a generic function, the return type will be inferred later. llvm::SmallVector ret_types; // Arguments type is uniformly a generic array. llvm::SmallVector arg_types(proto.getArgs().size(), getType(VarType{})); auto func_type = mlir::FunctionType::get(arg_types, ret_types, &context); - auto *function = new mlir::Function(loc(proto.loc()), proto.getName(), - func_type, /* attrs = */ {}); + auto function = mlir::Function::create(loc(proto.loc()), proto.getName(), + func_type, /* attrs = */ {}); // Mark the function as generic: it'll require type specialization for every // call site. - if (function->getNumArguments()) - function->setAttr("toy.generic", mlir::BoolAttr::get(true, &context)); + if (function.getNumArguments()) + function.setAttr("toy.generic", mlir::BoolAttr::get(true, &context)); return function; } /// Emit a new function and add it to the MLIR module. - std::unique_ptr mlirGen(FunctionAST &funcAST) { + mlir::Function mlirGen(FunctionAST &funcAST) { // Create a scope in the symbol table to hold variable declarations. ScopedHashTableScope var_scope(symbolTable); // Create an MLIR function for the given prototype. - std::unique_ptr function(mlirGen(*funcAST.getProto())); + mlir::Function function(mlirGen(*funcAST.getProto())); if (!function) return nullptr; // Let's start the body of the function now! // In MLIR the entry block of the function is special: it must have the same // argument list as the function itself. - function->addEntryBlock(); + function.addEntryBlock(); - auto &entryBlock = function->front(); + auto &entryBlock = function.front(); auto &protoArgs = funcAST.getProto()->getArgs(); // Declare all the function arguments in the symbol table. for (const auto &name_value : @@ -173,16 +173,18 @@ private: // Create a builder for the function, it will be used throughout the codegen // to create operations in this function. - builder = llvm::make_unique(function->getBody()); + builder = llvm::make_unique(function.getBody()); // Emit the body of the function. - if (!mlirGen(*funcAST.getBody())) + if (!mlirGen(*funcAST.getBody())) { + function.erase(); return nullptr; + } // Implicitly return void if no return statement was emited. // FIXME: we may fix the parser instead to always return the last expression // (this would possibly help the REPL case later) - if (function->getBlocks().back().back().getName().getStringRef() != + if (function.getBlocks().back().back().getName().getStringRef() != "toy.return") { ReturnExprAST fakeRet(funcAST.getProto()->loc(), llvm::None); mlirGen(fakeRet); diff --git a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp index 688c73645a5..f237fd9fb53 100644 --- a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp @@ -113,14 +113,14 @@ public: // function to process, the mangled name for this specialization, and the // types of the arguments on which to specialize. struct FunctionToSpecialize { - mlir::Function *function; + mlir::Function function; std::string mangledName; SmallVector argumentsType; }; void runOnModule() override { auto &module = getModule(); - auto *main = module.getNamedFunction("main"); + auto main = module.getNamedFunction("main"); if (!main) { emitError(mlir::UnknownLoc::get(module.getContext()), "Shape inference failed: can't find a main function\n"); @@ -139,7 +139,7 @@ public: // Delete any generic function left // FIXME: we may want this as a separate pass. - for (mlir::Function &function : llvm::make_early_inc_range(module)) { + for (mlir::Function function : llvm::make_early_inc_range(module)) { if (auto genericAttr = function.getAttrOfType("toy.generic")) { if (genericAttr.getValue()) @@ -153,7 +153,7 @@ public: mlir::LogicalResult specialize(SmallVectorImpl &funcWorklist) { FunctionToSpecialize &functionToSpecialize = funcWorklist.back(); - mlir::Function *f = functionToSpecialize.function; + mlir::Function f = functionToSpecialize.function; // Check if cloning for specialization is needed (usually anything but main) // We will create a new function with the concrete types for the parameters @@ -169,36 +169,36 @@ public: auto type = mlir::FunctionType::get(functionToSpecialize.argumentsType, {ToyArrayType::get(&getContext())}, &getContext()); - auto *newFunction = new mlir::Function( - f->getLoc(), functionToSpecialize.mangledName, type, f->getAttrs()); - getModule().getFunctions().push_back(newFunction); + auto newFunction = mlir::Function::create( + f.getLoc(), functionToSpecialize.mangledName, type, f.getAttrs()); + getModule().push_back(newFunction); // Clone the function body mlir::BlockAndValueMapping mapper; - f->cloneInto(newFunction, mapper); + f.cloneInto(newFunction, mapper); LLVM_DEBUG({ llvm::dbgs() << "====== Cloned : \n"; - f->dump(); + f.dump(); llvm::dbgs() << "====== Into : \n"; - newFunction->dump(); + newFunction.dump(); }); f = newFunction; - f->setAttr("toy.generic", mlir::BoolAttr::get(false, &getContext())); + f.setAttr("toy.generic", mlir::BoolAttr::get(false, &getContext())); // Remap the entry-block arguments // FIXME: this seems like a bug in `cloneInto()` above? - auto &entryBlock = f->getBlocks().front(); + auto &entryBlock = f.getBlocks().front(); int blockArgSize = entryBlock.getArguments().size(); - assert(blockArgSize == static_cast(f->getType().getInputs().size())); - entryBlock.addArguments(f->getType().getInputs()); + assert(blockArgSize == static_cast(f.getType().getInputs().size())); + entryBlock.addArguments(f.getType().getInputs()); auto argList = entryBlock.getArguments(); for (int argNum = 0; argNum < blockArgSize; ++argNum) { argList[0]->replaceAllUsesWith(argList[blockArgSize]); entryBlock.eraseArgument(0); } - assert(succeeded(f->verify())); + assert(succeeded(f.verify())); } LLVM_DEBUG(llvm::dbgs() - << "Run shape inference on : '" << f->getName() << "'\n"); + << "Run shape inference on : '" << f.getName() << "'\n"); auto *toyDialect = getContext().getRegisteredDialect("toy"); if (!toyDialect) { @@ -211,7 +211,7 @@ public: // Populate the worklist with the operations that need shape inference: // these are the Toy operations that return a generic array. llvm::SmallPtrSet opWorklist; - f->walk([&](mlir::Operation *op) { + f.walk([&](mlir::Operation *op) { if (op->getDialect() == toyDialect) { if (op->getNumResults() == 1 && op->getResult(0)->getType().cast().isGeneric()) @@ -292,9 +292,9 @@ public: // restart after the callee is processed. if (auto callOp = llvm::dyn_cast(op)) { auto calleeName = callOp.getCalleeName(); - auto *callee = getModule().getNamedFunction(calleeName); + auto callee = getModule().getNamedFunction(calleeName); if (!callee) { - f->emitError("Shape inference failed, call to unknown '") + f.emitError("Shape inference failed, call to unknown '") << calleeName << "'"; signalPassFailure(); return mlir::failure(); @@ -302,7 +302,7 @@ public: auto mangledName = mangle(calleeName, op->getOpOperands()); LLVM_DEBUG(llvm::dbgs() << "Found callee to infer: '" << calleeName << "', mangled: '" << mangledName << "'\n"); - auto *mangledCallee = getModule().getNamedFunction(mangledName); + auto mangledCallee = getModule().getNamedFunction(mangledName); if (!mangledCallee) { // Can't find the target, this is where we queue the request for the // callee and stop the inference for the current function now. @@ -327,7 +327,7 @@ public: // Done with inference on this function, removing it from the worklist. funcWorklist.pop_back(); // Mark the function as non-generic now that inference has succeeded - f->setAttr("toy.generic", mlir::BoolAttr::get(false, &getContext())); + f.setAttr("toy.generic", mlir::BoolAttr::get(false, &getContext())); // If the operation worklist isn't empty, this indicates a failure. if (!opWorklist.empty()) { @@ -337,31 +337,31 @@ public: << " operations couldn't be inferred\n"; for (auto *ope : opWorklist) errorMsg << " - " << *ope << "\n"; - f->emitError(errorMsg.str()); + f.emitError(errorMsg.str()); signalPassFailure(); return mlir::failure(); } // Finally, update the return type of the function based on the argument to // the return operation. - for (auto &block : f->getBlocks()) { + for (auto &block : f.getBlocks()) { auto ret = llvm::cast(block.getTerminator()); if (!ret) continue; if (ret.getNumOperands() && - f->getType().getResult(0) == ret.getOperand()->getType()) + f.getType().getResult(0) == ret.getOperand()->getType()) // type match, we're done break; SmallVector retTy; if (ret.getNumOperands()) retTy.push_back(ret.getOperand()->getType()); std::vector argumentsType; - for (auto arg : f->getArguments()) + for (auto arg : f.getArguments()) argumentsType.push_back(arg->getType()); auto newType = mlir::FunctionType::get(argumentsType, retTy, &getContext()); - f->setType(newType); - assert(succeeded(f->verify())); + f.setType(newType); + assert(succeeded(f.verify())); break; } return mlir::success(); diff --git a/mlir/examples/toy/Ch5/mlir/LateLowering.cpp b/mlir/examples/toy/Ch5/mlir/LateLowering.cpp index 8b2a3927d78..60a8b5a3b9a 100644 --- a/mlir/examples/toy/Ch5/mlir/LateLowering.cpp +++ b/mlir/examples/toy/Ch5/mlir/LateLowering.cpp @@ -136,14 +136,14 @@ public: PatternMatchResult matchAndRewrite(Operation *op, ArrayRef operands, PatternRewriter &rewriter) const override { // Get or create the declaration of the printf function in the module. - Function *printfFunc = getPrintf(*op->getFunction()->getModule()); + Function printfFunc = getPrintf(*op->getFunction().getModule()); auto print = cast(op); auto loc = print.getLoc(); // We will operate on a MemRef abstraction, we use a type.cast to get one // if our operand is still a Toy array. Value *operand = memRefTypeCast(rewriter, operands[0]); - Type retTy = printfFunc->getType().getResult(0); + Type retTy = printfFunc.getType().getResult(0); // Create our loop nest now using namespace edsc; @@ -205,8 +205,8 @@ private: /// Return the prototype declaration for printf in the module, create it if /// necessary. - Function *getPrintf(Module &module) const { - auto *printfFunc = module.getNamedFunction("printf"); + Function getPrintf(Module &module) const { + auto printfFunc = module.getNamedFunction("printf"); if (printfFunc) return printfFunc; @@ -218,10 +218,10 @@ private: auto llvmI32Ty = LLVM::LLVMType::getInt32Ty(dialect); auto llvmI8PtrTy = LLVM::LLVMType::getInt8Ty(dialect).getPointerTo(); auto printfTy = builder.getFunctionType({llvmI8PtrTy}, {llvmI32Ty}); - printfFunc = new Function(builder.getUnknownLoc(), "printf", printfTy); + printfFunc = Function::create(builder.getUnknownLoc(), "printf", printfTy); // It should be variadic, but we don't support it fully just yet. - printfFunc->setAttr("std.varargs", builder.getBoolAttr(true)); - module.getFunctions().push_back(printfFunc); + printfFunc.setAttr("std.varargs", builder.getBoolAttr(true)); + module.push_back(printfFunc); return printfFunc; } }; @@ -369,7 +369,7 @@ struct LateLoweringPass : public ModulePass { // affine dialect: they already include conversion to the LLVM dialect. // First patch calls type to return memref instead of ToyArray - for (auto &function : getModule()) { + for (auto function : getModule()) { function.walk([&](Operation *op) { auto callOp = dyn_cast(op); if (!callOp) @@ -384,7 +384,7 @@ struct LateLoweringPass : public ModulePass { }); } - for (auto &function : getModule()) { + for (auto function : getModule()) { function.walk([&](Operation *op) { // Turns toy.alloc into sequence of alloc/dealloc (later malloc/free). if (auto allocOp = dyn_cast(op)) { @@ -403,8 +403,8 @@ struct LateLoweringPass : public ModulePass { } // Lower Linalg to affine - for (auto &function : getModule()) - linalg::lowerToLoops(&function); + for (auto function : getModule()) + linalg::lowerToLoops(function); getModule().dump(); diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp index f7e6fad568e..9ebfeb438ca 100644 --- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp @@ -76,7 +76,7 @@ public: auto func = mlirGen(F); if (!func) return nullptr; - theModule->getFunctions().push_back(func.release()); + theModule->push_back(func); } // FIXME: (in the next chapter...) without registering a dialect in MLIR, @@ -130,40 +130,40 @@ private: /// Create the prototype for an MLIR function with as many arguments as the /// provided Toy AST prototype. - mlir::Function *mlirGen(PrototypeAST &proto) { + mlir::Function mlirGen(PrototypeAST &proto) { // This is a generic function, the return type will be inferred later. llvm::SmallVector ret_types; // Arguments type is uniformly a generic array. llvm::SmallVector arg_types(proto.getArgs().size(), getType(VarType{})); auto func_type = mlir::FunctionType::get(arg_types, ret_types, &context); - auto *function = new mlir::Function(loc(proto.loc()), proto.getName(), - func_type, /* attrs = */ {}); + auto function = mlir::Function::create(loc(proto.loc()), proto.getName(), + func_type, /* attrs = */ {}); // Mark the function as generic: it'll require type specialization for every // call site. - if (function->getNumArguments()) - function->setAttr("toy.generic", mlir::BoolAttr::get(true, &context)); + if (function.getNumArguments()) + function.setAttr("toy.generic", mlir::BoolAttr::get(true, &context)); return function; } /// Emit a new function and add it to the MLIR module. - std::unique_ptr mlirGen(FunctionAST &funcAST) { + mlir::Function mlirGen(FunctionAST &funcAST) { // Create a scope in the symbol table to hold variable declarations. ScopedHashTableScope var_scope(symbolTable); // Create an MLIR function for the given prototype. - std::unique_ptr function(mlirGen(*funcAST.getProto())); + mlir::Function function(mlirGen(*funcAST.getProto())); if (!function) return nullptr; // Let's start the body of the function now! // In MLIR the entry block of the function is special: it must have the same // argument list as the function itself. - function->addEntryBlock(); + function.addEntryBlock(); - auto &entryBlock = function->front(); + auto &entryBlock = function.front(); auto &protoArgs = funcAST.getProto()->getArgs(); // Declare all the function arguments in the symbol table. for (const auto &name_value : @@ -173,16 +173,18 @@ private: // Create a builder for the function, it will be used throughout the codegen // to create operations in this function. - builder = llvm::make_unique(function->getBody()); + builder = llvm::make_unique(function.getBody()); // Emit the body of the function. - if (!mlirGen(*funcAST.getBody())) + if (!mlirGen(*funcAST.getBody())) { + function.erase(); return nullptr; + } // Implicitly return void if no return statement was emited. // FIXME: we may fix the parser instead to always return the last expression // (this would possibly help the REPL case later) - if (function->getBlocks().back().back().getName().getStringRef() != + if (function.getBlocks().back().back().getName().getStringRef() != "toy.return") { ReturnExprAST fakeRet(funcAST.getProto()->loc(), llvm::None); mlirGen(fakeRet); diff --git a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp index cad2deda57e..0abcb4bb850 100644 --- a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp @@ -113,7 +113,7 @@ public: // function to process, the mangled name for this specialization, and the // types of the arguments on which to specialize. struct FunctionToSpecialize { - mlir::Function *function; + mlir::Function function; std::string mangledName; SmallVector argumentsType; }; @@ -121,7 +121,7 @@ public: void runOnModule() override { auto &module = getModule(); mlir::ModuleManager moduleManager(&module); - auto *main = moduleManager.getNamedFunction("main"); + auto main = moduleManager.getNamedFunction("main"); if (!main) { emitError(mlir::UnknownLoc::get(module.getContext()), "Shape inference failed: can't find a main function\n"); @@ -140,7 +140,7 @@ public: // Delete any generic function left // FIXME: we may want this as a separate pass. - for (mlir::Function &function : llvm::make_early_inc_range(module)) { + for (mlir::Function function : llvm::make_early_inc_range(module)) { if (auto genericAttr = function.getAttrOfType("toy.generic")) { if (genericAttr.getValue()) @@ -155,7 +155,7 @@ public: specialize(SmallVectorImpl &funcWorklist, mlir::ModuleManager &moduleManager) { FunctionToSpecialize &functionToSpecialize = funcWorklist.back(); - mlir::Function *f = functionToSpecialize.function; + mlir::Function f = functionToSpecialize.function; // Check if cloning for specialization is needed (usually anything but main) // We will create a new function with the concrete types for the parameters @@ -171,36 +171,36 @@ public: auto type = mlir::FunctionType::get(functionToSpecialize.argumentsType, {ToyArrayType::get(&getContext())}, &getContext()); - auto *newFunction = new mlir::Function( - f->getLoc(), functionToSpecialize.mangledName, type, f->getAttrs()); + auto newFunction = mlir::Function::create( + f.getLoc(), functionToSpecialize.mangledName, type, f.getAttrs()); moduleManager.insert(newFunction); // Clone the function body mlir::BlockAndValueMapping mapper; - f->cloneInto(newFunction, mapper); + f.cloneInto(newFunction, mapper); LLVM_DEBUG({ llvm::dbgs() << "====== Cloned : \n"; - f->dump(); + f.dump(); llvm::dbgs() << "====== Into : \n"; - newFunction->dump(); + newFunction.dump(); }); f = newFunction; - f->setAttr("toy.generic", mlir::BoolAttr::get(false, &getContext())); + f.setAttr("toy.generic", mlir::BoolAttr::get(false, &getContext())); // Remap the entry-block arguments // FIXME: this seems like a bug in `cloneInto()` above? - auto &entryBlock = f->getBlocks().front(); + auto &entryBlock = f.getBlocks().front(); int blockArgSize = entryBlock.getArguments().size(); - assert(blockArgSize == static_cast(f->getType().getInputs().size())); - entryBlock.addArguments(f->getType().getInputs()); + assert(blockArgSize == static_cast(f.getType().getInputs().size())); + entryBlock.addArguments(f.getType().getInputs()); auto argList = entryBlock.getArguments(); for (int argNum = 0; argNum < blockArgSize; ++argNum) { argList[0]->replaceAllUsesWith(argList[blockArgSize]); entryBlock.eraseArgument(0); } - assert(succeeded(f->verify())); + assert(succeeded(f.verify())); } LLVM_DEBUG(llvm::dbgs() - << "Run shape inference on : '" << f->getName() << "'\n"); + << "Run shape inference on : '" << f.getName() << "'\n"); auto *toyDialect = getContext().getRegisteredDialect("toy"); if (!toyDialect) { @@ -212,7 +212,7 @@ public: // Populate the worklist with the operations that need shape inference: // these are the Toy operations that return a generic array. llvm::SmallPtrSet opWorklist; - f->walk([&](mlir::Operation *op) { + f.walk([&](mlir::Operation *op) { if (op->getDialect() == toyDialect) { if (op->getNumResults() == 1 && op->getResult(0)->getType().cast().isGeneric()) @@ -295,16 +295,16 @@ public: // restart after the callee is processed. if (auto callOp = llvm::dyn_cast(op)) { auto calleeName = callOp.getCalleeName(); - auto *callee = moduleManager.getNamedFunction(calleeName); + auto callee = moduleManager.getNamedFunction(calleeName); if (!callee) { signalPassFailure(); - return f->emitError("Shape inference failed, call to unknown '") + return f.emitError("Shape inference failed, call to unknown '") << calleeName << "'"; } auto mangledName = mangle(calleeName, op->getOpOperands()); LLVM_DEBUG(llvm::dbgs() << "Found callee to infer: '" << calleeName << "', mangled: '" << mangledName << "'\n"); - auto *mangledCallee = moduleManager.getNamedFunction(mangledName); + auto mangledCallee = moduleManager.getNamedFunction(mangledName); if (!mangledCallee) { // Can't find the target, this is where we queue the request for the // callee and stop the inference for the current function now. @@ -315,7 +315,7 @@ public: // Found a specialized callee! Let's turn this into a normal call // operation. SmallVector operands(op->getOperands()); - mlir::OpBuilder builder(f->getBody()); + mlir::OpBuilder builder(f.getBody()); builder.setInsertionPoint(op); auto newCall = builder.create(op->getLoc(), mangledCallee, operands); @@ -330,12 +330,12 @@ public: // Done with inference on this function, removing it from the worklist. funcWorklist.pop_back(); // Mark the function as non-generic now that inference has succeeded - f->setAttr("toy.generic", mlir::BoolAttr::get(false, &getContext())); + f.setAttr("toy.generic", mlir::BoolAttr::get(false, &getContext())); // If the operation worklist isn't empty, this indicates a failure. if (!opWorklist.empty()) { signalPassFailure(); - auto diag = f->emitError("Shape inference failed, ") + auto diag = f.emitError("Shape inference failed, ") << opWorklist.size() << " operations couldn't be inferred\n"; for (auto *ope : opWorklist) diag << " - " << *ope << "\n"; @@ -344,24 +344,24 @@ public: // Finally, update the return type of the function based on the argument to // the return operation. - for (auto &block : f->getBlocks()) { + for (auto &block : f.getBlocks()) { auto ret = llvm::cast(block.getTerminator()); if (!ret) continue; if (ret.getNumOperands() && - f->getType().getResult(0) == ret.getOperand()->getType()) + f.getType().getResult(0) == ret.getOperand()->getType()) // type match, we're done break; SmallVector retTy; if (ret.getNumOperands()) retTy.push_back(ret.getOperand()->getType()); std::vector argumentsType; - for (auto arg : f->getArguments()) + for (auto arg : f.getArguments()) argumentsType.push_back(arg->getType()); auto newType = mlir::FunctionType::get(argumentsType, retTy, &getContext()); - f->setType(newType); - assert(succeeded(f->verify())); + f.setType(newType); + assert(succeeded(f.verify())); break; } return mlir::success(); diff --git a/mlir/include/mlir/Analysis/Dominance.h b/mlir/include/mlir/Analysis/Dominance.h index e69756e73f4..8d7b2d59afe 100644 --- a/mlir/include/mlir/Analysis/Dominance.h +++ b/mlir/include/mlir/Analysis/Dominance.h @@ -34,7 +34,7 @@ template class DominanceInfoBase { using base = llvm::DominatorTreeBase; public: - DominanceInfoBase(Function *function) { recalculate(function); } + DominanceInfoBase(Function function) { recalculate(function); } DominanceInfoBase(Operation *op) { recalculate(op); } DominanceInfoBase(DominanceInfoBase &&) = default; DominanceInfoBase &operator=(DominanceInfoBase &&) = default; @@ -43,7 +43,7 @@ public: DominanceInfoBase &operator=(const DominanceInfoBase &) = delete; /// Recalculate the dominance info. - void recalculate(Function *function); + void recalculate(Function function); void recalculate(Operation *op); /// Get the root dominance node of the given region. diff --git a/mlir/include/mlir/Analysis/NestedMatcher.h b/mlir/include/mlir/Analysis/NestedMatcher.h index 3ab24f84640..b89011a28e3 100644 --- a/mlir/include/mlir/Analysis/NestedMatcher.h +++ b/mlir/include/mlir/Analysis/NestedMatcher.h @@ -104,8 +104,8 @@ struct NestedPattern { NestedPattern &operator=(const NestedPattern &) = default; /// Returns all the top-level matches in `func`. - void match(Function *func, SmallVectorImpl *matches) { - func->walk([&](Operation *op) { matchOne(op, matches); }); + void match(Function func, SmallVectorImpl *matches) { + func.walk([&](Operation *op) { matchOne(op, matches); }); } /// Returns all the top-level matches in `op`. diff --git a/mlir/include/mlir/ExecutionEngine/MemRefUtils.h b/mlir/include/mlir/ExecutionEngine/MemRefUtils.h index a2d982d299b..3d20eaff46c 100644 --- a/mlir/include/mlir/ExecutionEngine/MemRefUtils.h +++ b/mlir/include/mlir/ExecutionEngine/MemRefUtils.h @@ -44,7 +44,7 @@ struct StaticFloatMemRef { /// each of the arguments, initialize the storage with `initialValue`, and /// return a list of type-erased descriptor pointers. llvm::Expected> -allocateMemRefArguments(Function *func, float initialValue = 0.0); +allocateMemRefArguments(Function func, float initialValue = 0.0); /// Free a list of type-erased descriptors to statically-shaped memrefs with /// element type f32. diff --git a/mlir/include/mlir/GPU/GPUDialect.h b/mlir/include/mlir/GPU/GPUDialect.h index 8f682ce7c2e..c0326deb7cd 100644 --- a/mlir/include/mlir/GPU/GPUDialect.h +++ b/mlir/include/mlir/GPU/GPUDialect.h @@ -44,7 +44,7 @@ public: /// Returns whether the given function is a kernel function, i.e., has the /// 'gpu.kernel' attribute. - static bool isKernel(Function *function); + static bool isKernel(Function function); }; /// Utility class for the GPU dialect to represent triples of `Value`s @@ -122,12 +122,12 @@ public: using Op::Op; static void build(Builder *builder, OperationState *result, - Function *kernelFunc, Value *gridSizeX, Value *gridSizeY, + Function kernelFunc, Value *gridSizeX, Value *gridSizeY, Value *gridSizeZ, Value *blockSizeX, Value *blockSizeY, Value *blockSizeZ, ArrayRef kernelOperands); static void build(Builder *builder, OperationState *result, - Function *kernelFunc, KernelDim3 gridSize, + Function kernelFunc, KernelDim3 gridSize, KernelDim3 blockSize, ArrayRef kernelOperands); /// The kernel function specified by the operation's `kernel` attribute. diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h index 5b9bfca35ad..b46e160174b 100644 --- a/mlir/include/mlir/IR/Attributes.h +++ b/mlir/include/mlir/IR/Attributes.h @@ -313,9 +313,8 @@ class FunctionAttr detail::StringAttributeStorage> { public: using Base::Base; - using ValueType = Function *; + using ValueType = StringRef; - static FunctionAttr get(Function *value); static FunctionAttr get(StringRef value, MLIRContext *ctx); /// Returns the name of the held function reference. diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h index f4ecb4ec6d7..feae5c93fea 100644 --- a/mlir/include/mlir/IR/Block.h +++ b/mlir/include/mlir/IR/Block.h @@ -101,7 +101,7 @@ public: /// Returns the function that this block is part of, even if the block is /// nested under an operation region. - Function *getFunction(); + Function getFunction(); /// Insert this block (which must not already be in a function) right before /// the specified block. diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h index 6ce5c22eadc..e5c8c035c46 100644 --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -112,7 +112,7 @@ public: AffineMapAttr getAffineMapAttr(AffineMap map); IntegerSetAttr getIntegerSetAttr(IntegerSet set); TypeAttr getTypeAttr(Type type); - FunctionAttr getFunctionAttr(Function *value); + FunctionAttr getFunctionAttr(Function value); FunctionAttr getFunctionAttr(StringRef value); ElementsAttr getDenseElementsAttr(ShapedType type, ArrayRef values); diff --git a/mlir/include/mlir/IR/Dialect.h b/mlir/include/mlir/IR/Dialect.h index 56d06619c79..4e82689efff 100644 --- a/mlir/include/mlir/IR/Dialect.h +++ b/mlir/include/mlir/IR/Dialect.h @@ -145,17 +145,13 @@ public: /// Verify an attribute from this dialect on the given function. Returns /// failure if the verification failed, success otherwise. - virtual LogicalResult verifyFunctionAttribute(Function *, NamedAttribute) { - return success(); - } + virtual LogicalResult verifyFunctionAttribute(Function, NamedAttribute); /// Verify an attribute from this dialect on the argument at 'argIndex' for /// the given function. Returns failure if the verification failed, success /// otherwise. - virtual LogicalResult - verifyFunctionArgAttribute(Function *, unsigned argIndex, NamedAttribute) { - return success(); - } + virtual LogicalResult verifyFunctionArgAttribute(Function, unsigned argIndex, + NamedAttribute); /// Verify an attribute from this dialect on the given operation. Returns /// failure if the verification failed, success otherwise. diff --git a/mlir/include/mlir/IR/Function.h b/mlir/include/mlir/IR/Function.h index 8f3b3b0df13..e11a45ba033 100644 --- a/mlir/include/mlir/IR/Function.h +++ b/mlir/include/mlir/IR/Function.h @@ -29,29 +29,79 @@ namespace mlir { class BlockAndValueMapping; class FunctionType; +class Function; class MLIRContext; class Module; -/// This is the base class for all of the MLIR function types. -class Function : public llvm::ilist_node_with_parent { +namespace detail { +/// This class represents all of the internal state of a Function. This allows +/// for the Function class to be value typed. +class FunctionStorage + : public llvm::ilist_node_with_parent { + FunctionStorage(Location location, StringRef name, FunctionType type, + ArrayRef attrs = {}); + FunctionStorage(Location location, StringRef name, FunctionType type, + ArrayRef attrs, + ArrayRef argAttrs); + /// The name of the function. + Identifier name; + + /// The module this function is embedded into. + Module *module = nullptr; + + /// The source location the function was defined or derived from. + Location location; + + /// The type of the function. + FunctionType type; + + /// This holds general named attributes for the function. + NamedAttributeList attrs; + + /// The attributes lists for each of the function arguments. + std::vector argAttrs; + + /// The body of the function. + Region body; + + friend struct llvm::ilist_traits; + friend Function; +}; +} // namespace detail + +/// This class represents an MLIR function, or the common unit of computation. +/// The region of a function is not allowed to implicitly capture global values, +/// and all external references must use Function arguments or attributes. +class Function { public: - Function(Location location, StringRef name, FunctionType type, - ArrayRef attrs = {}); - Function(Location location, StringRef name, FunctionType type, - ArrayRef attrs, - ArrayRef argAttrs); + Function(detail::FunctionStorage *impl = nullptr) : impl(impl) {} + + static Function create(Location location, StringRef name, FunctionType type, + ArrayRef attrs = {}) { + return new detail::FunctionStorage(location, name, type, attrs); + } + static Function create(Location location, StringRef name, FunctionType type, + ArrayRef attrs, + ArrayRef argAttrs) { + return new detail::FunctionStorage(location, name, type, attrs, argAttrs); + } + + /// Allow converting a Function to bool for null checks. + operator bool() const { return impl; } + bool operator==(Function other) const { return impl == other.impl; } + bool operator!=(Function other) const { return !(*this == other); } /// The source location the function was defined or derived from. - Location getLoc() { return location; } + Location getLoc() { return impl->location; } /// Set the source location this function was defined or derived from. - void setLoc(Location loc) { location = loc; } + void setLoc(Location loc) { impl->location = loc; } /// Return the name of this function, without the @. - Identifier getName() { return name; } + Identifier getName() { return impl->name; } /// Return the type of this function. - FunctionType getType() { return type; } + FunctionType getType() { return impl->type; } /// Change the type of this function in place. This is an extremely dangerous /// operation and it is up to the caller to ensure that this is legal for this @@ -61,12 +111,12 @@ public: /// parameters we drop the extra attributes, if there are more parameters /// they won't have any attributes. void setType(FunctionType newType) { - type = newType; - argAttrs.resize(type.getNumInputs()); + impl->type = newType; + impl->argAttrs.resize(newType.getNumInputs()); } MLIRContext *getContext(); - Module *getModule() { return module; } + Module *getModule() { return impl->module; } /// Add an entry block to an empty function, and set up the block arguments /// to match the signature of the function. @@ -82,28 +132,28 @@ public: // Body Handling //===--------------------------------------------------------------------===// - Region &getBody() { return body; } - void eraseBody() { body.getBlocks().clear(); } + Region &getBody() { return impl->body; } + void eraseBody() { getBody().getBlocks().clear(); } /// This is the list of blocks in the function. using RegionType = Region::RegionType; - RegionType &getBlocks() { return body.getBlocks(); } + RegionType &getBlocks() { return getBody().getBlocks(); } // Iteration over the block in the function. using iterator = RegionType::iterator; using reverse_iterator = RegionType::reverse_iterator; - iterator begin() { return body.begin(); } - iterator end() { return body.end(); } - reverse_iterator rbegin() { return body.rbegin(); } - reverse_iterator rend() { return body.rend(); } + iterator begin() { return getBody().begin(); } + iterator end() { return getBody().end(); } + reverse_iterator rbegin() { return getBody().rbegin(); } + reverse_iterator rend() { return getBody().rend(); } - bool empty() { return body.empty(); } - void push_back(Block *block) { body.push_back(block); } - void push_front(Block *block) { body.push_front(block); } + bool empty() { return getBody().empty(); } + void push_back(Block *block) { getBody().push_back(block); } + void push_front(Block *block) { getBody().push_front(block); } - Block &back() { return body.back(); } - Block &front() { return body.front(); } + Block &back() { return getBody().back(); } + Block &front() { return getBody().front(); } //===--------------------------------------------------------------------===// // Operation Walkers @@ -150,53 +200,55 @@ public: /// the lifetime of an function. /// Return all of the attributes on this function. - ArrayRef getAttrs() { return attrs.getAttrs(); } + ArrayRef getAttrs() { return impl->attrs.getAttrs(); } /// Return the internal attribute list on this function. - NamedAttributeList &getAttrList() { return attrs; } + NamedAttributeList &getAttrList() { return impl->attrs; } /// Return all of the attributes for the argument at 'index'. ArrayRef getArgAttrs(unsigned index) { assert(index < getNumArguments() && "invalid argument number"); - return argAttrs[index].getAttrs(); + return impl->argAttrs[index].getAttrs(); } /// Set the attributes held by this function. void setAttrs(ArrayRef attributes) { - attrs.setAttrs(attributes); + impl->attrs.setAttrs(attributes); } /// Set the attributes held by the argument at 'index'. void setArgAttrs(unsigned index, ArrayRef attributes) { assert(index < getNumArguments() && "invalid argument number"); - argAttrs[index].setAttrs(attributes); + impl->argAttrs[index].setAttrs(attributes); } void setArgAttrs(unsigned index, NamedAttributeList attributes) { assert(index < getNumArguments() && "invalid argument number"); - argAttrs[index] = attributes; + impl->argAttrs[index] = attributes; } void setAllArgAttrs(ArrayRef attributes) { assert(attributes.size() == getNumArguments()); for (unsigned i = 0, e = attributes.size(); i != e; ++i) - argAttrs[i] = attributes[i]; + impl->argAttrs[i] = attributes[i]; } /// Return all argument attributes of this function. - MutableArrayRef getAllArgAttrs() { return argAttrs; } + MutableArrayRef getAllArgAttrs() { + return impl->argAttrs; + } /// Return the specified attribute if present, null otherwise. - Attribute getAttr(Identifier name) { return attrs.get(name); } - Attribute getAttr(StringRef name) { return attrs.get(name); } + Attribute getAttr(Identifier name) { return impl->attrs.get(name); } + Attribute getAttr(StringRef name) { return impl->attrs.get(name); } /// Return the specified attribute, if present, for the argument at 'index', /// null otherwise. Attribute getArgAttr(unsigned index, Identifier name) { assert(index < getNumArguments() && "invalid argument number"); - return argAttrs[index].get(name); + return impl->argAttrs[index].get(name); } Attribute getArgAttr(unsigned index, StringRef name) { assert(index < getNumArguments() && "invalid argument number"); - return argAttrs[index].get(name); + return impl->argAttrs[index].get(name); } template AttrClass getAttrOfType(Identifier name) { @@ -219,13 +271,15 @@ public: /// If the an attribute exists with the specified name, change it to the new /// value. Otherwise, add a new attribute with the specified name/value. - void setAttr(Identifier name, Attribute value) { attrs.set(name, value); } + void setAttr(Identifier name, Attribute value) { + impl->attrs.set(name, value); + } void setAttr(StringRef name, Attribute value) { setAttr(Identifier::get(name, getContext()), value); } void setArgAttr(unsigned index, Identifier name, Attribute value) { assert(index < getNumArguments() && "invalid argument number"); - argAttrs[index].set(name, value); + impl->argAttrs[index].set(name, value); } void setArgAttr(unsigned index, StringRef name, Attribute value) { setArgAttr(index, Identifier::get(name, getContext()), value); @@ -234,12 +288,12 @@ public: /// Remove the attribute with the specified name if it exists. The return /// value indicates whether the attribute was present or not. NamedAttributeList::RemoveResult removeAttr(Identifier name) { - return attrs.remove(name); + return impl->attrs.remove(name); } NamedAttributeList::RemoveResult removeArgAttr(unsigned index, Identifier name) { assert(index < getNumArguments() && "invalid argument number"); - return attrs.remove(name); + return impl->attrs.remove(name); } //===--------------------------------------------------------------------===// @@ -281,44 +335,37 @@ public: /// contains entries for function arguments, these arguments are not included /// in the new function. Replaces references to cloned sub-values with the /// corresponding value that is copied, and adds those mappings to the mapper. - Function *clone(BlockAndValueMapping &mapper); - Function *clone(); + Function clone(BlockAndValueMapping &mapper); + Function clone(); /// Clone the internal blocks and attributes from this function into dest. Any /// cloned blocks are appended to the back of dest. This function asserts that /// the attributes of the current function and dest are compatible. - void cloneInto(Function *dest, BlockAndValueMapping &mapper); + void cloneInto(Function dest, BlockAndValueMapping &mapper); + + /// Methods for supporting PointerLikeTypeTraits. + const void *getAsOpaquePointer() const { + return static_cast(impl); + } + static Function getFromOpaquePointer(const void *pointer) { + return reinterpret_cast( + const_cast(pointer)); + } private: /// Set the name of this function. - void setName(Identifier newName) { name = newName; } - - /// The name of the function. - Identifier name; - - /// The module this function is embedded into. - Module *module = nullptr; - - /// The source location the function was defined or derived from. - Location location; - - /// The type of the function. - FunctionType type; - - /// This holds general named attributes for the function. - NamedAttributeList attrs; + void setName(Identifier newName) { impl->name = newName; } - /// The attributes lists for each of the function arguments. - std::vector argAttrs; - - /// The body of the function. - Region body; - - void operator=(Function &) = delete; - friend struct llvm::ilist_traits; + /// A pointer to the impl storage instance for this function. This allows for + /// 'Function' to be treated as a value type. + detail::FunctionStorage *impl = nullptr; // Allow access to 'setName'. friend class SymbolTable; + + // Allow access to 'impl'. + friend class Module; + friend class Region; }; //===--------------------------------------------------------------------===// @@ -487,21 +534,52 @@ private: namespace llvm { template <> -struct ilist_traits<::mlir::Function> - : public ilist_alloc_traits<::mlir::Function> { - using Function = ::mlir::Function; - using function_iterator = simple_ilist::iterator; +struct ilist_traits<::mlir::detail::FunctionStorage> + : public ilist_alloc_traits<::mlir::detail::FunctionStorage> { + using FunctionStorage = ::mlir::detail::FunctionStorage; + using function_iterator = simple_ilist::iterator; - static void deleteNode(Function *function) { delete function; } + static void deleteNode(FunctionStorage *function) { delete function; } - void addNodeToList(Function *function); - void removeNodeFromList(Function *function); - void transferNodesFromList(ilist_traits &otherList, + void addNodeToList(FunctionStorage *function); + void removeNodeFromList(FunctionStorage *function); + void transferNodesFromList(ilist_traits &otherList, function_iterator first, function_iterator last); private: mlir::Module *getContainingModule(); }; -} // end namespace llvm + +// Functions hash just like pointers. +template <> struct DenseMapInfo { + static mlir::Function getEmptyKey() { + auto pointer = llvm::DenseMapInfo::getEmptyKey(); + return mlir::Function::getFromOpaquePointer(pointer); + } + static mlir::Function getTombstoneKey() { + auto pointer = llvm::DenseMapInfo::getTombstoneKey(); + return mlir::Function::getFromOpaquePointer(pointer); + } + static unsigned getHashValue(mlir::Function val) { + return hash_value(val.getAsOpaquePointer()); + } + static bool isEqual(mlir::Function LHS, mlir::Function RHS) { + return LHS == RHS; + } +}; + +/// Allow stealing the low bits of FunctionStorage. +template <> struct PointerLikeTypeTraits { +public: + static inline void *getAsVoidPointer(mlir::Function I) { + return const_cast(I.getAsOpaquePointer()); + } + static inline mlir::Function getFromVoidPointer(void *P) { + return mlir::Function::getFromOpaquePointer(P); + } + enum { NumLowBitsAvailable = 3 }; +}; + +} // namespace llvm #endif // MLIR_IR_FUNCTION_H diff --git a/mlir/include/mlir/IR/Module.h b/mlir/include/mlir/IR/Module.h index 8161a305fb5..d8a47891ace 100644 --- a/mlir/include/mlir/IR/Module.h +++ b/mlir/include/mlir/IR/Module.h @@ -34,34 +34,54 @@ public: MLIRContext *getContext() { return context; } + /// An iterator class used to iterate over the held functions. + class iterator : public llvm::mapped_iterator< + llvm::iplist::iterator, + Function (*)(detail::FunctionStorage &)> { + static Function unwrap(detail::FunctionStorage &impl) { return &impl; } + + public: + using reference = Function; + + /// Initializes the operand type iterator to the specified operand iterator. + iterator(llvm::iplist::iterator it) + : llvm::mapped_iterator::iterator, + Function (*)(detail::FunctionStorage &)>( + it, &unwrap) {} + iterator(Function it) + : iterator(llvm::iplist::iterator(it.impl)) {} + }; + /// This is the list of functions in the module. - using FunctionListType = llvm::iplist; - FunctionListType &getFunctions() { return functions; } + llvm::iterator_range getFunctions() { return {begin(), end()}; } // Iteration over the functions in the module. - using iterator = FunctionListType::iterator; - using reverse_iterator = FunctionListType::reverse_iterator; - iterator begin() { return functions.begin(); } iterator end() { return functions.end(); } - reverse_iterator rbegin() { return functions.rbegin(); } - reverse_iterator rend() { return functions.rend(); } + Function front() { return &functions.front(); } + Function back() { return &functions.back(); } + + void push_back(Function fn) { functions.push_back(fn.impl); } + void insert(iterator insertPt, Function fn) { + functions.insert(insertPt.getCurrent(), fn.impl); + } // Interfaces for working with the symbol table. /// Look up a function with the specified name, returning null if no such /// name exists. Function names never include the @ on them. Note: This /// performs a linear scan of held symbols. - Function *getNamedFunction(StringRef name) { + Function getNamedFunction(StringRef name) { return getNamedFunction(Identifier::get(name, getContext())); } /// Look up a function with the specified name, returning null if no such /// name exists. Function names never include the @ on them. Note: This /// performs a linear scan of held symbols. - Function *getNamedFunction(Identifier name) { - auto it = llvm::find_if( - functions, [name](Function &fn) { return fn.getName() == name; }); + Function getNamedFunction(Identifier name) { + auto it = llvm::find_if(functions, [name](detail::FunctionStorage &fn) { + return Function(&fn).getName() == name; + }); return it == functions.end() ? nullptr : &*it; } @@ -74,11 +94,13 @@ public: void dump(); private: - friend struct llvm::ilist_traits; - friend class Function; + friend struct llvm::ilist_traits; + friend detail::FunctionStorage; + friend Function; /// getSublistAccess() - Returns pointer to member of function list - static FunctionListType Module::*getSublistAccess(Function *) { + static llvm::iplist Module::* + getSublistAccess(detail::FunctionStorage *) { return &Module::functions; } @@ -86,7 +108,7 @@ private: MLIRContext *context; /// This is the actual list of functions the module contains. - FunctionListType functions; + llvm::iplist functions; }; /// A class used to manage the symbols held by a module. This class handles @@ -98,24 +120,24 @@ public: /// Look up a symbol with the specified name, returning null if no such /// name exists. Names must never include the @ on them. - template Function *getNamedFunction(NameTy &&name) const { + template Function getNamedFunction(NameTy &&name) const { return symbolTable.lookup(name); } /// Insert a new symbol into the module, auto-renaming it as necessary. - void insert(Function *function) { + void insert(Function function) { symbolTable.insert(function); - module->getFunctions().push_back(function); + module->push_back(function); } - void insert(Module::iterator insertPt, Function *function) { + void insert(Module::iterator insertPt, Function function) { symbolTable.insert(function); - module->getFunctions().insert(insertPt, function); + module->insert(insertPt, function); } /// Remove the given symbol from the module symbol table and then erase it. - void erase(Function *function) { + void erase(Function function) { symbolTable.erase(function); - function->erase(); + function.erase(); } /// Return the internally held module. diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index e5323999df7..f916f4ba583 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -128,7 +128,7 @@ public: /// Returns the function that this operation is part of. /// The function is determined by traversing the chain of parent operations. /// Returns nullptr if the operation is unlinked. - Function *getFunction(); + Function getFunction(); /// Replace any uses of 'from' with 'to' within this operation. void replaceUsesOfWith(Value *from, Value *to); diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h index a1b81fcde40..921437601e1 100644 --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -420,7 +420,7 @@ private: /// patterns in a greedy work-list driven manner. Return true if no more /// patterns can be matched in the result function. /// -bool applyPatternsGreedily(Function &fn, OwningRewritePatternList &&patterns); +bool applyPatternsGreedily(Function fn, OwningRewritePatternList &&patterns); /// Helper class to create a list of rewrite patterns given a list of their /// types and a list of attributes perfect-forwarded to each of the conversion diff --git a/mlir/include/mlir/IR/Region.h b/mlir/include/mlir/IR/Region.h index 2189ad490f8..ad0692b0864 100644 --- a/mlir/include/mlir/IR/Region.h +++ b/mlir/include/mlir/IR/Region.h @@ -27,11 +27,16 @@ namespace mlir { class BlockAndValueMapping; +namespace detail { +class FunctionStorage; +} + /// This class contains a list of basic blocks and has a notion of the object it /// is part of - a Function or an Operation. class Region { public: - explicit Region(Function *container = nullptr); + Region() = default; + explicit Region(Function container); explicit Region(Operation *container); ~Region(); @@ -77,7 +82,7 @@ public: /// A Region is either a function body or a part of an operation. If it is /// a Function body, then return this function, otherwise return null. - Function *getContainingFunction(); + Function getContainingFunction(); /// Return true if this region is a proper ancestor of the `other` region. bool isProperAncestor(Region *other); @@ -118,7 +123,7 @@ private: RegionType blocks; /// This is the object we are part of. - llvm::PointerUnion container; + llvm::PointerUnion container; }; } // end namespace mlir diff --git a/mlir/include/mlir/IR/SymbolTable.h b/mlir/include/mlir/IR/SymbolTable.h index 30749582031..a351f66eb2e 100644 --- a/mlir/include/mlir/IR/SymbolTable.h +++ b/mlir/include/mlir/IR/SymbolTable.h @@ -18,7 +18,7 @@ #ifndef MLIR_IR_SYMBOLTABLE_H #define MLIR_IR_SYMBOLTABLE_H -#include "mlir/IR/Identifier.h" +#include "mlir/IR/Function.h" #include "llvm/ADT/DenseMap.h" namespace mlir { @@ -35,18 +35,18 @@ public: /// Look up a symbol with the specified name, returning null if no such /// name exists. Names never include the @ on them. - Function *lookup(StringRef name) const; + Function lookup(StringRef name) const; /// Look up a symbol with the specified name, returning null if no such /// name exists. Names never include the @ on them. - Function *lookup(Identifier name) const; + Function lookup(Identifier name) const; /// Erase the given symbol from the table. - void erase(Function *symbol); + void erase(Function symbol); /// Insert a new symbol into the table, and rename it as necessary to avoid /// collisions. - void insert(Function *symbol); + void insert(Function symbol); /// Returns the context held by this symbol table. MLIRContext *getContext() const { return context; } @@ -55,7 +55,7 @@ private: MLIRContext *context; /// This is a mapping from a name to the function with that name. - llvm::DenseMap symbolTable; + llvm::DenseMap symbolTable; /// This is used when name conflicts are detected. unsigned uniquingCounter = 0; diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h index e90505ec90d..4604ed99c77 100644 --- a/mlir/include/mlir/IR/Value.h +++ b/mlir/include/mlir/IR/Value.h @@ -72,7 +72,7 @@ public: } /// Return the function that this Value is defined in. - Function *getFunction(); + Function getFunction(); /// If this value is the result of an operation, return the operation that /// defines it. @@ -128,7 +128,7 @@ public: } /// Return the function that this argument is defined in. - Function *getFunction(); + Function getFunction(); Block *getOwner() { return owner; } diff --git a/mlir/include/mlir/LLVMIR/LLVMDialect.h b/mlir/include/mlir/LLVMIR/LLVMDialect.h index bd3286df8f4..a28aa719965 100644 --- a/mlir/include/mlir/LLVMIR/LLVMDialect.h +++ b/mlir/include/mlir/LLVMIR/LLVMDialect.h @@ -153,7 +153,7 @@ public: /// Verify a function argument attribute registered to this dialect. /// Returns failure if the verification failed, success otherwise. - LogicalResult verifyFunctionArgAttribute(Function *func, unsigned argIdx, + LogicalResult verifyFunctionArgAttribute(Function func, unsigned argIdx, NamedAttribute argAttr) override; private: diff --git a/mlir/include/mlir/Pass/AnalysisManager.h b/mlir/include/mlir/Pass/AnalysisManager.h index 3751a93629d..c44f88f6763 100644 --- a/mlir/include/mlir/Pass/AnalysisManager.h +++ b/mlir/include/mlir/Pass/AnalysisManager.h @@ -106,7 +106,7 @@ template class AnalysisMap { } public: - explicit AnalysisMap(IRUnitT *ir) : ir(ir) {} + explicit AnalysisMap(IRUnitT ir) : ir(ir) {} /// Get an analysis for the current IR unit, computing it if necessary. template AnalysisT &getAnalysis(PassInstrumentor *pi) { @@ -140,8 +140,8 @@ public: } /// Returns the IR unit that this analysis map represents. - IRUnitT *getIRUnit() { return ir; } - const IRUnitT *getIRUnit() const { return ir; } + IRUnitT getIRUnit() { return ir; } + const IRUnitT getIRUnit() const { return ir; } /// Clear any held analyses. void clear() { analyses.clear(); } @@ -158,7 +158,7 @@ public: } private: - IRUnitT *ir; + IRUnitT ir; ConceptMap analyses; }; @@ -231,14 +231,14 @@ public: /// Query for the analysis of a function. The analysis is computed if it does /// not exist. template - AnalysisT &getFunctionAnalysis(Function *function) { + AnalysisT &getFunctionAnalysis(Function function) { return slice(function).getAnalysis(); } /// Query for a cached analysis of a child function, or return null. template llvm::Optional> - getCachedFunctionAnalysis(Function *function) const { + getCachedFunctionAnalysis(Function function) const { auto it = functionAnalyses.find(function); if (it == functionAnalyses.end()) return llvm::None; @@ -258,7 +258,7 @@ public: } /// Create an analysis slice for the given child function. - FunctionAnalysisManager slice(Function *function); + FunctionAnalysisManager slice(Function function); /// Invalidate any non preserved analyses. void invalidate(const detail::PreservedAnalyses &pa); @@ -269,11 +269,11 @@ public: private: /// The cached analyses for functions within the current module. - llvm::DenseMap>> + llvm::DenseMap>> functionAnalyses; /// The analyses for the owning module. - detail::AnalysisMap moduleAnalyses; + detail::AnalysisMap moduleAnalyses; /// An optional instrumentation object. PassInstrumentor *passInstrumentor; diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h index 5fd6dfd18b5..41d20ccdd63 100644 --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -70,12 +70,12 @@ class ModulePassExecutor; /// interface for accessing and initializing necessary state for pass execution. template struct PassExecutionState { - PassExecutionState(IRUnitT *ir, AnalysisManagerT &analysisManager) + PassExecutionState(IRUnitT ir, AnalysisManagerT &analysisManager) : irAndPassFailed(ir, false), analysisManager(analysisManager) {} /// The current IR unit being transformed and a bool for if the pass signaled /// a failure. - llvm::PointerIntPair irAndPassFailed; + llvm::PointerIntPair irAndPassFailed; /// The analysis manager for the IR unit. AnalysisManagerT &analysisManager; @@ -107,9 +107,7 @@ protected: virtual FunctionPassBase *clone() const = 0; /// Return the current function being transformed. - Function &getFunction() { - return *getPassState().irAndPassFailed.getPointer(); - } + Function getFunction() { return getPassState().irAndPassFailed.getPointer(); } /// Return the MLIR context for the current function being transformed. MLIRContext &getContext() { return *getFunction().getContext(); } @@ -128,7 +126,7 @@ protected: private: /// Forwarding function to execute this pass. LLVM_NODISCARD - LogicalResult run(Function *fn, FunctionAnalysisManager &fam); + LogicalResult run(Function fn, FunctionAnalysisManager &fam); /// The current execution state for the pass. llvm::Optional passState; @@ -140,7 +138,8 @@ private: /// Pass to transform a module. Derived passes should not inherit from this /// class directly, and instead should use the CRTP ModulePass class. class ModulePassBase : public Pass { - using PassStateT = detail::PassExecutionState; + using PassStateT = + detail::PassExecutionState; public: static bool classof(const Pass *pass) { @@ -272,7 +271,7 @@ struct FunctionPass : public detail::PassModel { template struct ModulePass : public detail::PassModel { /// Returns the analysis for a child function. - template AnalysisT &getFunctionAnalysis(Function *f) { + template AnalysisT &getFunctionAnalysis(Function f) { return this->getAnalysisManager().template getFunctionAnalysis( f); } @@ -280,7 +279,7 @@ struct ModulePass : public detail::PassModel { /// Returns an existing analysis for a child function if it exists. template llvm::Optional> - getCachedFunctionAnalysis(Function *f) { + getCachedFunctionAnalysis(Function f) { return this->getAnalysisManager() .template getCachedFunctionAnalysis(f); } diff --git a/mlir/include/mlir/Pass/PassInstrumentation.h b/mlir/include/mlir/Pass/PassInstrumentation.h index 0f427066296..40358329f45 100644 --- a/mlir/include/mlir/Pass/PassInstrumentation.h +++ b/mlir/include/mlir/Pass/PassInstrumentation.h @@ -77,29 +77,29 @@ public: ~PassInstrumentor(); /// See PassInstrumentation::runBeforePass for details. - template void runBeforePass(Pass *pass, IRUnitT *ir) { + template void runBeforePass(Pass *pass, IRUnitT ir) { runBeforePass(pass, llvm::Any(ir)); } /// See PassInstrumentation::runAfterPass for details. - template void runAfterPass(Pass *pass, IRUnitT *ir) { + template void runAfterPass(Pass *pass, IRUnitT ir) { runAfterPass(pass, llvm::Any(ir)); } /// See PassInstrumentation::runAfterPassFailed for details. - template void runAfterPassFailed(Pass *pass, IRUnitT *ir) { + template void runAfterPassFailed(Pass *pass, IRUnitT ir) { runAfterPassFailed(pass, llvm::Any(ir)); } /// See PassInstrumentation::runBeforeAnalysis for details. template - void runBeforeAnalysis(llvm::StringRef name, AnalysisID *id, IRUnitT *ir) { + void runBeforeAnalysis(llvm::StringRef name, AnalysisID *id, IRUnitT ir) { runBeforeAnalysis(name, id, llvm::Any(ir)); } /// See PassInstrumentation::runAfterAnalysis for details. template - void runAfterAnalysis(llvm::StringRef name, AnalysisID *id, IRUnitT *ir) { + void runAfterAnalysis(llvm::StringRef name, AnalysisID *id, IRUnitT ir) { runAfterAnalysis(name, id, llvm::Any(ir)); } diff --git a/mlir/include/mlir/StandardOps/Ops.td b/mlir/include/mlir/StandardOps/Ops.td index 1b14e2a2a9c..a7afe1f9e7c 100644 --- a/mlir/include/mlir/StandardOps/Ops.td +++ b/mlir/include/mlir/StandardOps/Ops.td @@ -214,11 +214,11 @@ def CallOp : Std_Op<"call"> { let results = (outs Variadic); let builders = [OpBuilder< - "Builder *builder, OperationState *result, Function *callee," + "Builder *builder, OperationState *result, Function callee," "ArrayRef operands = {}", [{ result->addOperands(operands); result->addAttribute("callee", builder->getFunctionAttr(callee)); - result->addTypes(callee->getType().getResults()); + result->addTypes(callee.getType().getResults()); }]>, OpBuilder< "Builder *builder, OperationState *result, StringRef callee," "ArrayRef results, ArrayRef operands = {}", [{ diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index 00da0d5fcc0..c8ede78ec20 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -345,7 +345,7 @@ LLVM_NODISCARD LogicalResult applyConversionPatterns( /// Convert the given functions with the provided conversion patterns. This /// function returns failure if a type conversion failed. LLVM_NODISCARD -LogicalResult applyConversionPatterns(ArrayRef fns, +LogicalResult applyConversionPatterns(MutableArrayRef fns, ConversionTarget &target, TypeConverter &converter, OwningRewritePatternList &&patterns); @@ -354,7 +354,7 @@ LogicalResult applyConversionPatterns(ArrayRef fns, /// convert as many of the operations within 'fn' as possible given the set of /// patterns. LLVM_NODISCARD -LogicalResult applyConversionPatterns(Function &fn, ConversionTarget &target, +LogicalResult applyConversionPatterns(Function fn, ConversionTarget &target, OwningRewritePatternList &&patterns); } // end namespace mlir diff --git a/mlir/include/mlir/Transforms/LowerAffine.h b/mlir/include/mlir/Transforms/LowerAffine.h index d77b35a8044..09aa7dc8acd 100644 --- a/mlir/include/mlir/Transforms/LowerAffine.h +++ b/mlir/include/mlir/Transforms/LowerAffine.h @@ -37,7 +37,7 @@ Value *expandAffineExpr(OpBuilder &builder, Location loc, AffineExpr expr, /// Convert from the Affine dialect to the Standard dialect, in particular /// convert structured affine control flow into CFG branch-based control flow. -LogicalResult lowerAffineConstructs(Function &function); +LogicalResult lowerAffineConstructs(Function function); /// Emit code that computes the lower bound of the given affine loop using /// standard arithmetic operations. diff --git a/mlir/include/mlir/Transforms/ViewFunctionGraph.h b/mlir/include/mlir/Transforms/ViewFunctionGraph.h index c1da5ef9638..5780df5c21b 100644 --- a/mlir/include/mlir/Transforms/ViewFunctionGraph.h +++ b/mlir/include/mlir/Transforms/ViewFunctionGraph.h @@ -33,11 +33,11 @@ class FunctionPassBase; /// Displays the CFG in a window. This is for use from the debugger and /// depends on Graphviz to generate the graph. -void viewGraph(Function &function, const Twine &name, bool shortNames = false, +void viewGraph(Function function, const Twine &name, bool shortNames = false, const Twine &title = "", llvm::GraphProgram::Name program = llvm::GraphProgram::DOT); -llvm::raw_ostream &writeGraph(llvm::raw_ostream &os, Function &function, +llvm::raw_ostream &writeGraph(llvm::raw_ostream &os, Function function, bool shortNames = false, const Twine &title = ""); /// Creates a pass to print CFG graphs. diff --git a/mlir/lib/AffineOps/AffineOps.cpp b/mlir/lib/AffineOps/AffineOps.cpp index 016ef43a84a..d7650dcb127 100644 --- a/mlir/lib/AffineOps/AffineOps.cpp +++ b/mlir/lib/AffineOps/AffineOps.cpp @@ -303,7 +303,7 @@ AffineDimExpr AffineApplyNormalizer::renumberOneDim(Value *v) { if (inserted) { reorderedDims.push_back(v); } - return getAffineDimExpr(iterPos->second, v->getFunction()->getContext()) + return getAffineDimExpr(iterPos->second, v->getFunction().getContext()) .cast(); } diff --git a/mlir/lib/Analysis/Dominance.cpp b/mlir/lib/Analysis/Dominance.cpp index 954a01b4843..b4cdeb7d886 100644 --- a/mlir/lib/Analysis/Dominance.cpp +++ b/mlir/lib/Analysis/Dominance.cpp @@ -37,17 +37,16 @@ template class llvm::DomTreeNodeBase; /// Recalculate the dominance info. template -void DominanceInfoBase::recalculate(Function *function) { +void DominanceInfoBase::recalculate(Function function) { dominanceInfos.clear(); // Build the top level function dominance. auto functionDominance = llvm::make_unique(); - functionDominance->recalculate(function->getBody()); - dominanceInfos.try_emplace(&function->getBody(), - std::move(functionDominance)); + functionDominance->recalculate(function.getBody()); + dominanceInfos.try_emplace(&function.getBody(), std::move(functionDominance)); /// Build the dominance for each of the operation regions. - function->walk([&](Operation *op) { + function.walk([&](Operation *op) { for (auto ®ion : op->getRegions()) { // Don't compute dominance if the region is empty. if (region.empty()) diff --git a/mlir/lib/Analysis/OpStats.cpp b/mlir/lib/Analysis/OpStats.cpp index 5177afcee67..75a2fc1a5dc 100644 --- a/mlir/lib/Analysis/OpStats.cpp +++ b/mlir/lib/Analysis/OpStats.cpp @@ -45,7 +45,7 @@ void PrintOpStatsPass::runOnModule() { opCount.clear(); // Compute the operation statistics for each function in the module. - for (auto &fn : getModule()) + for (auto fn : getModule()) fn.walk([&](Operation *op) { ++opCount[op->getName().getStringRef()]; }); printSummary(); } diff --git a/mlir/lib/Analysis/TestParallelismDetection.cpp b/mlir/lib/Analysis/TestParallelismDetection.cpp index cbda6d40224..473d253cfa2 100644 --- a/mlir/lib/Analysis/TestParallelismDetection.cpp +++ b/mlir/lib/Analysis/TestParallelismDetection.cpp @@ -43,7 +43,7 @@ FunctionPassBase *mlir::createParallelismDetectionTestPass() { // Walks the function and emits a note for all 'affine.for' ops detected as // parallel. void TestParallelismDetection::runOnFunction() { - Function &f = getFunction(); + Function f = getFunction(); OpBuilder b(f.getBody()); f.walk([&](AffineForOp forOp) { if (isLoopParallel(forOp)) diff --git a/mlir/lib/Analysis/Verifier.cpp b/mlir/lib/Analysis/Verifier.cpp index 1330fe0fb94..0d0525145ef 100644 --- a/mlir/lib/Analysis/Verifier.cpp +++ b/mlir/lib/Analysis/Verifier.cpp @@ -53,7 +53,7 @@ public: : ctx(ctx), identifierRegex("^[a-zA-Z_][a-zA-Z_0-9\\.\\$]*$") {} /// Verify the body of the given function. - LogicalResult verify(Function &fn); + LogicalResult verify(Function fn); /// Verify the given operation. LogicalResult verify(Operation &op); @@ -104,7 +104,7 @@ private: } // end anonymous namespace /// Verify the body of the given function. -LogicalResult OperationVerifier::verify(Function &fn) { +LogicalResult OperationVerifier::verify(Function fn) { // Verify the body first. if (failed(verifyRegion(fn.getBody()))) return failure(); @@ -113,7 +113,7 @@ LogicalResult OperationVerifier::verify(Function &fn) { // check. We do this as a second pass since malformed CFG's can cause // dominator analysis constructure to crash and we want the verifier to be // resilient to malformed code. - DominanceInfo theDomInfo(&fn); + DominanceInfo theDomInfo(fn); domInfo = &theDomInfo; if (failed(verifyDominance(fn.getBody()))) return failure(); @@ -313,7 +313,7 @@ LogicalResult Function::verify() { // Verify this attribute with the defining dialect. if (auto *dialect = opVerifier.getDialectForAttribute(attr)) - if (failed(dialect->verifyFunctionAttribute(this, attr))) + if (failed(dialect->verifyFunctionAttribute(*this, attr))) return failure(); } @@ -331,7 +331,7 @@ LogicalResult Function::verify() { // Verify this attribute with the defining dialect. if (auto *dialect = opVerifier.getDialectForAttribute(attr)) - if (failed(dialect->verifyFunctionArgAttribute(this, i, attr))) + if (failed(dialect->verifyFunctionArgAttribute(*this, i, attr))) return failure(); } } @@ -369,7 +369,7 @@ LogicalResult Operation::verify() { LogicalResult Module::verify() { // Check that all functions are uniquely named. llvm::StringMap nameToOrigLoc; - for (auto &fn : *this) { + for (auto fn : *this) { auto it = nameToOrigLoc.try_emplace(fn.getName(), fn.getLoc()); if (!it.second) return fn.emitError() @@ -379,7 +379,7 @@ LogicalResult Module::verify() { } // Check that each function is correct. - for (auto &fn : *this) + for (auto fn : *this) if (failed(fn.verify())) return failure(); diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp index 9d7aeeb6321..022d8c70cc6 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp @@ -64,8 +64,8 @@ public: LLVMInitializeNVPTXTargetMC(); LLVMInitializeNVPTXAsmPrinter(); - for (auto &function : getModule()) { - if (!gpu::GPUDialect::isKernel(&function) || function.isExternal()) { + for (auto function : getModule()) { + if (!gpu::GPUDialect::isKernel(function) || function.isExternal()) { continue; } if (failed(translateGpuKernelToCubinAnnotation(function))) @@ -142,7 +142,7 @@ GpuKernelToCubinPass::translateGpuKernelToCubinAnnotation(Function &function) { std::unique_ptr module(builder.createModule()); // TODO(herhut): Also handle called functions. - module->getFunctions().push_back(function.clone()); + module->push_back(function.clone()); auto llvmModule = translateModuleToNVVMIR(*module); auto cubin = convertModuleToCubin(*llvmModule, function); diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp index bd96f396b22..f9d5899456a 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp @@ -118,7 +118,7 @@ private: void declareCudaFunctions(Location loc); Value *setupParamsArray(gpu::LaunchFuncOp launchOp, OpBuilder &builder); - Value *generateKernelNameConstant(Function *kernelFunction, Location &loc, + Value *generateKernelNameConstant(Function kernelFunction, Location &loc, OpBuilder &builder); void translateGpuLaunchCalls(mlir::gpu::LaunchFuncOp launchOp); @@ -130,7 +130,7 @@ public: // Cache the used LLVM types. initializeCachedTypes(); - for (auto &func : getModule()) { + for (auto func : getModule()) { func.walk( [this](mlir::gpu::LaunchFuncOp op) { translateGpuLaunchCalls(op); }); } @@ -155,66 +155,66 @@ void GpuLaunchFuncToCudaCallsPass::declareCudaFunctions(Location loc) { Module &module = getModule(); Builder builder(&module); if (!module.getNamedFunction(cuModuleLoadName)) { - module.getFunctions().push_back( - new Function(loc, cuModuleLoadName, - builder.getFunctionType( - { - getPointerPointerType(), /* CUmodule *module */ - getPointerType() /* void *cubin */ - }, - getCUResultType()))); + module.push_back( + Function::create(loc, cuModuleLoadName, + builder.getFunctionType( + { + getPointerPointerType(), /* CUmodule *module */ + getPointerType() /* void *cubin */ + }, + getCUResultType()))); } if (!module.getNamedFunction(cuModuleGetFunctionName)) { // The helper uses void* instead of CUDA's opaque CUmodule and // CUfunction. - module.getFunctions().push_back( - new Function(loc, cuModuleGetFunctionName, - builder.getFunctionType( - { - getPointerPointerType(), /* void **function */ - getPointerType(), /* void *module */ - getPointerType() /* char *name */ - }, - getCUResultType()))); + module.push_back( + Function::create(loc, cuModuleGetFunctionName, + builder.getFunctionType( + { + getPointerPointerType(), /* void **function */ + getPointerType(), /* void *module */ + getPointerType() /* char *name */ + }, + getCUResultType()))); } if (!module.getNamedFunction(cuLaunchKernelName)) { // Other than the CUDA api, the wrappers use uintptr_t to match the // LLVM type if MLIR's index type, which the GPU dialect uses. // Furthermore, they use void* instead of CUDA's opaque CUfunction and // CUstream. - module.getFunctions().push_back( - new Function(loc, cuLaunchKernelName, - builder.getFunctionType( - { - getPointerType(), /* void* f */ - getIntPtrType(), /* intptr_t gridXDim */ - getIntPtrType(), /* intptr_t gridyDim */ - getIntPtrType(), /* intptr_t gridZDim */ - getIntPtrType(), /* intptr_t blockXDim */ - getIntPtrType(), /* intptr_t blockYDim */ - getIntPtrType(), /* intptr_t blockZDim */ - getInt32Type(), /* unsigned int sharedMemBytes */ - getPointerType(), /* void *hstream */ - getPointerPointerType(), /* void **kernelParams */ - getPointerPointerType() /* void **extra */ - }, - getCUResultType()))); + module.push_back(Function::create( + loc, cuLaunchKernelName, + builder.getFunctionType( + { + getPointerType(), /* void* f */ + getIntPtrType(), /* intptr_t gridXDim */ + getIntPtrType(), /* intptr_t gridyDim */ + getIntPtrType(), /* intptr_t gridZDim */ + getIntPtrType(), /* intptr_t blockXDim */ + getIntPtrType(), /* intptr_t blockYDim */ + getIntPtrType(), /* intptr_t blockZDim */ + getInt32Type(), /* unsigned int sharedMemBytes */ + getPointerType(), /* void *hstream */ + getPointerPointerType(), /* void **kernelParams */ + getPointerPointerType() /* void **extra */ + }, + getCUResultType()))); } if (!module.getNamedFunction(cuGetStreamHelperName)) { // Helper function to get the current CUDA stream. Uses void* instead of // CUDAs opaque CUstream. - module.getFunctions().push_back(new Function( + module.push_back(Function::create( loc, cuGetStreamHelperName, builder.getFunctionType({}, getPointerType() /* void *stream */))); } if (!module.getNamedFunction(cuStreamSynchronizeName)) { - module.getFunctions().push_back( - new Function(loc, cuStreamSynchronizeName, - builder.getFunctionType( - { - getPointerType() /* CUstream stream */ - }, - getCUResultType()))); + module.push_back( + Function::create(loc, cuStreamSynchronizeName, + builder.getFunctionType( + { + getPointerType() /* CUstream stream */ + }, + getCUResultType()))); } } @@ -264,14 +264,14 @@ GpuLaunchFuncToCudaCallsPass::setupParamsArray(gpu::LaunchFuncOp launchOp, // %0[n] = constant name[n] // %0[n+1] = 0 Value *GpuLaunchFuncToCudaCallsPass::generateKernelNameConstant( - Function *kernelFunction, Location &loc, OpBuilder &builder) { + Function kernelFunction, Location &loc, OpBuilder &builder) { // TODO(herhut): Make this a constant once this is supported. auto kernelNameSize = builder.create( loc, getInt32Type(), - builder.getI32IntegerAttr(kernelFunction->getName().size() + 1)); + builder.getI32IntegerAttr(kernelFunction.getName().size() + 1)); auto kernelName = builder.create(loc, getPointerType(), kernelNameSize); - for (auto byte : llvm::enumerate(kernelFunction->getName())) { + for (auto byte : llvm::enumerate(kernelFunction.getName())) { auto index = builder.create( loc, getInt32Type(), builder.getI32IntegerAttr(byte.index())); auto gep = builder.create(loc, getPointerType(), kernelName, @@ -284,7 +284,7 @@ Value *GpuLaunchFuncToCudaCallsPass::generateKernelNameConstant( // Add trailing zero to terminate string. auto index = builder.create( loc, getInt32Type(), - builder.getI32IntegerAttr(kernelFunction->getName().size())); + builder.getI32IntegerAttr(kernelFunction.getName().size())); auto gep = builder.create(loc, getPointerType(), kernelName, ArrayRef{index}); auto value = builder.create( @@ -326,9 +326,9 @@ void GpuLaunchFuncToCudaCallsPass::translateGpuLaunchCalls( // TODO(herhut): This should rather be a static global once supported. auto kernelFunction = getModule().getNamedFunction(launchOp.kernel()); auto cubinGetter = - kernelFunction->getAttrOfType(kCubinGetterAnnotation); + kernelFunction.getAttrOfType(kCubinGetterAnnotation); if (!cubinGetter) { - kernelFunction->emitError("Missing ") + kernelFunction.emitError("Missing ") << kCubinGetterAnnotation << " attribute."; return signalPassFailure(); } @@ -337,7 +337,7 @@ void GpuLaunchFuncToCudaCallsPass::translateGpuLaunchCalls( // Emit the load module call to load the module data. Error checking is done // in the called helper function. auto cuModule = allocatePointer(builder, loc); - Function *cuModuleLoad = getModule().getNamedFunction(cuModuleLoadName); + Function cuModuleLoad = getModule().getNamedFunction(cuModuleLoadName); builder.create(loc, ArrayRef{getCUResultType()}, builder.getFunctionAttr(cuModuleLoad), ArrayRef{cuModule, data.getResult(0)}); @@ -347,14 +347,14 @@ void GpuLaunchFuncToCudaCallsPass::translateGpuLaunchCalls( builder.create(loc, getPointerType(), cuModule); auto kernelName = generateKernelNameConstant(kernelFunction, loc, builder); auto cuFunction = allocatePointer(builder, loc); - Function *cuModuleGetFunction = + Function cuModuleGetFunction = getModule().getNamedFunction(cuModuleGetFunctionName); builder.create( loc, ArrayRef{getCUResultType()}, builder.getFunctionAttr(cuModuleGetFunction), ArrayRef{cuFunction, cuModuleRef, kernelName}); // Grab the global stream needed for execution. - Function *cuGetStreamHelper = + Function cuGetStreamHelper = getModule().getNamedFunction(cuGetStreamHelperName); auto cuStream = builder.create( loc, ArrayRef{getPointerType()}, diff --git a/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp b/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp index c1d4af380ce..97790a5afce 100644 --- a/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp @@ -53,15 +53,15 @@ constexpr const char *kMallocHelperName = "mcuMalloc"; class GpuGenerateCubinAccessorsPass : public ModulePass { private: - Function *getMallocHelper(Location loc, Builder &builder) { - Function *result = getModule().getNamedFunction(kMallocHelperName); + Function getMallocHelper(Location loc, Builder &builder) { + Function result = getModule().getNamedFunction(kMallocHelperName); if (!result) { - result = new Function( + result = Function::create( loc, kMallocHelperName, builder.getFunctionType( ArrayRef{LLVM::LLVMType::getInt32Ty(llvmDialect)}, LLVM::LLVMType::getInt8PtrTy(llvmDialect))); - getModule().getFunctions().push_back(result); + getModule().push_back(result); } return result; } @@ -70,18 +70,18 @@ private: // data from blob. As there are currently no global constants, this uses a // sequence of store operations. // TODO(herhut): Use global constants instead. - Function *generateCubinAccessor(Builder &builder, Function &orig, - StringAttr blob) { + Function generateCubinAccessor(Builder &builder, Function &orig, + StringAttr blob) { Location loc = orig.getLoc(); SmallString<128> nameBuffer(orig.getName()); nameBuffer.append(kCubinGetterSuffix); // Generate a function that returns void*. - Function *result = new Function( + Function result = Function::create( loc, mlir::Identifier::get(nameBuffer, &getContext()), builder.getFunctionType(ArrayRef{}, LLVM::LLVMType::getInt8PtrTy(llvmDialect))); // Insert a body block that just returns the constant. - OpBuilder ob(result->getBody()); + OpBuilder ob(result.getBody()); ob.createBlock(); auto sizeConstant = ob.create( loc, LLVM::LLVMType::getInt32Ty(llvmDialect), @@ -115,18 +115,18 @@ public: void runOnModule() override { llvmDialect = getModule().getContext()->getRegisteredDialect(); - Builder builder(getModule().getContext()); + auto &module = getModule(); + Builder builder(&getContext()); - auto &functions = getModule().getFunctions(); + auto functions = module.getFunctions(); for (auto it = functions.begin(); it != functions.end();) { // Move iterator to after the current function so that potential insertion // of the accessor is after the kernel with cubin iself. - Function &orig = *it++; + Function orig = *it++; StringAttr cubinBlob = orig.getAttrOfType(kCubinAnnotation); if (!cubinBlob) continue; - it = - functions.insert(it, generateCubinAccessor(builder, orig, cubinBlob)); + module.insert(it, generateCubinAccessor(builder, orig, cubinBlob)); } } diff --git a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp index 872707842d7..e849f6fd023 100644 --- a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp @@ -441,13 +441,14 @@ struct AllocOpLowering : public LLVMLegalizationPattern { createIndexConstant(rewriter, op->getLoc(), elementSize)}); // Insert the `malloc` declaration if it is not already present. - Function *mallocFunc = - op->getFunction()->getModule()->getNamedFunction("malloc"); + Function mallocFunc = + op->getFunction().getModule()->getNamedFunction("malloc"); if (!mallocFunc) { auto mallocType = rewriter.getFunctionType(getIndexType(), getVoidPtrType()); - mallocFunc = new Function(rewriter.getUnknownLoc(), "malloc", mallocType); - op->getFunction()->getModule()->getFunctions().push_back(mallocFunc); + mallocFunc = + Function::create(rewriter.getUnknownLoc(), "malloc", mallocType); + op->getFunction().getModule()->push_back(mallocFunc); } // Allocate the underlying buffer and store a pointer to it in the MemRef @@ -502,12 +503,11 @@ struct DeallocOpLowering : public LLVMLegalizationPattern { OperandAdaptor transformed(operands); // Insert the `free` declaration if it is not already present. - Function *freeFunc = - op->getFunction()->getModule()->getNamedFunction("free"); + Function freeFunc = op->getFunction().getModule()->getNamedFunction("free"); if (!freeFunc) { auto freeType = rewriter.getFunctionType(getVoidPtrType(), {}); - freeFunc = new Function(rewriter.getUnknownLoc(), "free", freeType); - op->getFunction()->getModule()->getFunctions().push_back(freeFunc); + freeFunc = Function::create(rewriter.getUnknownLoc(), "free", freeType); + op->getFunction().getModule()->push_back(freeFunc); } auto type = transformed.memref()->getType().cast(); @@ -937,7 +937,7 @@ static void ensureDistinctSuccessors(Block &bb) { } void mlir::LLVM::ensureDistinctSuccessors(Module *m) { - for (auto &f : *m) { + for (auto f : *m) { for (auto &bb : f.getBlocks()) { ::ensureDistinctSuccessors(bb); } diff --git a/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp b/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp index ff198217bb7..dafc8e711f5 100644 --- a/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp +++ b/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp @@ -365,7 +365,7 @@ struct UniformRealMulEwPattern : public OpRewritePattern { //===----------------------------------------------------------------------===// void LowerUniformRealMathPass::runOnFunction() { - auto &fn = getFunction(); + auto fn = getFunction(); OwningRewritePatternList patterns; auto *context = &getContext(); patterns.push_back(llvm::make_unique(context)); @@ -386,7 +386,7 @@ static PassRegistration lowerUniformRealMathPass( //===----------------------------------------------------------------------===// void LowerUniformCastsPass::runOnFunction() { - auto &fn = getFunction(); + auto fn = getFunction(); OwningRewritePatternList patterns; auto *context = &getContext(); patterns.push_back(llvm::make_unique(context)); diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp index 9dcc6df6bea..8469fa2ea70 100644 --- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp +++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp @@ -106,7 +106,7 @@ QuantizedConstRewrite::matchAndRewrite(QuantizeCastOp qbarrier, void ConvertConstPass::runOnFunction() { OwningRewritePatternList patterns; - auto &func = getFunction(); + auto func = getFunction(); auto *context = &getContext(); patterns.push_back(llvm::make_unique(context)); applyPatternsGreedily(func, std::move(patterns)); diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp index ea8095b791c..0c93146a232 100644 --- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp +++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp @@ -95,7 +95,7 @@ public: void ConvertSimulatedQuantPass::runOnFunction() { bool hadFailure = false; OwningRewritePatternList patterns; - auto &func = getFunction(); + auto func = getFunction(); auto *context = &getContext(); patterns.push_back( llvm::make_unique(context, &hadFailure)); diff --git a/mlir/lib/ExecutionEngine/MemRefUtils.cpp b/mlir/lib/ExecutionEngine/MemRefUtils.cpp index 51636037382..f13b743de0c 100644 --- a/mlir/lib/ExecutionEngine/MemRefUtils.cpp +++ b/mlir/lib/ExecutionEngine/MemRefUtils.cpp @@ -67,10 +67,10 @@ allocMemRefDescriptor(Type type, bool allocateData = true, } llvm::Expected> -mlir::allocateMemRefArguments(Function *func, float initialValue) { +mlir::allocateMemRefArguments(Function func, float initialValue) { SmallVector args; - args.reserve(func->getNumArguments()); - for (const auto &arg : func->getArguments()) { + args.reserve(func.getNumArguments()); + for (const auto &arg : func.getArguments()) { auto descriptor = allocMemRefDescriptor(arg->getType(), /*allocateData=*/true, initialValue); @@ -79,10 +79,10 @@ mlir::allocateMemRefArguments(Function *func, float initialValue) { args.push_back(*descriptor); } - if (func->getType().getNumResults() > 1) + if (func.getType().getNumResults() > 1) return make_string_error("functions with more than 1 result not supported"); - for (Type resType : func->getType().getResults()) { + for (Type resType : func.getType().getResults()) { auto descriptor = allocMemRefDescriptor(resType, /*allocateData=*/false); if (!descriptor) return descriptor.takeError(); diff --git a/mlir/lib/GPU/IR/GPUDialect.cpp b/mlir/lib/GPU/IR/GPUDialect.cpp index e39860bddda..5e8090b42b4 100644 --- a/mlir/lib/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/GPU/IR/GPUDialect.cpp @@ -30,9 +30,9 @@ using namespace mlir::gpu; StringRef GPUDialect::getDialectName() { return "gpu"; } -bool GPUDialect::isKernel(Function *function) { +bool GPUDialect::isKernel(Function function) { UnitAttr isKernelAttr = - function->getAttrOfType(getKernelFuncAttrName()); + function.getAttrOfType(getKernelFuncAttrName()); return static_cast(isKernelAttr); } @@ -318,7 +318,7 @@ ParseResult LaunchOp::parse(OpAsmParser *parser, OperationState *result) { //===----------------------------------------------------------------------===// void LaunchFuncOp::build(Builder *builder, OperationState *result, - Function *kernelFunc, Value *gridSizeX, + Function kernelFunc, Value *gridSizeX, Value *gridSizeY, Value *gridSizeZ, Value *blockSizeX, Value *blockSizeY, Value *blockSizeZ, ArrayRef kernelOperands) { @@ -331,7 +331,7 @@ void LaunchFuncOp::build(Builder *builder, OperationState *result, } void LaunchFuncOp::build(Builder *builder, OperationState *result, - Function *kernelFunc, KernelDim3 gridSize, + Function kernelFunc, KernelDim3 gridSize, KernelDim3 blockSize, ArrayRef kernelOperands) { build(builder, result, kernelFunc, gridSize.x, gridSize.y, gridSize.z, @@ -366,23 +366,23 @@ LogicalResult LaunchFuncOp::verify() { return emitOpError("attribute 'kernel' must be a function"); } - auto *module = getOperation()->getFunction()->getModule(); - Function *kernelFunc = module->getNamedFunction(kernel()); + auto *module = getOperation()->getFunction().getModule(); + Function kernelFunc = module->getNamedFunction(kernel()); if (!kernelFunc) return emitError() << "kernel function '" << kernelAttr << "' is undefined"; - if (!kernelFunc->getAttrOfType( + if (!kernelFunc.getAttrOfType( GPUDialect::getKernelFuncAttrName())) { return emitError("kernel function is missing the '") << GPUDialect::getKernelFuncAttrName() << "' attribute"; } - unsigned numKernelFuncArgs = kernelFunc->getNumArguments(); + unsigned numKernelFuncArgs = kernelFunc.getNumArguments(); if (getNumKernelOperands() != numKernelFuncArgs) { return emitOpError("got ") << getNumKernelOperands() << " kernel operands but expected " << numKernelFuncArgs; } - auto functionType = kernelFunc->getType(); + auto functionType = kernelFunc.getType(); for (unsigned i = 0; i < numKernelFuncArgs; ++i) { if (getKernelOperand(i)->getType() != functionType.getInput(i)) { return emitOpError("type of function argument ") diff --git a/mlir/lib/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/GPU/Transforms/KernelOutlining.cpp index 46363f06f72..f93febcf5da 100644 --- a/mlir/lib/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/GPU/Transforms/KernelOutlining.cpp @@ -40,7 +40,7 @@ static void createForAllDimensions(OpBuilder &builder, Location loc, // Add operations generating block/thread ids and gird/block dimensions at the // beginning of `kernelFunc` and replace uses of the respective function args. -static void injectGpuIndexOperations(Location loc, Function &kernelFunc) { +static void injectGpuIndexOperations(Location loc, Function kernelFunc) { OpBuilder OpBuilder(kernelFunc.getBody()); SmallVector indexOps; createForAllDimensions(OpBuilder, loc, indexOps); @@ -58,20 +58,20 @@ static void injectGpuIndexOperations(Location loc, Function &kernelFunc) { // Outline the `gpu.launch` operation body into a kernel function. Replace // `gpu.return` operations by `std.return` in the generated functions. -static Function *outlineKernelFunc(gpu::LaunchOp launchOp) { +static Function outlineKernelFunc(gpu::LaunchOp launchOp) { Location loc = launchOp.getLoc(); SmallVector kernelOperandTypes(launchOp.getKernelOperandTypes()); FunctionType type = FunctionType::get(kernelOperandTypes, {}, launchOp.getContext()); std::string kernelFuncName = - Twine(launchOp.getOperation()->getFunction()->getName(), "_kernel").str(); - Function *outlinedFunc = new mlir::Function(loc, kernelFuncName, type); - outlinedFunc->getBody().takeBody(launchOp.getBody()); + Twine(launchOp.getOperation()->getFunction().getName(), "_kernel").str(); + Function outlinedFunc = Function::create(loc, kernelFuncName, type); + outlinedFunc.getBody().takeBody(launchOp.getBody()); Builder builder(launchOp.getContext()); - outlinedFunc->setAttr(gpu::GPUDialect::getKernelFuncAttrName(), - builder.getUnitAttr()); - injectGpuIndexOperations(loc, *outlinedFunc); - outlinedFunc->walk([](mlir::gpu::Return op) { + outlinedFunc.setAttr(gpu::GPUDialect::getKernelFuncAttrName(), + builder.getUnitAttr()); + injectGpuIndexOperations(loc, outlinedFunc); + outlinedFunc.walk([](mlir::gpu::Return op) { OpBuilder replacer(op); replacer.create(op.getLoc()); op.erase(); @@ -82,12 +82,12 @@ static Function *outlineKernelFunc(gpu::LaunchOp launchOp) { // Replace `gpu.launch` operations with an `gpu.launch_func` operation launching // `kernelFunc`. static void convertToLaunchFuncOp(gpu::LaunchOp &launchOp, - Function &kernelFunc) { + Function kernelFunc) { OpBuilder builder(launchOp); SmallVector kernelOperandValues( launchOp.getKernelOperandValues()); builder.create( - launchOp.getLoc(), &kernelFunc, launchOp.getGridSizeOperandValues(), + launchOp.getLoc(), kernelFunc, launchOp.getGridSizeOperandValues(), launchOp.getBlockSizeOperandValues(), kernelOperandValues); launchOp.erase(); } @@ -98,11 +98,11 @@ class GpuKernelOutliningPass : public ModulePass { public: void runOnModule() override { ModuleManager moduleManager(&getModule()); - for (auto &func : getModule()) { + for (auto func : getModule()) { func.walk([&](mlir::gpu::LaunchOp op) { - Function *outlinedFunc = outlineKernelFunc(op); + Function outlinedFunc = outlineKernelFunc(op); moduleManager.insert(outlinedFunc); - convertToLaunchFuncOp(op, *outlinedFunc); + convertToLaunchFuncOp(op, outlinedFunc); }); } } diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 8e3d5788bb1..346d35af231 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -306,7 +306,7 @@ void ModuleState::initialize(Module *module) { initializeSymbolAliases(); // Walk the module and visit each operation. - for (auto &fn : *module) { + for (auto fn : *module) { visitType(fn.getType()); for (auto attr : fn.getAttrs()) ModuleState::visitAttribute(attr.second); @@ -342,7 +342,7 @@ public: void printAttribute(Attribute attr, bool mayElideType = false); void printType(Type type); - void print(Function *fn); + void print(Function fn); void printLocation(LocationAttr loc); void printAffineMap(AffineMap map); @@ -460,8 +460,8 @@ void ModulePrinter::print(Module *module) { state.printTypeAliases(os); // Print the module. - for (auto &fn : *module) - print(&fn); + for (auto fn : *module) + print(fn); } /// Print a floating point value in a way that the parser will be able to @@ -1186,7 +1186,7 @@ namespace { // CFG and ML functions. class FunctionPrinter : public ModulePrinter, private OpAsmPrinter { public: - FunctionPrinter(Function *function, ModulePrinter &other); + FunctionPrinter(Function function, ModulePrinter &other); // Prints the function as a whole. void print(); @@ -1275,7 +1275,7 @@ protected: void printValueID(Value *value, bool printResultNo = true) const; private: - Function *function; + Function function; /// This is the value ID for each SSA value in the current function. If this /// returns ~0, then the valueID has an entry in valueNames. @@ -1305,10 +1305,10 @@ private: }; } // end anonymous namespace -FunctionPrinter::FunctionPrinter(Function *function, ModulePrinter &other) +FunctionPrinter::FunctionPrinter(Function function, ModulePrinter &other) : ModulePrinter(other), function(function) { - for (auto &block : *function) + for (auto &block : function) numberValuesInBlock(block); } @@ -1419,17 +1419,17 @@ void FunctionPrinter::print() { printFunctionSignature(); // Print out function attributes, if present. - auto attrs = function->getAttrs(); + auto attrs = function.getAttrs(); if (!attrs.empty()) { os << "\n attributes "; printOptionalAttrDict(attrs); } // Print the trailing location. - printTrailingLocation(function->getLoc()); + printTrailingLocation(function.getLoc()); - if (!function->empty()) { - printRegion(function->getBody(), /*printEntryBlockArgs=*/false, + if (!function.empty()) { + printRegion(function.getBody(), /*printEntryBlockArgs=*/false, /*printBlockTerminators=*/true); os << "\n"; } @@ -1437,24 +1437,24 @@ void FunctionPrinter::print() { } void FunctionPrinter::printFunctionSignature() { - os << "func @" << function->getName() << '('; + os << "func @" << function.getName() << '('; - auto fnType = function->getType(); - bool isExternal = function->isExternal(); - for (unsigned i = 0, e = function->getNumArguments(); i != e; ++i) { + auto fnType = function.getType(); + bool isExternal = function.isExternal(); + for (unsigned i = 0, e = function.getNumArguments(); i != e; ++i) { if (i > 0) os << ", "; // If this is an external function, don't print argument labels. if (!isExternal) { - printOperand(function->getArgument(i)); + printOperand(function.getArgument(i)); os << ": "; } printType(fnType.getInput(i)); // Print the attributes for this argument. - printOptionalAttrDict(function->getArgAttrs(i)); + printOptionalAttrDict(function.getArgAttrs(i)); } os << ')'; @@ -1662,7 +1662,7 @@ void FunctionPrinter::printSuccessorAndUseList(Operation *term, } // Prints function with initialized module state. -void ModulePrinter::print(Function *fn) { FunctionPrinter(fn, *this).print(); } +void ModulePrinter::print(Function fn) { FunctionPrinter(fn, *this).print(); } //===----------------------------------------------------------------------===// // print and dump methods @@ -1737,13 +1737,13 @@ void Value::print(raw_ostream &os) { void Value::dump() { print(llvm::errs()); } void Operation::print(raw_ostream &os) { - auto *function = getFunction(); + auto function = getFunction(); if (!function) { os << "<>\n"; return; } - ModuleState state(function->getContext()); + ModuleState state(function.getContext()); ModulePrinter modulePrinter(os, state); FunctionPrinter(function, modulePrinter).print(this); } @@ -1754,13 +1754,13 @@ void Operation::dump() { } void Block::print(raw_ostream &os) { - auto *function = getFunction(); + auto function = getFunction(); if (!function) { os << "<>\n"; return; } - ModuleState state(function->getContext()); + ModuleState state(function.getContext()); ModulePrinter modulePrinter(os, state); FunctionPrinter(function, modulePrinter).print(this); } @@ -1773,14 +1773,14 @@ void Block::printAsOperand(raw_ostream &os, bool printType) { os << "<>\n"; return; } - ModuleState state(getFunction()->getContext()); + ModuleState state(getFunction().getContext()); ModulePrinter modulePrinter(os, state); FunctionPrinter(getFunction(), modulePrinter).printBlockName(this); } void Function::print(raw_ostream &os) { ModuleState state(getContext()); - ModulePrinter(os, state).print(this); + ModulePrinter(os, state).print(*this); } void Function::dump() { print(llvm::errs()); } diff --git a/mlir/lib/IR/Attributes.cpp b/mlir/lib/IR/Attributes.cpp index 01f9a060bd9..9cbba0fe429 100644 --- a/mlir/lib/IR/Attributes.cpp +++ b/mlir/lib/IR/Attributes.cpp @@ -249,11 +249,6 @@ FloatAttr::verifyConstructionInvariants(llvm::Optional loc, // FunctionAttr //===----------------------------------------------------------------------===// -FunctionAttr FunctionAttr::get(Function *value) { - assert(value && "Cannot get FunctionAttr for a null function"); - return get(value->getName(), value->getContext()); -} - FunctionAttr FunctionAttr::get(StringRef value, MLIRContext *ctx) { return Base::get(ctx, StandardAttributes::Function, value, NoneType::get(ctx)); diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp index e7616f6d7d0..134f6e468a0 100644 --- a/mlir/lib/IR/Block.cpp +++ b/mlir/lib/IR/Block.cpp @@ -50,7 +50,7 @@ Operation *Block::getContainingOp() { return getParent() ? getParent()->getContainingOp() : nullptr; } -Function *Block::getFunction() { +Function Block::getFunction() { Block *block = this; while (auto *op = block->getContainingOp()) { block = op->getBlock(); diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp index 9b30205abdb..89df64260d3 100644 --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -177,8 +177,8 @@ IntegerSetAttr Builder::getIntegerSetAttr(IntegerSet set) { TypeAttr Builder::getTypeAttr(Type type) { return TypeAttr::get(type); } -FunctionAttr Builder::getFunctionAttr(Function *value) { - return FunctionAttr::get(value); +FunctionAttr Builder::getFunctionAttr(Function value) { + return getFunctionAttr(value.getName()); } FunctionAttr Builder::getFunctionAttr(StringRef value) { return FunctionAttr::get(value, getContext()); diff --git a/mlir/lib/IR/Dialect.cpp b/mlir/lib/IR/Dialect.cpp index 4547452eb55..e38b95ff0f7 100644 --- a/mlir/lib/IR/Dialect.cpp +++ b/mlir/lib/IR/Dialect.cpp @@ -18,6 +18,7 @@ #include "mlir/IR/Dialect.h" #include "mlir/IR/Diagnostics.h" #include "mlir/IR/DialectHooks.h" +#include "mlir/IR/Function.h" #include "mlir/IR/MLIRContext.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/ManagedStatic.h" @@ -68,6 +69,20 @@ Dialect::Dialect(StringRef name, MLIRContext *context) Dialect::~Dialect() {} +/// Verify an attribute from this dialect on the given function. Returns +/// failure if the verification failed, success otherwise. +LogicalResult Dialect::verifyFunctionAttribute(Function, NamedAttribute) { + return success(); +} + +/// Verify an attribute from this dialect on the argument at 'argIndex' for +/// the given function. Returns failure if the verification failed, success +/// otherwise. +LogicalResult Dialect::verifyFunctionArgAttribute(Function, unsigned argIndex, + NamedAttribute) { + return success(); +} + /// Parse an attribute registered to this dialect. Attribute Dialect::parseAttribute(StringRef attrData, Location loc) const { emitError(loc) << "dialect '" << getNamespace() diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp index 7d17ed1d705..f8835f02c26 100644 --- a/mlir/lib/IR/Function.cpp +++ b/mlir/lib/IR/Function.cpp @@ -27,45 +27,50 @@ #include "llvm/ADT/Twine.h" using namespace mlir; +using namespace mlir::detail; -Function::Function(Location location, StringRef name, FunctionType type, - ArrayRef attrs) +FunctionStorage::FunctionStorage(Location location, StringRef name, + FunctionType type, + ArrayRef attrs) : name(Identifier::get(name, type.getContext())), location(location), type(type), attrs(attrs), argAttrs(type.getNumInputs()), body(this) {} -Function::Function(Location location, StringRef name, FunctionType type, - ArrayRef attrs, - ArrayRef argAttrs) +FunctionStorage::FunctionStorage(Location location, StringRef name, + FunctionType type, + ArrayRef attrs, + ArrayRef argAttrs) : name(Identifier::get(name, type.getContext())), location(location), type(type), attrs(attrs), argAttrs(argAttrs), body(this) {} MLIRContext *Function::getContext() { return getType().getContext(); } -Module *llvm::ilist_traits::getContainingModule() { +Module *llvm::ilist_traits::getContainingModule() { size_t Offset( size_t(&((Module *)nullptr->*Module::getSublistAccess(nullptr)))); - iplist *Anchor(static_cast *>(this)); + iplist *Anchor(static_cast *>(this)); return reinterpret_cast(reinterpret_cast(Anchor) - Offset); } /// This is a trait method invoked when a Function is added to a Module. We /// keep the module pointer and module symbol table up to date. -void llvm::ilist_traits::addNodeToList(Function *function) { - assert(!function->getModule() && "already in a module!"); +void llvm::ilist_traits::addNodeToList( + FunctionStorage *function) { + assert(!function->module && "already in a module!"); function->module = getContainingModule(); } /// This is a trait method invoked when a Function is removed from a Module. /// We keep the module pointer up to date. -void llvm::ilist_traits::removeNodeFromList(Function *function) { +void llvm::ilist_traits::removeNodeFromList( + FunctionStorage *function) { assert(function->module && "not already in a module!"); function->module = nullptr; } /// This is a trait method invoked when an operation is moved from one block /// to another. We keep the block pointer up to date. -void llvm::ilist_traits::transferNodesFromList( - ilist_traits &otherList, function_iterator first, +void llvm::ilist_traits::transferNodesFromList( + ilist_traits &otherList, function_iterator first, function_iterator last) { // If we are transferring functions within the same module, the Module // pointer doesn't need to be updated. @@ -82,8 +87,10 @@ void llvm::ilist_traits::transferNodesFromList( /// Unlink this function from its Module and delete it. void Function::erase() { - assert(getModule() && "Function has no parent"); - getModule()->getFunctions().erase(this); + if (auto *module = getModule()) + getModule()->functions.erase(impl); + else + delete impl; } /// Emit an error about fatal conditions with this function, reporting up to @@ -111,10 +118,10 @@ InFlightDiagnostic Function::emitRemark(const Twine &message) { /// Clone the internal blocks from this function into dest and all attributes /// from this function to dest. -void Function::cloneInto(Function *dest, BlockAndValueMapping &mapper) { +void Function::cloneInto(Function dest, BlockAndValueMapping &mapper) { // Add the attributes of this function to dest. llvm::MapVector newAttrs; - for (auto &attr : dest->getAttrs()) + for (auto &attr : dest.getAttrs()) newAttrs.insert(attr); for (auto &attr : getAttrs()) { auto insertPair = newAttrs.insert(attr); @@ -125,10 +132,10 @@ void Function::cloneInto(Function *dest, BlockAndValueMapping &mapper) { assert((insertPair.second || insertPair.first->second == attr.second) && "the two functions have incompatible attributes"); } - dest->setAttrs(newAttrs.takeVector()); + dest.setAttrs(newAttrs.takeVector()); // Clone the body. - body.cloneInto(&dest->body, mapper); + impl->body.cloneInto(&dest.impl->body, mapper); } /// Create a deep copy of this function and all of its blocks, remapping @@ -136,8 +143,8 @@ void Function::cloneInto(Function *dest, BlockAndValueMapping &mapper) { /// provided (leaving them alone if no entry is present). Replaces references /// to cloned sub-values with the corresponding value that is copied, and adds /// those mappings to the mapper. -Function *Function::clone(BlockAndValueMapping &mapper) { - FunctionType newType = type; +Function Function::clone(BlockAndValueMapping &mapper) { + FunctionType newType = impl->type; // If the function has a body, then the user might be deleting arguments to // the function by specifying them in the mapper. If so, we don't add the @@ -147,23 +154,23 @@ Function *Function::clone(BlockAndValueMapping &mapper) { SmallVector inputTypes; for (unsigned i = 0, e = getNumArguments(); i != e; ++i) if (!mapper.contains(getArgument(i))) - inputTypes.push_back(type.getInput(i)); - newType = FunctionType::get(inputTypes, type.getResults(), getContext()); + inputTypes.push_back(newType.getInput(i)); + newType = FunctionType::get(inputTypes, newType.getResults(), getContext()); } // Create the new function. - Function *newFunc = new Function(getLoc(), getName(), newType); + Function newFunc = Function::create(getLoc(), getName(), newType); /// Set the argument attributes for arguments that aren't being replaced. for (unsigned i = 0, e = getNumArguments(), destI = 0; i != e; ++i) if (isExternalFn || !mapper.contains(getArgument(i))) - newFunc->setArgAttrs(destI++, getArgAttrs(i)); + newFunc.setArgAttrs(destI++, getArgAttrs(i)); /// Clone the current function into the new one and return it. cloneInto(newFunc, mapper); return newFunc; } -Function *Function::clone() { +Function Function::clone() { BlockAndValueMapping mapper; return clone(mapper); } @@ -178,7 +185,7 @@ void Function::addEntryBlock() { assert(empty() && "function already has an entry block"); auto *entry = new Block(); push_back(entry); - entry->addArguments(type.getInputs()); + entry->addArguments(impl->type.getInputs()); } void Function::walk(const std::function &callback) { diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp index 83171f12d1d..f953cd27a56 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -281,7 +281,7 @@ Operation *Operation::getParentOp() { return block ? block->getContainingOp() : nullptr; } -Function *Operation::getFunction() { +Function Operation::getFunction() { return block ? block->getFunction() : nullptr; } @@ -861,12 +861,13 @@ static LogicalResult verifyBBArguments(Operation::operand_range operands, } static LogicalResult verifyTerminatorSuccessors(Operation *op) { + auto *parent = op->getContainingRegion(); + // Verify that the operands lines up with the BB arguments in the successor. - Function *fn = op->getFunction(); for (unsigned i = 0, e = op->getNumSuccessors(); i != e; ++i) { auto *succ = op->getSuccessor(i); - if (succ->getFunction() != fn) - return op->emitError("reference to block defined in another function"); + if (succ->getParent() != parent) + return op->emitError("reference to block defined in another region"); if (failed(verifyBBArguments(op->getSuccessorOperands(i), succ, op))) return failure(); } diff --git a/mlir/lib/IR/Region.cpp b/mlir/lib/IR/Region.cpp index 992d9112beb..74c71b7aeac 100644 --- a/mlir/lib/IR/Region.cpp +++ b/mlir/lib/IR/Region.cpp @@ -21,7 +21,7 @@ #include "mlir/IR/Operation.h" using namespace mlir; -Region::Region(Function *container) : container(container) {} +Region::Region(Function container) : container(container.impl) {} Region::Region(Operation *container) : container(container) {} @@ -38,7 +38,7 @@ MLIRContext *Region::getContext() { assert(!container.isNull() && "region is not attached to a container"); if (auto *inst = getContainingOp()) return inst->getContext(); - return getContainingFunction()->getContext(); + return getContainingFunction().getContext(); } /// Return a location for this region. This is the location attached to the @@ -47,7 +47,7 @@ Location Region::getLoc() { assert(!container.isNull() && "region is not attached to a container"); if (auto *inst = getContainingOp()) return inst->getLoc(); - return getContainingFunction()->getLoc(); + return getContainingFunction().getLoc(); } Region *Region::getContainingRegion() { @@ -60,8 +60,8 @@ Operation *Region::getContainingOp() { return container.dyn_cast(); } -Function *Region::getContainingFunction() { - return container.dyn_cast(); +Function Region::getContainingFunction() { + return container.dyn_cast(); } bool Region::isProperAncestor(Region *other) { diff --git a/mlir/lib/IR/SymbolTable.cpp b/mlir/lib/IR/SymbolTable.cpp index a0819a78fc1..dafbd48f513 100644 --- a/mlir/lib/IR/SymbolTable.cpp +++ b/mlir/lib/IR/SymbolTable.cpp @@ -22,8 +22,8 @@ using namespace mlir; /// Build a symbol table with the symbols within the given module. SymbolTable::SymbolTable(Module *module) : context(module->getContext()) { - for (auto &func : *module) { - auto inserted = symbolTable.insert({func.getName(), &func}); + for (auto func : *module) { + auto inserted = symbolTable.insert({func.getName(), func}); (void)inserted; assert(inserted.second && "expected module to contain uniquely named functions"); @@ -32,34 +32,34 @@ SymbolTable::SymbolTable(Module *module) : context(module->getContext()) { /// Look up a symbol with the specified name, returning null if no such name /// exists. Names never include the @ on them. -Function *SymbolTable::lookup(StringRef name) const { +Function SymbolTable::lookup(StringRef name) const { return lookup(Identifier::get(name, context)); } /// Look up a symbol with the specified name, returning null if no such name /// exists. Names never include the @ on them. -Function *SymbolTable::lookup(Identifier name) const { +Function SymbolTable::lookup(Identifier name) const { return symbolTable.lookup(name); } /// Erase the given symbol from the table. -void SymbolTable::erase(Function *symbol) { - auto it = symbolTable.find(symbol->getName()); +void SymbolTable::erase(Function symbol) { + auto it = symbolTable.find(symbol.getName()); if (it != symbolTable.end() && it->second == symbol) symbolTable.erase(it); } /// Insert a new symbol into the table, and rename it as necessary to avoid /// collisions. -void SymbolTable::insert(Function *symbol) { +void SymbolTable::insert(Function symbol) { // Add this symbol to the symbol table, uniquing the name if a conflict is // detected. - if (symbolTable.insert({symbol->getName(), symbol}).second) + if (symbolTable.insert({symbol.getName(), symbol}).second) return; // If a conflict was detected, then the function will not have been added to // the symbol table. Try suffixes until we get to a unique name that works. - SmallString<128> nameBuffer(symbol->getName()); + SmallString<128> nameBuffer(symbol.getName()); unsigned originalLength = nameBuffer.size(); // Iteratively try suffixes until we find one that isn't used. We use a @@ -68,6 +68,6 @@ void SymbolTable::insert(Function *symbol) { nameBuffer.resize(originalLength); nameBuffer += '_'; nameBuffer += std::to_string(uniquingCounter++); - symbol->setName(Identifier::get(nameBuffer, context)); - } while (!symbolTable.insert({symbol->getName(), symbol}).second); + symbol.setName(Identifier::get(nameBuffer, context)); + } while (!symbolTable.insert({symbol.getName(), symbol}).second); } diff --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp index 073c3b369c6..65a98f7ee59 100644 --- a/mlir/lib/IR/Value.cpp +++ b/mlir/lib/IR/Value.cpp @@ -30,7 +30,7 @@ Operation *Value::getDefiningOp() { } /// Return the function that this Value is defined in. -Function *Value::getFunction() { +Function Value::getFunction() { switch (getKind()) { case Value::Kind::BlockArgument: return cast(this)->getFunction(); @@ -84,7 +84,7 @@ void IRObjectWithUseList::dropAllUses() { //===----------------------------------------------------------------------===// /// Return the function that this argument is defined in. -Function *BlockArgument::getFunction() { +Function BlockArgument::getFunction() { if (auto *owner = getOwner()) return owner->getFunction(); return nullptr; @@ -92,6 +92,6 @@ Function *BlockArgument::getFunction() { /// Returns if the current argument is a function argument. bool BlockArgument::isFunctionArgument() { - auto *containingFn = getFunction(); - return containingFn && &containingFn->front() == getOwner(); + auto containingFn = getFunction(); + return containingFn && &containingFn.front() == getOwner(); } diff --git a/mlir/lib/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/LLVMIR/IR/LLVMDialect.cpp index 0d3a5ca2756..0dbf63a3ce7 100644 --- a/mlir/lib/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/LLVMIR/IR/LLVMDialect.cpp @@ -816,12 +816,12 @@ void LLVMDialect::printType(Type type, raw_ostream &os) const { } /// Verify LLVMIR function argument attributes. -LogicalResult LLVMDialect::verifyFunctionArgAttribute(Function *func, +LogicalResult LLVMDialect::verifyFunctionArgAttribute(Function func, unsigned argIdx, NamedAttribute argAttr) { // Check that llvm.noalias is a boolean attribute. if (argAttr.first == "llvm.noalias" && !argAttr.second.isa()) - return func->emitError() + return func.emitError() << "llvm.noalias argument attribute of non boolean type"; return success(); } diff --git a/mlir/lib/Linalg/Transforms/Fusion.cpp b/mlir/lib/Linalg/Transforms/Fusion.cpp index 7ddb7b0c19f..5761cc637b7 100644 --- a/mlir/lib/Linalg/Transforms/Fusion.cpp +++ b/mlir/lib/Linalg/Transforms/Fusion.cpp @@ -209,7 +209,7 @@ static bool isStructurallyFusableProducer(LinalgOp producer, Value *readView, return true; } -static void fuseLinalgOps(Function &f, ArrayRef tileSizes) { +static void fuseLinalgOps(Function f, ArrayRef tileSizes) { OperationFolder state; DenseSet eraseSet; diff --git a/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp b/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp index a8099aaff99..5fe4f07613a 100644 --- a/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp +++ b/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp @@ -170,12 +170,13 @@ public: LLVM::LLVMType::getInt8Ty(lowering.getDialect()).getPointerTo(); auto int64Ty = lowering.convertType(rewriter.getIntegerType(64)); // Insert the `malloc` declaration if it is not already present. - auto *module = op->getFunction()->getModule(); - Function *mallocFunc = module->getNamedFunction("malloc"); + auto *module = op->getFunction().getModule(); + Function mallocFunc = module->getNamedFunction("malloc"); if (!mallocFunc) { auto mallocType = rewriter.getFunctionType(int64Ty, voidPtrTy); - mallocFunc = new Function(rewriter.getUnknownLoc(), "malloc", mallocType); - module->getFunctions().push_back(mallocFunc); + mallocFunc = + Function::create(rewriter.getUnknownLoc(), "malloc", mallocType); + module->push_back(mallocFunc); } // Get MLIR types for injecting element pointer. @@ -230,12 +231,12 @@ public: auto voidPtrTy = LLVM::LLVMType::getInt8Ty(lowering.getDialect()).getPointerTo(); // Insert the `free` declaration if it is not already present. - auto *module = op->getFunction()->getModule(); - Function *freeFunc = module->getNamedFunction("free"); + auto *module = op->getFunction().getModule(); + Function freeFunc = module->getNamedFunction("free"); if (!freeFunc) { auto freeType = rewriter.getFunctionType(voidPtrTy, {}); - freeFunc = new Function(rewriter.getUnknownLoc(), "free", freeType); - module->getFunctions().push_back(freeFunc); + freeFunc = Function::create(rewriter.getUnknownLoc(), "free", freeType); + module->push_back(freeFunc); } // Get MLIR types for extracting element pointer. @@ -572,37 +573,37 @@ public: // Create a function definition which takes as argument pointers to the input // types and returns pointers to the output types. -static Function *getLLVMLibraryCallImplDefinition(Function *libFn) { - auto implFnName = (libFn->getName().str() + "_impl"); - auto module = libFn->getModule(); - if (auto *f = module->getNamedFunction(implFnName)) { +static Function getLLVMLibraryCallImplDefinition(Function libFn) { + auto implFnName = (libFn.getName().str() + "_impl"); + auto module = libFn.getModule(); + if (auto f = module->getNamedFunction(implFnName)) { return f; } SmallVector fnArgTypes; - for (auto t : libFn->getType().getInputs()) { + for (auto t : libFn.getType().getInputs()) { assert(t.isa() && "Expected LLVM Type for argument while generating library Call " "Implementation Definition"); fnArgTypes.push_back(t.cast().getPointerTo()); } - auto implFnType = FunctionType::get(fnArgTypes, {}, libFn->getContext()); + auto implFnType = FunctionType::get(fnArgTypes, {}, libFn.getContext()); // Insert the implementation function definition. - auto implFnDefn = new Function(libFn->getLoc(), implFnName, implFnType); - module->getFunctions().push_back(implFnDefn); + auto implFnDefn = Function::create(libFn.getLoc(), implFnName, implFnType); + module->push_back(implFnDefn); return implFnDefn; } // Get function definition for the LinalgOp. If it doesn't exist, insert a // definition. template -static Function *getLLVMLibraryCallDeclaration(Operation *op, - LLVMTypeConverter &lowering, - PatternRewriter &rewriter) { +static Function getLLVMLibraryCallDeclaration(Operation *op, + LLVMTypeConverter &lowering, + PatternRewriter &rewriter) { assert(isa(op)); auto fnName = LinalgOp::getLibraryCallName(); - auto module = op->getFunction()->getModule(); - if (auto *f = module->getNamedFunction(fnName)) { + auto module = op->getFunction().getModule(); + if (auto f = module->getNamedFunction(fnName)) { return f; } @@ -618,29 +619,29 @@ static Function *getLLVMLibraryCallDeclaration(Operation *op, "Library call for linalg operation can be generated only for ops that " "have void return types"); auto libFnType = FunctionType::get(inputTypes, {}, op->getContext()); - auto libFn = new Function(op->getLoc(), fnName, libFnType); - module->getFunctions().push_back(libFn); + auto libFn = Function::create(op->getLoc(), fnName, libFnType); + module->push_back(libFn); // Return after creating the function definition. The body will be created // later. return libFn; } -static void getLLVMLibraryCallDefinition(Function *fn, +static void getLLVMLibraryCallDefinition(Function fn, LLVMTypeConverter &lowering) { // Generate the implementation function definition. auto implFn = getLLVMLibraryCallImplDefinition(fn); // Generate the function body. - fn->addEntryBlock(); + fn.addEntryBlock(); - OpBuilder builder(fn->getBody()); - edsc::ScopedContext scope(builder, fn->getLoc()); + OpBuilder builder(fn.getBody()); + edsc::ScopedContext scope(builder, fn.getLoc()); SmallVector implFnArgs; // Create a constant 1. auto one = constant(LLVMType::getInt64Ty(lowering.getDialect()), - IntegerAttr::get(IndexType::get(fn->getContext()), 1)); - for (auto arg : fn->getArguments()) { + IntegerAttr::get(IndexType::get(fn.getContext()), 1)); + for (auto arg : fn.getArguments()) { // Allocate a stack for storing the argument value. The stack is passed to // the implementation function. auto alloca = @@ -665,17 +666,17 @@ public: return convertLinalgType(t, *this); } - void addLibraryFnDeclaration(Function *fn) { + void addLibraryFnDeclaration(Function fn) { libraryFnDeclarations.push_back(fn); } - ArrayRef getLibraryFnDeclarations() { + ArrayRef getLibraryFnDeclarations() { return libraryFnDeclarations; } private: /// List of library functions declarations needed during dialect conversion - SmallVector libraryFnDeclarations; + SmallVector libraryFnDeclarations; }; } // end anonymous namespace @@ -692,7 +693,7 @@ public: PatternMatchResult matchAndRewrite(Operation *op, ArrayRef operands, PatternRewriter &rewriter) const override { // Only emit library call declaration. Fill in the body later. - auto *f = getLLVMLibraryCallDeclaration(op, lowering, rewriter); + auto f = getLLVMLibraryCallDeclaration(op, lowering, rewriter); static_cast(lowering).addLibraryFnDeclaration(f); auto fAttr = rewriter.getFunctionAttr(f); @@ -803,7 +804,7 @@ static void lowerLinalgForToCFG(Function &f) { void LowerLinalgToLLVMPass::runOnModule() { auto &module = getModule(); - for (auto &f : module.getFunctions()) { + for (auto f : module.getFunctions()) { lowerLinalgSubViewOps(f); lowerLinalgForToCFG(f); if (failed(lowerAffineConstructs(f))) diff --git a/mlir/lib/Linalg/Transforms/LowerToLoops.cpp b/mlir/lib/Linalg/Transforms/LowerToLoops.cpp index d31ba5bf22d..2e616c35f1d 100644 --- a/mlir/lib/Linalg/Transforms/LowerToLoops.cpp +++ b/mlir/lib/Linalg/Transforms/LowerToLoops.cpp @@ -104,9 +104,8 @@ struct LowerLinalgToLoopsPass : public FunctionPass { } // namespace void LowerLinalgToLoopsPass::runOnFunction() { - auto &f = getFunction(); OperationFolder state; - f.walk([&state](LinalgOp linalgOp) { + getFunction().walk([&state](LinalgOp linalgOp) { emitLinalgOpAsLoops(linalgOp, state); linalgOp.getOperation()->erase(); }); diff --git a/mlir/lib/Linalg/Transforms/Tiling.cpp b/mlir/lib/Linalg/Transforms/Tiling.cpp index c63e1cf197d..2f752b2b637 100644 --- a/mlir/lib/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Linalg/Transforms/Tiling.cpp @@ -259,7 +259,7 @@ mlir::linalg::tileLinalgOp(LinalgOp op, ArrayRef tileSizes, return tileLinalgOp(op, tileSizeValues, state); } -static void tileLinalgOps(Function &f, ArrayRef tileSizes) { +static void tileLinalgOps(Function f, ArrayRef tileSizes) { OperationFolder state; f.walk([tileSizes, &state](LinalgOp op) { auto opLoopsPair = tileLinalgOp(op, tileSizes, state); diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index 44f05963727..4af2f093daf 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -254,7 +254,7 @@ public: /// trailing-location ::= location? /// template - ParseResult parseOptionalTrailingLocation(Owner *owner) { + ParseResult parseOptionalTrailingLocation(Owner &owner) { // If there is a 'loc' we parse a trailing location. if (!getToken().is(Token::kw_loc)) return success(); @@ -263,7 +263,7 @@ public: LocationAttr directLoc; if (parseLocation(directLoc)) return failure(); - owner->setLoc(directLoc); + owner.setLoc(directLoc); return success(); } @@ -2472,8 +2472,8 @@ namespace { /// operations. class OperationParser : public Parser { public: - OperationParser(ParserState &state, Function *function) - : Parser(state), function(function), opBuilder(function->getBody()) {} + OperationParser(ParserState &state, Function function) + : Parser(state), function(function), opBuilder(function.getBody()) {} ~OperationParser(); @@ -2588,7 +2588,7 @@ public: Block *defineBlockNamed(StringRef name, SMLoc loc, Block *existing); private: - Function *function; + Function function; /// Returns the info for a block at the current scope for the given name. std::pair &getBlockInfoByName(StringRef name) { @@ -2690,7 +2690,7 @@ ParseResult OperationParser::popSSANameScope() { for (auto entry : forwardRefInCurrentScope) { errors.push_back({entry.second.getPointer(), entry.first}); // Add this block to the top-level region to allow for automatic cleanup. - function->push_back(entry.first); + function.push_back(entry.first); } llvm::array_pod_sort(errors.begin(), errors.end()); @@ -2984,7 +2984,7 @@ ParseResult OperationParser::parseOperation() { } // Try to parse the optional trailing location. - if (parseOptionalTrailingLocation(op)) + if (parseOptionalTrailingLocation(*op)) return failure(); return success(); @@ -4049,17 +4049,17 @@ ParseResult ModuleParser::parseFunc(Module *module) { } // Okay, the function signature was parsed correctly, create the function now. - auto *function = - new Function(getEncodedSourceLocation(loc), name, type, attrs); - module->getFunctions().push_back(function); + auto function = + Function::create(getEncodedSourceLocation(loc), name, type, attrs); + module->push_back(function); // Parse an optional trailing location. if (parseOptionalTrailingLocation(function)) return failure(); // Add the attributes to the function arguments. - for (unsigned i = 0, e = function->getNumArguments(); i != e; ++i) - function->setArgAttrs(i, argAttrs[i]); + for (unsigned i = 0, e = function.getNumArguments(); i != e; ++i) + function.setArgAttrs(i, argAttrs[i]); // External functions have no body. if (getToken().isNot(Token::l_brace)) @@ -4076,11 +4076,11 @@ ParseResult ModuleParser::parseFunc(Module *module) { // Parse the function body. auto parser = OperationParser(getState(), function); - if (parser.parseRegion(function->getBody(), entryArgs)) + if (parser.parseRegion(function.getBody(), entryArgs)) return failure(); // Verify that a valid function body was parsed. - if (function->empty()) + if (function.empty()) return emitError(braceLoc, "function must have a body"); return parser.finalize(braceLoc); diff --git a/mlir/lib/Pass/IRPrinting.cpp b/mlir/lib/Pass/IRPrinting.cpp index 868d492e094..057f2655207 100644 --- a/mlir/lib/Pass/IRPrinting.cpp +++ b/mlir/lib/Pass/IRPrinting.cpp @@ -61,12 +61,12 @@ private: static void printIR(const llvm::Any &ir, bool printModuleScope, raw_ostream &out) { // Check for printing at module scope. - if (printModuleScope && llvm::any_isa(ir)) { - Function *function = llvm::any_cast(ir); + if (printModuleScope && llvm::any_isa(ir)) { + Function function = llvm::any_cast(ir); // Print the function name and a newline before the Module. - out << " (function: " << function->getName() << ")\n"; - function->getModule()->print(out); + out << " (function: " << function.getName() << ")\n"; + function.getModule()->print(out); return; } @@ -74,8 +74,8 @@ static void printIR(const llvm::Any &ir, bool printModuleScope, out << "\n"; // Print the given function. - if (llvm::any_isa(ir)) { - llvm::any_cast(ir)->print(out); + if (llvm::any_isa(ir)) { + llvm::any_cast(ir).print(out); return; } diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp index 2f605b6690b..27ec74c23c2 100644 --- a/mlir/lib/Pass/Pass.cpp +++ b/mlir/lib/Pass/Pass.cpp @@ -46,8 +46,7 @@ static llvm::cl::opt void Pass::anchor() {} /// Forwarding function to execute this pass. -LogicalResult FunctionPassBase::run(Function *fn, - FunctionAnalysisManager &fam) { +LogicalResult FunctionPassBase::run(Function fn, FunctionAnalysisManager &fam) { // Initialize the pass state. passState.emplace(fn, fam); @@ -115,7 +114,7 @@ FunctionPassExecutor::FunctionPassExecutor(const FunctionPassExecutor &rhs) } /// Run all of the passes in this manager over the current function. -LogicalResult detail::FunctionPassExecutor::run(Function *function, +LogicalResult detail::FunctionPassExecutor::run(Function function, FunctionAnalysisManager &fam) { // Run each of the held passes. for (auto &pass : passes) @@ -141,7 +140,7 @@ LogicalResult detail::ModulePassExecutor::run(Module *module, /// Utility to run the given function and analysis manager on a provided /// function pass executor. static LogicalResult runFunctionPipeline(FunctionPassExecutor &fpe, - Function *func, + Function func, FunctionAnalysisManager &fam) { // Run the function pipeline over the provided function. auto result = fpe.run(func, fam); @@ -158,14 +157,14 @@ static LogicalResult runFunctionPipeline(FunctionPassExecutor &fpe, /// module. void ModuleToFunctionPassAdaptor::runOnModule() { ModuleAnalysisManager &mam = getAnalysisManager(); - for (auto &func : getModule()) { + for (auto func : getModule()) { // Skip external functions. if (func.isExternal()) continue; // Run the held function pipeline over the current function. - auto fam = mam.slice(&func); - if (failed(runFunctionPipeline(fpe, &func, fam))) + auto fam = mam.slice(func); + if (failed(runFunctionPipeline(fpe, func, fam))) return signalPassFailure(); // Clear out any computed function analyses. These analyses won't be used @@ -189,10 +188,10 @@ void ModuleToFunctionPassAdaptorParallel::runOnModule() { // Run a prepass over the module to collect the functions to execute a over. // This ensures that an analysis manager exists for each function, as well as // providing a queue of functions to execute over. - std::vector> funcAMPairs; - for (auto &func : getModule()) + std::vector> funcAMPairs; + for (auto func : getModule()) if (!func.isExternal()) - funcAMPairs.emplace_back(&func, mam.slice(&func)); + funcAMPairs.emplace_back(func, mam.slice(func)); // A parallel diagnostic handler that provides deterministic diagnostic // ordering. @@ -340,8 +339,8 @@ PassInstrumentor *FunctionAnalysisManager::getPassInstrumentor() const { } /// Create an analysis slice for the given child function. -FunctionAnalysisManager ModuleAnalysisManager::slice(Function *func) { - assert(func->getModule() == moduleAnalyses.getIRUnit() && +FunctionAnalysisManager ModuleAnalysisManager::slice(Function func) { + assert(func.getModule() == moduleAnalyses.getIRUnit() && "function has a different parent module"); auto it = functionAnalyses.find(func); if (it == functionAnalyses.end()) { diff --git a/mlir/lib/Pass/PassDetail.h b/mlir/lib/Pass/PassDetail.h index 46addfb8e9c..d2563fb62cd 100644 --- a/mlir/lib/Pass/PassDetail.h +++ b/mlir/lib/Pass/PassDetail.h @@ -48,7 +48,7 @@ public: FunctionPassExecutor(const FunctionPassExecutor &rhs); /// Run the executor on the given function. - LogicalResult run(Function *function, FunctionAnalysisManager &fam); + LogicalResult run(Function function, FunctionAnalysisManager &fam); /// Add a pass to the current executor. This takes ownership over the provided /// pass pointer. diff --git a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp index 375a64d8f2d..3f26bf075af 100644 --- a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp +++ b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp @@ -71,7 +71,7 @@ void AddDefaultStatsPass::runOnFunction() { void AddDefaultStatsPass::runWithConfig(SolverContext &solverContext, const TargetConfiguration &config) { - auto &func = getFunction(); + auto func = getFunction(); // Insert stats for each argument. for (auto *arg : func.getArguments()) { diff --git a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp index dec4ea90db8..169fec3b39a 100644 --- a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp +++ b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp @@ -129,7 +129,7 @@ void InferQuantizedTypesPass::runOnModule() { void InferQuantizedTypesPass::runWithConfig(SolverContext &solverContext, const TargetConfiguration &config) { CAGSlice cag(solverContext); - for (auto &f : getModule()) { + for (auto f : getModule()) { f.walk([&cag, &config](Operation *op) { config.handleOp(op, cag); }); } config.finalizeAnchors(cag); diff --git a/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp b/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp index ed3b0956a16..6b376db8516 100644 --- a/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp +++ b/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp @@ -58,7 +58,7 @@ public: void RemoveInstrumentationPass::runOnFunction() { OwningRewritePatternList patterns; - auto &func = getFunction(); + auto func = getFunction(); auto *context = &getContext(); patterns.push_back( llvm::make_unique>(context)); diff --git a/mlir/lib/SPIRV/Serialization/ConvertFromBinary.cpp b/mlir/lib/SPIRV/Serialization/ConvertFromBinary.cpp index 3add211fdd5..543b7300af0 100644 --- a/mlir/lib/SPIRV/Serialization/ConvertFromBinary.cpp +++ b/mlir/lib/SPIRV/Serialization/ConvertFromBinary.cpp @@ -36,11 +36,11 @@ using namespace mlir; // block. The created block will be terminated by `std.return`. Block *createOneBlockFunction(Builder builder, Module *module) { auto fnType = builder.getFunctionType(/*inputs=*/{}, /*results=*/{}); - auto *fn = new Function(builder.getUnknownLoc(), "spirv_module", fnType); - module->getFunctions().push_back(fn); + auto fn = Function::create(builder.getUnknownLoc(), "spirv_module", fnType); + module->push_back(fn); auto *block = new Block(); - fn->push_back(block); + fn.push_back(block); OperationState state(builder.getUnknownLoc(), ReturnOp::getOperationName()); ReturnOp::build(&builder, &state); diff --git a/mlir/lib/SPIRV/Serialization/ConvertToBinary.cpp b/mlir/lib/SPIRV/Serialization/ConvertToBinary.cpp index ebdcaf73717..33572d5adbe 100644 --- a/mlir/lib/SPIRV/Serialization/ConvertToBinary.cpp +++ b/mlir/lib/SPIRV/Serialization/ConvertToBinary.cpp @@ -45,7 +45,7 @@ LogicalResult serializeModule(Module *module, StringRef outputFilename) { // wrapping the SPIR-V ModuleOp inside a MLIR module. This should be changed // to take in the SPIR-V ModuleOp directly after module and function are // migrated to be general ops. - for (auto &fn : *module) { + for (auto fn : *module) { fn.walk([&](spirv::ModuleOp spirvModule) { if (done) { spirvModule.emitError("found more than one 'spv.module' op"); diff --git a/mlir/lib/SPIRV/Transforms/StdOpsToSPIRVConversion.cpp b/mlir/lib/SPIRV/Transforms/StdOpsToSPIRVConversion.cpp index 1a8d79c1790..1ce2b69f055 100644 --- a/mlir/lib/SPIRV/Transforms/StdOpsToSPIRVConversion.cpp +++ b/mlir/lib/SPIRV/Transforms/StdOpsToSPIRVConversion.cpp @@ -42,7 +42,7 @@ class StdOpsToSPIRVConversionPass void StdOpsToSPIRVConversionPass::runOnFunction() { OwningRewritePatternList patterns; - auto &func = getFunction(); + auto func = getFunction(); populateWithGenerated(func.getContext(), &patterns); applyPatternsGreedily(func, std::move(patterns)); diff --git a/mlir/lib/StandardOps/Ops.cpp b/mlir/lib/StandardOps/Ops.cpp index 6d5073f1c37..9fc216eef25 100644 --- a/mlir/lib/StandardOps/Ops.cpp +++ b/mlir/lib/StandardOps/Ops.cpp @@ -440,14 +440,14 @@ static LogicalResult verify(CallOp op) { auto fnAttr = op.getAttrOfType("callee"); if (!fnAttr) return op.emitOpError("requires a 'callee' function attribute"); - auto *fn = op.getOperation()->getFunction()->getModule()->getNamedFunction( + auto fn = op.getOperation()->getFunction().getModule()->getNamedFunction( fnAttr.getValue()); if (!fn) return op.emitOpError() << "'" << fnAttr.getValue() << "' does not reference a valid function"; // Verify that the operand and result types match the callee. - auto fnType = fn->getType(); + auto fnType = fn.getType(); if (fnType.getNumInputs() != op.getNumOperands()) return op.emitOpError("incorrect number of operands for callee"); @@ -1107,13 +1107,13 @@ static LogicalResult verify(ConstantOp &op) { return op.emitOpError("requires 'value' to be a function reference"); // Try to find the referenced function. - auto *fn = op.getOperation()->getFunction()->getModule()->getNamedFunction( + auto fn = op.getOperation()->getFunction().getModule()->getNamedFunction( fnAttr.getValue()); if (!fn) return op.emitOpError("reference to undefined function 'bar'"); // Check that the referenced function has the correct type. - if (fn->getType() != type) + if (fn.getType() != type) return op.emitOpError("reference to function with mismatched type"); return success(); @@ -1876,10 +1876,10 @@ static void print(OpAsmPrinter *p, ReturnOp op) { } static LogicalResult verify(ReturnOp op) { - auto *function = op.getOperation()->getFunction(); + auto function = op.getOperation()->getFunction(); // The operand number and types must match the function signature. - const auto &results = function->getType().getResults(); + const auto &results = function.getType().getResults(); if (op.getNumOperands() != results.size()) return op.emitOpError("has ") << op.getNumOperands() diff --git a/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp index 74ade942fc7..1e8409246ef 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp @@ -69,7 +69,7 @@ std::unique_ptr mlir::translateModuleToNVVMIR(Module &m) { // Insert the nvvm.annotations kernel so that the NVVM backend recognizes the // function as a kernel. - for (Function &func : m) { + for (Function func : m) { if (!func.getAttrOfType(gpu::GPUDialect::getKernelFuncAttrName())) continue; @@ -89,20 +89,21 @@ std::unique_ptr mlir::translateModuleToNVVMIR(Module &m) { return llvmModule; } -static TranslateFromMLIRRegistration registration( - "mlir-to-nvvmir", [](Module *module, llvm::StringRef outputFilename) { - if (!module) - return true; +static TranslateFromMLIRRegistration + registration("mlir-to-nvvmir", + [](Module *module, llvm::StringRef outputFilename) { + if (!module) + return true; - auto llvmModule = mlir::translateModuleToNVVMIR(*module); - if (!llvmModule) - return true; + auto llvmModule = mlir::translateModuleToNVVMIR(*module); + if (!llvmModule) + return true; - auto file = openOutputFile(outputFilename); - if (!file) - return true; + auto file = openOutputFile(outputFilename); + if (!file) + return true; - llvmModule->print(file->os(), nullptr); - file->keep(); - return false; - }); + llvmModule->print(file->os(), nullptr); + file->keep(); + return false; + }); diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index ef286cb64fd..4a68ac71ee0 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -375,7 +375,7 @@ bool ModuleTranslation::convertOneFunction(Function &func) { bool ModuleTranslation::convertFunctions() { // Declare all functions first because there may be function calls that form a // call graph with cycles. - for (Function &function : mlirModule) { + for (Function function : mlirModule) { mlir::BoolAttr isVarArgsAttr = function.getAttrOfType("std.varargs"); bool isVarArgs = isVarArgsAttr && isVarArgsAttr.getValue(); @@ -392,7 +392,7 @@ bool ModuleTranslation::convertFunctions() { } // Convert functions. - for (Function &function : mlirModule) { + for (Function function : mlirModule) { // Ignore external functions. if (function.isExternal()) continue; diff --git a/mlir/lib/Transforms/Canonicalizer.cpp b/mlir/lib/Transforms/Canonicalizer.cpp index 8a2002ce368..394b3ef8db5 100644 --- a/mlir/lib/Transforms/Canonicalizer.cpp +++ b/mlir/lib/Transforms/Canonicalizer.cpp @@ -40,7 +40,7 @@ struct Canonicalizer : public FunctionPass { void Canonicalizer::runOnFunction() { OwningRewritePatternList patterns; - auto &func = getFunction(); + auto func = getFunction(); // TODO: Instead of adding all known patterns from the whole system lazily add // and cache the canonicalization patterns for ops we see in practice when diff --git a/mlir/lib/Transforms/DialectConversion.cpp b/mlir/lib/Transforms/DialectConversion.cpp index be60ada6a43..84f00b97e38 100644 --- a/mlir/lib/Transforms/DialectConversion.cpp +++ b/mlir/lib/Transforms/DialectConversion.cpp @@ -849,7 +849,7 @@ struct FunctionConverter { /// error, success otherwise. If 'signatureConversion' is provided, the /// arguments of the entry block are updated accordingly. LogicalResult - convertFunction(Function *f, + convertFunction(Function f, TypeConverter::SignatureConversion *signatureConversion); /// Converts the given region starting from the entry block and following the @@ -957,22 +957,22 @@ FunctionConverter::convertRegion(DialectConversionRewriter &rewriter, } LogicalResult FunctionConverter::convertFunction( - Function *f, TypeConverter::SignatureConversion *signatureConversion) { + Function f, TypeConverter::SignatureConversion *signatureConversion) { // If this is an external function, there is nothing else to do. - if (f->isExternal()) + if (f.isExternal()) return success(); - DialectConversionRewriter rewriter(f->getBody(), typeConverter); + DialectConversionRewriter rewriter(f.getBody(), typeConverter); // Update the signature of the entry block. if (signatureConversion) { rewriter.argConverter.convertSignature( - &f->getBody().front(), *signatureConversion, rewriter.mapping); + &f.getBody().front(), *signatureConversion, rewriter.mapping); } // Rewrite the function body. if (failed( - convertRegion(rewriter, f->getBody(), /*convertEntryTypes=*/false))) { + convertRegion(rewriter, f.getBody(), /*convertEntryTypes=*/false))) { // Reset any of the generated rewrites. rewriter.discardRewrites(); return failure(); @@ -1124,24 +1124,6 @@ auto ConversionTarget::getOpAction(OperationName op) const // applyConversionPatterns //===----------------------------------------------------------------------===// -namespace { -/// This class represents a function to be converted. It allows for converting -/// the body of functions and the signature in two phases. -struct ConvertedFunction { - ConvertedFunction(Function *fn, FunctionType newType, - ArrayRef newFunctionArgAttrs) - : fn(fn), newType(newType), - newFunctionArgAttrs(newFunctionArgAttrs.begin(), - newFunctionArgAttrs.end()) {} - - /// The function to convert. - Function *fn; - /// The new type and argument attributes for the function. - FunctionType newType; - SmallVector newFunctionArgAttrs; -}; -} // end anonymous namespace - /// Convert the given module with the provided conversion patterns and type /// conversion object. If conversion fails for specific functions, those /// functions remains unmodified. @@ -1149,37 +1131,33 @@ LogicalResult mlir::applyConversionPatterns(Module &module, ConversionTarget &target, TypeConverter &converter, OwningRewritePatternList &&patterns) { - std::vector allFunctions; - allFunctions.reserve(module.getFunctions().size()); - for (auto &func : module) - allFunctions.push_back(&func); + SmallVector allFunctions(module.getFunctions()); return applyConversionPatterns(allFunctions, target, converter, std::move(patterns)); } /// Convert the given functions with the provided conversion patterns. LogicalResult mlir::applyConversionPatterns( - ArrayRef fns, ConversionTarget &target, + MutableArrayRef fns, ConversionTarget &target, TypeConverter &converter, OwningRewritePatternList &&patterns) { if (fns.empty()) return success(); // Build the function converter. - FunctionConverter funcConverter(fns.front()->getContext(), target, patterns, - &converter); + auto *ctx = fns.front().getContext(); + FunctionConverter funcConverter(ctx, target, patterns, &converter); // Try to convert each of the functions within the module. - auto *ctx = fns.front()->getContext(); - for (auto *func : fns) { + for (auto func : fns) { // Convert the function type using the type converter. auto conversion = - converter.convertSignature(func->getType(), func->getAllArgAttrs()); + converter.convertSignature(func.getType(), func.getAllArgAttrs()); if (!conversion) return failure(); // Update the function signature. - func->setType(conversion->getConvertedType(ctx)); - func->setAllArgAttrs(conversion->getConvertedArgAttrs()); + func.setType(conversion->getConvertedType(ctx)); + func.setAllArgAttrs(conversion->getConvertedArgAttrs()); // Convert the body of this function. if (failed(funcConverter.convertFunction(func, &*conversion))) @@ -1193,9 +1171,9 @@ LogicalResult mlir::applyConversionPatterns( /// convert as many of the operations within 'fn' as possible given the set of /// patterns. LogicalResult -mlir::applyConversionPatterns(Function &fn, ConversionTarget &target, +mlir::applyConversionPatterns(Function fn, ConversionTarget &target, OwningRewritePatternList &&patterns) { // Convert the body of this function. FunctionConverter converter(fn.getContext(), target, patterns); - return converter.convertFunction(&fn, /*signatureConversion=*/nullptr); + return converter.convertFunction(fn, /*signatureConversion=*/nullptr); } diff --git a/mlir/lib/Transforms/DmaGeneration.cpp b/mlir/lib/Transforms/DmaGeneration.cpp index 5a926ceaa92..a3aa092b0ec 100644 --- a/mlir/lib/Transforms/DmaGeneration.cpp +++ b/mlir/lib/Transforms/DmaGeneration.cpp @@ -214,7 +214,7 @@ static bool getFullMemRefAsRegion(Operation *opInst, unsigned numParamLoopIVs, static InFlightDiagnostic LLVM_ATTRIBUTE_UNUSED emitRemarkForBlock(Block &block) { auto *op = block.getContainingOp(); - return op ? op->emitRemark() : block.getFunction()->emitRemark(); + return op ? op->emitRemark() : block.getFunction().emitRemark(); } /// Creates a buffer in the faster memory space for the specified region; @@ -246,8 +246,8 @@ bool DmaGeneration::generateDma(const MemRefRegion ®ion, Block *block, OpBuilder &b = region.isWrite() ? epilogue : prologue; // Builder to create constants at the top level. - auto *func = block->getFunction(); - OpBuilder top(func->getBody()); + auto func = block->getFunction(); + OpBuilder top(func.getBody()); auto loc = region.loc; auto *memref = region.memref; @@ -751,14 +751,14 @@ uint64_t DmaGeneration::runOnBlock(Block::iterator begin, Block::iterator end) { if (auto *op = block->getContainingOp()) op->emitError(str); else - block->getFunction()->emitError(str); + block->getFunction().emitError(str); } return totalDmaBuffersSizeInBytes; } void DmaGeneration::runOnFunction() { - Function &f = getFunction(); + Function f = getFunction(); OpBuilder topBuilder(f.getBody()); zeroIndex = topBuilder.create(f.getLoc(), 0); diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index 8d2e75b2dca..77b944f3e01 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -257,7 +257,7 @@ public: // Initializes the dependence graph based on operations in 'f'. // Returns true on success, false otherwise. - bool init(Function &f); + bool init(Function f); // Returns the graph node for 'id'. Node *getNode(unsigned id) { @@ -637,7 +637,7 @@ public: // Assigns each node in the graph a node id based on program order in 'f'. // TODO(andydavis) Add support for taking a Block arg to construct the // dependence graph at a different depth. -bool MemRefDependenceGraph::init(Function &f) { +bool MemRefDependenceGraph::init(Function f) { DenseMap> memrefAccesses; // TODO: support multi-block functions. @@ -859,7 +859,7 @@ static Value *createPrivateMemRef(AffineForOp forOp, Operation *srcStoreOpInst, // Create builder to insert alloc op just before 'forOp'. OpBuilder b(forInst); // Builder to create constants at the top level. - OpBuilder top(forInst->getFunction()->getBody()); + OpBuilder top(forInst->getFunction().getBody()); // Create new memref type based on slice bounds. auto *oldMemRef = cast(srcStoreOpInst).getMemRef(); auto oldMemRefType = oldMemRef->getType().cast(); @@ -1750,9 +1750,9 @@ public: }; // Search for siblings which load the same memref function argument. - auto *fn = dstNode->op->getFunction(); - for (unsigned i = 0, e = fn->getNumArguments(); i != e; ++i) { - for (auto *user : fn->getArgument(i)->getUsers()) { + auto fn = dstNode->op->getFunction(); + for (unsigned i = 0, e = fn.getNumArguments(); i != e; ++i) { + for (auto *user : fn.getArgument(i)->getUsers()) { if (auto loadOp = dyn_cast(user)) { // Gather loops surrounding 'use'. SmallVector loops; diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp index c1be6e8f6b1..2744e5ca05c 100644 --- a/mlir/lib/Transforms/LoopTiling.cpp +++ b/mlir/lib/Transforms/LoopTiling.cpp @@ -261,7 +261,7 @@ LogicalResult mlir::tileCodeGen(MutableArrayRef band, // Identify valid and profitable bands of loops to tile. This is currently just // a temporary placeholder to test the mechanics of tiled code generation. // Returns all maximal outermost perfect loop nests to tile. -static void getTileableBands(Function &f, +static void getTileableBands(Function f, std::vector> *bands) { // Get maximal perfect nest of 'affine.for' insts starting from root // (inclusive). diff --git a/mlir/lib/Transforms/LoopUnroll.cpp b/mlir/lib/Transforms/LoopUnroll.cpp index 05953926376..6f13f623fe8 100644 --- a/mlir/lib/Transforms/LoopUnroll.cpp +++ b/mlir/lib/Transforms/LoopUnroll.cpp @@ -92,8 +92,8 @@ void LoopUnroll::runOnFunction() { // Store innermost loops as we walk. std::vector loops; - void walkPostOrder(Function *f) { - for (auto &b : *f) + void walkPostOrder(Function f) { + for (auto &b : f) walkPostOrder(b.begin(), b.end()); } @@ -142,10 +142,10 @@ void LoopUnroll::runOnFunction() { ? clUnrollNumRepetitions : 1; // If the call back is provided, we will recurse until no loops are found. - Function &func = getFunction(); + Function func = getFunction(); for (unsigned i = 0; i < numRepetitions || getUnrollFactor; i++) { InnermostLoopGatherer ilg; - ilg.walkPostOrder(&func); + ilg.walkPostOrder(func); auto &loops = ilg.loops; if (loops.empty()) break; diff --git a/mlir/lib/Transforms/LowerAffine.cpp b/mlir/lib/Transforms/LowerAffine.cpp index 77a23b156b0..df30e270fe6 100644 --- a/mlir/lib/Transforms/LowerAffine.cpp +++ b/mlir/lib/Transforms/LowerAffine.cpp @@ -726,7 +726,7 @@ public: } // end namespace -LogicalResult mlir::lowerAffineConstructs(Function &function) { +LogicalResult mlir::lowerAffineConstructs(Function function) { OwningRewritePatternList patterns; RewriteListBuildergetFunction()->print(dbgs())); + LLVM_DEBUG((*slice)[0]->getFunction().print(dbgs())); // slice are topologically sorted, we can just erase them in reverse // order. Reverse iterator does not just work simply with an operator* @@ -667,7 +667,7 @@ static bool emitSlice(MaterializationState *state, /// because we currently disallow vectorization of defs that come from another /// scope. /// TODO(ntv): please document return value. -static bool materialize(Function *f, const SetVector &terminators, +static bool materialize(Function f, const SetVector &terminators, MaterializationState *state) { DenseSet seen; DominanceInfo domInfo(f); @@ -721,7 +721,7 @@ static bool materialize(Function *f, const SetVector &terminators, return true; } LLVM_DEBUG(dbgs() << "\nMLFunction is now\n"); - LLVM_DEBUG(f->print(dbgs())); + LLVM_DEBUG(f.print(dbgs())); } return false; } @@ -731,13 +731,13 @@ void MaterializeVectorsPass::runOnFunction() { NestedPatternContext mlContext; // TODO(ntv): Check to see if this supports arbitrary top-level code. - Function *f = &getFunction(); - if (f->getBlocks().size() != 1) + Function f = getFunction(); + if (f.getBlocks().size() != 1) return; using matcher::Op; LLVM_DEBUG(dbgs() << "\nMaterializeVectors on Function\n"); - LLVM_DEBUG(f->print(dbgs())); + LLVM_DEBUG(f.print(dbgs())); MaterializationState state(hwVectorSize); // Get the hardware vector type. diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp index c5676afaf63..1208e2fdd15 100644 --- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp +++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp @@ -212,7 +212,7 @@ void MemRefDataFlowOpt::forwardStoreToLoad(LoadOp loadOp) { void MemRefDataFlowOpt::runOnFunction() { // Only supports single block functions at the moment. - Function &f = getFunction(); + Function f = getFunction(); if (f.getBlocks().size() != 1) { markAllAnalysesPreserved(); return; diff --git a/mlir/lib/Transforms/StripDebugInfo.cpp b/mlir/lib/Transforms/StripDebugInfo.cpp index f97f549c93e..c7c3621781a 100644 --- a/mlir/lib/Transforms/StripDebugInfo.cpp +++ b/mlir/lib/Transforms/StripDebugInfo.cpp @@ -29,7 +29,7 @@ struct StripDebugInfo : public FunctionPass { } // end anonymous namespace void StripDebugInfo::runOnFunction() { - Function &func = getFunction(); + Function func = getFunction(); auto unknownLoc = UnknownLoc::get(&getContext()); // Strip the debug info from the function and its operations. diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp index 47ca378f324..e185f702d27 100644 --- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp +++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp @@ -44,7 +44,7 @@ namespace { /// applies the locally optimal patterns in a roughly "bottom up" way. class GreedyPatternRewriteDriver : public PatternRewriter { public: - explicit GreedyPatternRewriteDriver(Function &fn, + explicit GreedyPatternRewriteDriver(Function fn, OwningRewritePatternList &&patterns) : PatternRewriter(fn.getBody()), matcher(std::move(patterns)) { worklist.reserve(64); @@ -213,7 +213,7 @@ bool GreedyPatternRewriteDriver::simplifyFunction(int maxIterations) { /// patterns in a greedy work-list driven manner. Return true if no more /// patterns can be matched in the result function. /// -bool mlir::applyPatternsGreedily(Function &fn, +bool mlir::applyPatternsGreedily(Function fn, OwningRewritePatternList &&patterns) { GreedyPatternRewriteDriver driver(fn, std::move(patterns)); bool converged = driver.simplifyFunction(maxPatternMatchIterations); diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index 728123f71a5..4ddf93c2232 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -125,7 +125,7 @@ LogicalResult mlir::promoteIfSingleIteration(AffineForOp forOp) { Operation *op = forOp.getOperation(); if (!iv->use_empty()) { if (forOp.hasConstantLowerBound()) { - OpBuilder topBuilder(op->getFunction()->getBody()); + OpBuilder topBuilder(op->getFunction().getBody()); auto constOp = topBuilder.create( forOp.getLoc(), forOp.getConstantLowerBound()); iv->replaceAllUsesWith(constOp); diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp index 39a05d8c300..3fca26bef19 100644 --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -1194,7 +1194,7 @@ static LogicalResult vectorizeRootMatch(NestedMatch m, /// Applies vectorization to the current Function by searching over a bunch of /// predetermined patterns. void Vectorize::runOnFunction() { - Function &f = getFunction(); + Function f = getFunction(); if (!fastestVaryingPattern.empty() && fastestVaryingPattern.size() != vectorSizes.size()) { f.emitRemark("Fastest varying pattern specified with different size than " @@ -1220,7 +1220,7 @@ void Vectorize::runOnFunction() { unsigned patternDepth = pat.getDepth(); SmallVector matches; - pat.match(&f, &matches); + pat.match(f, &matches); // Iterate over all the top-level matches and vectorize eagerly. // This automatically prunes intersecting matches. for (auto m : matches) { diff --git a/mlir/lib/Transforms/ViewFunctionGraph.cpp b/mlir/lib/Transforms/ViewFunctionGraph.cpp index 1f2ab69409e..3c1a1b3b481 100644 --- a/mlir/lib/Transforms/ViewFunctionGraph.cpp +++ b/mlir/lib/Transforms/ViewFunctionGraph.cpp @@ -53,13 +53,13 @@ std::string DOTGraphTraits::getNodeLabel(Block *Block, Function *) { } // end namespace llvm -void mlir::viewGraph(Function &function, const llvm::Twine &name, +void mlir::viewGraph(Function function, const llvm::Twine &name, bool shortNames, const llvm::Twine &title, llvm::GraphProgram::Name program) { llvm::ViewGraph(&function, name, shortNames, title, program); } -llvm::raw_ostream &mlir::writeGraph(llvm::raw_ostream &os, Function &function, +llvm::raw_ostream &mlir::writeGraph(llvm::raw_ostream &os, Function function, bool shortNames, const llvm::Twine &title) { return llvm::WriteGraph(os, &function, shortNames, title); } diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp index 834e7c98228..a88312dba9b 100644 --- a/mlir/test/EDSC/builder-api-test.cpp +++ b/mlir/test/EDSC/builder-api-test.cpp @@ -43,13 +43,12 @@ static MLIRContext &globalContext() { return context; } -static std::unique_ptr makeFunction(StringRef name, - ArrayRef results = {}, - ArrayRef args = {}) { +static Function makeFunction(StringRef name, ArrayRef results = {}, + ArrayRef args = {}) { auto &ctx = globalContext(); - auto function = llvm::make_unique( - UnknownLoc::get(&ctx), name, FunctionType::get(args, results, &ctx)); - function->addEntryBlock(); + auto function = Function::create(UnknownLoc::get(&ctx), name, + FunctionType::get(args, results, &ctx)); + function.addEntryBlock(); return function; } @@ -62,10 +61,10 @@ TEST_FUNC(builder_dynamic_for_func_args) { auto f = makeFunction("builder_dynamic_for_func_args", {}, {indexType, indexType}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); - ValueHandle i(indexType), j(indexType), lb(f->getArgument(0)), - ub(f->getArgument(1)); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); + ValueHandle i(indexType), j(indexType), lb(f.getArgument(0)), + ub(f.getArgument(1)); ValueHandle f7(constant_float(llvm::APFloat(7.0f), f32Type)); ValueHandle f13(constant_float(llvm::APFloat(13.0f), f32Type)); ValueHandle i7(constant_int(7, 32)); @@ -102,7 +101,8 @@ TEST_FUNC(builder_dynamic_for_func_args) { // CHECK-DAG: [[ri4:%[0-9]+]] = muli {{.*}}, {{.*}} : i32 // CHECK: {{.*}} = subi [[ri3]], [[ri4]] : i32 // clang-format on - f->print(llvm::outs()); + f.print(llvm::outs()); + f.erase(); } TEST_FUNC(builder_dynamic_for) { @@ -113,10 +113,10 @@ TEST_FUNC(builder_dynamic_for) { auto f = makeFunction("builder_dynamic_for", {}, {indexType, indexType, indexType, indexType}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); - ValueHandle i(indexType), a(f->getArgument(0)), b(f->getArgument(1)), - c(f->getArgument(2)), d(f->getArgument(3)); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); + ValueHandle i(indexType), a(f.getArgument(0)), b(f.getArgument(1)), + c(f.getArgument(2)), d(f.getArgument(3)); LoopBuilder(&i, a - b, c + d, 2)(); // clang-format off @@ -125,7 +125,8 @@ TEST_FUNC(builder_dynamic_for) { // CHECK-DAG: [[r1:%[0-9]+]] = affine.apply ()[s0, s1] -> (s0 + s1)()[%arg2, %arg3] // CHECK-NEXT: affine.for %i0 = (d0) -> (d0)([[r0]]) to (d0) -> (d0)([[r1]]) step 2 { // clang-format on - f->print(llvm::outs()); + f.print(llvm::outs()); + f.erase(); } TEST_FUNC(builder_max_min_for) { @@ -136,10 +137,10 @@ TEST_FUNC(builder_max_min_for) { auto f = makeFunction("builder_max_min_for", {}, {indexType, indexType, indexType, indexType}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); - ValueHandle i(indexType), lb1(f->getArgument(0)), lb2(f->getArgument(1)), - ub1(f->getArgument(2)), ub2(f->getArgument(3)); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); + ValueHandle i(indexType), lb1(f.getArgument(0)), lb2(f.getArgument(1)), + ub1(f.getArgument(2)), ub2(f.getArgument(3)); LoopBuilder(&i, {lb1, lb2}, {ub1, ub2}, 1)(); ret(); @@ -148,7 +149,8 @@ TEST_FUNC(builder_max_min_for) { // CHECK: affine.for %i0 = max (d0, d1) -> (d0, d1)(%arg0, %arg1) to min (d0, d1) -> (d0, d1)(%arg2, %arg3) { // CHECK: return // clang-format on - f->print(llvm::outs()); + f.print(llvm::outs()); + f.erase(); } TEST_FUNC(builder_blocks) { @@ -157,14 +159,14 @@ TEST_FUNC(builder_blocks) { using namespace edsc::op; auto f = makeFunction("builder_blocks"); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); ValueHandle c1(ValueHandle::create(42, 32)), c2(ValueHandle::create(1234, 32)); ValueHandle arg1(c1.getType()), arg2(c1.getType()), arg3(c1.getType()), arg4(c1.getType()), r(c1.getType()); - BlockHandle b1, b2, functionBlock(&f->front()); + BlockHandle b1, b2, functionBlock(&f.front()); BlockBuilder(&b1, {&arg1, &arg2})( // b2 has not yet been constructed, need to come back later. // This is a byproduct of non-structured control-flow. @@ -192,7 +194,8 @@ TEST_FUNC(builder_blocks) { // CHECK-NEXT: br ^bb1(%3, %4 : i32, i32) // CHECK-NEXT: } // clang-format on - f->print(llvm::outs()); + f.print(llvm::outs()); + f.erase(); } TEST_FUNC(builder_blocks_eager) { @@ -201,8 +204,8 @@ TEST_FUNC(builder_blocks_eager) { using namespace edsc::op; auto f = makeFunction("builder_blocks_eager"); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); ValueHandle c1(ValueHandle::create(42, 32)), c2(ValueHandle::create(1234, 32)); ValueHandle arg1(c1.getType()), arg2(c1.getType()), arg3(c1.getType()), @@ -235,7 +238,8 @@ TEST_FUNC(builder_blocks_eager) { // CHECK-NEXT: br ^bb1(%3, %4 : i32, i32) // CHECK-NEXT: } // clang-format on - f->print(llvm::outs()); + f.print(llvm::outs()); + f.erase(); } TEST_FUNC(builder_cond_branch) { @@ -244,15 +248,15 @@ TEST_FUNC(builder_cond_branch) { auto f = makeFunction("builder_cond_branch", {}, {IntegerType::get(1, &globalContext())}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); - ValueHandle funcArg(f->getArgument(0)); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); + ValueHandle funcArg(f.getArgument(0)); ValueHandle c32(ValueHandle::create(32, 32)), c64(ValueHandle::create(64, 64)), c42(ValueHandle::create(42, 32)); ValueHandle arg1(c32.getType()), arg2(c64.getType()), arg3(c32.getType()); - BlockHandle b1, b2, functionBlock(&f->front()); + BlockHandle b1, b2, functionBlock(&f.front()); BlockBuilder(&b1, {&arg1})([&] { ret(); }); BlockBuilder(&b2, {&arg2, &arg3})([&] { ret(); }); // Get back to entry block and add a conditional branch @@ -271,7 +275,8 @@ TEST_FUNC(builder_cond_branch) { // CHECK-NEXT: ^bb2(%1: i64, %2: i32): // pred: ^bb0 // CHECK-NEXT: return // clang-format on - f->print(llvm::outs()); + f.print(llvm::outs()); + f.erase(); } TEST_FUNC(builder_cond_branch_eager) { @@ -281,9 +286,9 @@ TEST_FUNC(builder_cond_branch_eager) { auto f = makeFunction("builder_cond_branch_eager", {}, {IntegerType::get(1, &globalContext())}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); - ValueHandle funcArg(f->getArgument(0)); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); + ValueHandle funcArg(f.getArgument(0)); ValueHandle c32(ValueHandle::create(32, 32)), c64(ValueHandle::create(64, 64)), c42(ValueHandle::create(42, 32)); @@ -309,7 +314,8 @@ TEST_FUNC(builder_cond_branch_eager) { // CHECK-NEXT: ^bb2(%1: i64, %2: i32): // pred: ^bb0 // CHECK-NEXT: return // clang-format on - f->print(llvm::outs()); + f.print(llvm::outs()); + f.erase(); } TEST_FUNC(builder_helpers) { @@ -321,14 +327,14 @@ TEST_FUNC(builder_helpers) { auto f = makeFunction("builder_helpers", {}, {memrefType, memrefType, memrefType}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); // clang-format off ValueHandle f7( ValueHandle::create(llvm::APFloat(7.0f), f32Type)); - MemRefView vA(f->getArgument(0)), vB(f->getArgument(1)), - vC(f->getArgument(2)); - IndexedValue A(f->getArgument(0)), B(f->getArgument(1)), C(f->getArgument(2)); + MemRefView vA(f.getArgument(0)), vB(f.getArgument(1)), + vC(f.getArgument(2)); + IndexedValue A(f.getArgument(0)), B(f.getArgument(1)), C(f.getArgument(2)); IndexHandle i, j, k1, k2, lb0, lb1, lb2, ub0, ub1, ub2; int64_t step0, step1, step2; std::tie(lb0, ub0, step0) = vA.range(0); @@ -363,7 +369,8 @@ TEST_FUNC(builder_helpers) { // CHECK-DAG: [[e:%.*]] = addf [[d]], [[c]] : f32 // CHECK-NEXT: store [[e]], %arg2[%i0, %i1, %i3] : memref // clang-format on - f->print(llvm::outs()); + f.print(llvm::outs()); + f.erase(); } TEST_FUNC(custom_ops) { @@ -373,8 +380,8 @@ TEST_FUNC(custom_ops) { auto indexType = IndexType::get(&globalContext()); auto f = makeFunction("custom_ops", {}, {indexType, indexType}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); CustomOperation MY_CUSTOM_OP("my_custom_op"); CustomOperation MY_CUSTOM_OP_0("my_custom_op_0"); CustomOperation MY_CUSTOM_OP_2("my_custom_op_2"); @@ -382,7 +389,7 @@ TEST_FUNC(custom_ops) { // clang-format off ValueHandle vh(indexType), vh20(indexType), vh21(indexType); OperationHandle ih0, ih2; - IndexHandle m, n, M(f->getArgument(0)), N(f->getArgument(1)); + IndexHandle m, n, M(f.getArgument(0)), N(f.getArgument(1)); IndexHandle ten(index_t(10)), twenty(index_t(20)); LoopNestBuilder({&m, &n}, {M, N}, {M + ten, N + twenty}, {1, 1})([&]{ vh = MY_CUSTOM_OP({m, m + n}, {indexType}, {}); @@ -402,7 +409,8 @@ TEST_FUNC(custom_ops) { // CHECK: [[TWO:%[a-z0-9]+]]:2 = "my_custom_op_2"{{.*}} : (index, index) -> (index, index) // CHECK: {{.*}} = "my_custom_op"([[TWO]]#0, [[TWO]]#1) : (index, index) -> index // clang-format on - f->print(llvm::outs()); + f.print(llvm::outs()); + f.erase(); } TEST_FUNC(insertion_in_block) { @@ -412,8 +420,8 @@ TEST_FUNC(insertion_in_block) { auto indexType = IndexType::get(&globalContext()); auto f = makeFunction("insertion_in_block", {}, {indexType, indexType}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); BlockHandle b1; // clang-format off ValueHandle::create(0, 32); @@ -427,7 +435,8 @@ TEST_FUNC(insertion_in_block) { // CHECK: ^bb1: // no predecessors // CHECK: {{.*}} = constant 1 : i32 // clang-format on - f->print(llvm::outs()); + f.print(llvm::outs()); + f.erase(); } TEST_FUNC(select_op) { @@ -438,12 +447,12 @@ TEST_FUNC(select_op) { auto memrefType = MemRefType::get({-1, -1, -1}, f32Type, {}, 0); auto f = makeFunction("select_op", {}, {memrefType}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); // clang-format off ValueHandle zero = constant_index(0), one = constant_index(1); - MemRefView vA(f->getArgument(0)); - IndexedValue A(f->getArgument(0)); + MemRefView vA(f.getArgument(0)); + IndexedValue A(f.getArgument(0)); IndexHandle i, j; LoopNestBuilder({&i, &j}, {zero, zero}, {one, one}, {1, 1})([&]{ // This test exercises IndexedValue::operator Value*. @@ -461,7 +470,8 @@ TEST_FUNC(select_op) { // CHECK-DAG: {{.*}} = load // CHECK-NEXT: {{.*}} = select // clang-format on - f->print(llvm::outs()); + f.print(llvm::outs()); + f.erase(); } // Inject an EDSC-constructed computation to exercise imperfectly nested 2-d @@ -474,12 +484,11 @@ TEST_FUNC(tile_2d) { MemRefType::get({-1, -1, -1}, FloatType::getF32(&globalContext()), {}, 0); auto f = makeFunction("tile_2d", {}, {memrefType, memrefType, memrefType}); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); ValueHandle zero = constant_index(0); - MemRefView vA(f->getArgument(0)), vB(f->getArgument(1)), - vC(f->getArgument(2)); - IndexedValue A(f->getArgument(0)), B(f->getArgument(1)), C(f->getArgument(2)); + MemRefView vA(f.getArgument(0)), vB(f.getArgument(1)), vC(f.getArgument(2)); + IndexedValue A(f.getArgument(0)), B(f.getArgument(1)), C(f.getArgument(2)); IndexHandle i, j, k1, k2, M(vC.ub(0)), N(vC.ub(1)), O(vC.ub(2)); // clang-format off @@ -531,7 +540,8 @@ TEST_FUNC(tile_2d) { // CHECK-NEXT: {{.*}}= addf {{.*}}, {{.*}} : f32 // CHECK-NEXT: store {{.*}}, {{.*}}[%i8, %i9, %i7] : memref // clang-format on - f->print(llvm::outs()); + f.print(llvm::outs()); + f.erase(); } // Inject an EDSC-constructed computation to exercise 2-d vectorization. @@ -544,16 +554,15 @@ TEST_FUNC(vectorize_2d) { auto owningF = makeFunction("vectorize_2d", {}, {memrefType, memrefType, memrefType}); - mlir::Function *f = owningF.release(); + mlir::Function f = owningF; mlir::Module module(&globalContext()); - module.getFunctions().push_back(f); + module.push_back(f); - OpBuilder builder(f->getBody()); - ScopedContext scope(builder, f->getLoc()); + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); ValueHandle zero = constant_index(0); - MemRefView vA(f->getArgument(0)), vB(f->getArgument(1)), - vC(f->getArgument(2)); - IndexedValue A(f->getArgument(0)), B(f->getArgument(1)), C(f->getArgument(2)); + MemRefView vA(f.getArgument(0)), vB(f.getArgument(1)), vC(f.getArgument(2)); + IndexedValue A(f.getArgument(0)), B(f.getArgument(1)), C(f.getArgument(2)); IndexHandle M(vA.ub(0)), N(vA.ub(1)), P(vA.ub(2)); // clang-format off @@ -580,9 +589,10 @@ TEST_FUNC(vectorize_2d) { pm.addPass(mlir::createCanonicalizerPass()); SmallVector vectorSizes{4, 4}; pm.addPass(mlir::createVectorizePass(vectorSizes)); - auto result = pm.run(f->getModule()); + auto result = pm.run(f.getModule()); if (succeeded(result)) - f->print(llvm::outs()); + f.print(llvm::outs()); + f.erase(); } int main() { diff --git a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp index 4767e3367be..7bfb5564064 100644 --- a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp +++ b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp @@ -97,12 +97,12 @@ struct VectorizerTestPass : public FunctionPass { } // end anonymous namespace void VectorizerTestPass::testVectorShapeRatio(llvm::raw_ostream &outs) { - auto *f = &getFunction(); + auto f = getFunction(); using matcher::Op; SmallVector shape(clTestVectorShapeRatio.begin(), clTestVectorShapeRatio.end()); auto subVectorType = - VectorType::get(shape, FloatType::getF32(f->getContext())); + VectorType::get(shape, FloatType::getF32(f.getContext())); // Only filter operations that operate on a strict super-vector and have one // return. This makes testing easier. auto filter = [&](Operation &op) { @@ -148,7 +148,7 @@ static NestedPattern patternTestSlicingOps() { } void VectorizerTestPass::testBackwardSlicing(llvm::raw_ostream &outs) { - auto *f = &getFunction(); + auto f = getFunction(); SmallVector matches; patternTestSlicingOps().match(f, &matches); @@ -163,7 +163,7 @@ void VectorizerTestPass::testBackwardSlicing(llvm::raw_ostream &outs) { } void VectorizerTestPass::testForwardSlicing(llvm::raw_ostream &outs) { - auto *f = &getFunction(); + auto f = getFunction(); SmallVector matches; patternTestSlicingOps().match(f, &matches); for (auto m : matches) { @@ -177,7 +177,7 @@ void VectorizerTestPass::testForwardSlicing(llvm::raw_ostream &outs) { } void VectorizerTestPass::testSlicing(llvm::raw_ostream &outs) { - auto *f = &getFunction(); + auto f = getFunction(); SmallVector matches; patternTestSlicingOps().match(f, &matches); @@ -195,7 +195,7 @@ static bool customOpWithAffineMapAttribute(Operation &op) { } void VectorizerTestPass::testComposeMaps(llvm::raw_ostream &outs) { - auto *f = &getFunction(); + auto f = getFunction(); using matcher::Op; auto pattern = Op(customOpWithAffineMapAttribute); @@ -227,7 +227,7 @@ static bool singleResultAffineApplyOpWithoutUses(Operation &op) { void VectorizerTestPass::testNormalizeMaps() { using matcher::Op; - auto *f = &getFunction(); + auto f = getFunction(); // Save matched AffineApplyOp that all need to be erased in the end. auto pattern = Op(affineApplyOp); @@ -256,7 +256,7 @@ void VectorizerTestPass::runOnFunction() { NestedPatternContext mlContext; // Only support single block functions at this point. - Function &f = getFunction(); + Function f = getFunction(); if (f.getBlocks().size() != 1) return; diff --git a/mlir/tools/mlir-cpu-runner/mlir-cpu-runner-lib.cpp b/mlir/tools/mlir-cpu-runner/mlir-cpu-runner-lib.cpp index 54a9c6ce95c..1ac6c402630 100644 --- a/mlir/tools/mlir-cpu-runner/mlir-cpu-runner-lib.cpp +++ b/mlir/tools/mlir-cpu-runner/mlir-cpu-runner-lib.cpp @@ -163,8 +163,8 @@ static LogicalResult convertAffineStandardToLLVMIR(Module *module) { static Error compileAndExecuteFunctionWithMemRefs( Module *module, StringRef entryPoint, std::function transformer) { - Function *mainFunction = module->getNamedFunction(entryPoint); - if (!mainFunction || mainFunction->getBlocks().empty()) { + Function mainFunction = module->getNamedFunction(entryPoint); + if (!mainFunction || mainFunction.getBlocks().empty()) { return make_string_error("entry point not found"); } @@ -172,9 +172,9 @@ static Error compileAndExecuteFunctionWithMemRefs( // pretty print the results, because the function itself will be rewritten // to use the LLVM dialect. SmallVector argTypes = - llvm::to_vector<8>(mainFunction->getType().getInputs()); + llvm::to_vector<8>(mainFunction.getType().getInputs()); SmallVector resTypes = - llvm::to_vector<8>(mainFunction->getType().getResults()); + llvm::to_vector<8>(mainFunction.getType().getResults()); float init = std::stof(initValue.getValue()); @@ -206,18 +206,18 @@ static Error compileAndExecuteFunctionWithMemRefs( static Error compileAndExecuteSingleFloatReturnFunction( Module *module, StringRef entryPoint, std::function transformer) { - Function *mainFunction = module->getNamedFunction(entryPoint); - if (!mainFunction || mainFunction->isExternal()) { + Function mainFunction = module->getNamedFunction(entryPoint); + if (!mainFunction || mainFunction.isExternal()) { return make_string_error("entry point not found"); } - if (!mainFunction->getType().getInputs().empty()) + if (!mainFunction.getType().getInputs().empty()) return make_string_error("function inputs not supported"); - if (mainFunction->getType().getResults().size() != 1) + if (mainFunction.getType().getResults().size() != 1) return make_string_error("only single f32 function result supported"); - auto t = mainFunction->getType().getResults()[0].dyn_cast(); + auto t = mainFunction.getType().getResults()[0].dyn_cast(); if (!t) return make_string_error("only single llvm.f32 function result supported"); auto *llvmTy = t.getUnderlyingType(); diff --git a/mlir/unittests/Pass/AnalysisManagerTest.cpp b/mlir/unittests/Pass/AnalysisManagerTest.cpp index 38a059b3ba5..d2a82374124 100644 --- a/mlir/unittests/Pass/AnalysisManagerTest.cpp +++ b/mlir/unittests/Pass/AnalysisManagerTest.cpp @@ -25,11 +25,11 @@ using namespace mlir::detail; namespace { /// Minimal class definitions for two analyses. struct MyAnalysis { - MyAnalysis(Function *) {} + MyAnalysis(Function) {} MyAnalysis(Module *) {} }; struct OtherAnalysis { - OtherAnalysis(Function *) {} + OtherAnalysis(Function) {} OtherAnalysis(Module *) {} }; @@ -59,10 +59,10 @@ TEST(AnalysisManagerTest, FineGrainFunctionAnalysisPreservation) { // Create a function and a module. std::unique_ptr module(new Module(&context)); - Function *func1 = - new Function(builder.getUnknownLoc(), "foo", - builder.getFunctionType(llvm::None, llvm::None)); - module->getFunctions().push_back(func1); + Function func1 = + Function::create(builder.getUnknownLoc(), "foo", + builder.getFunctionType(llvm::None, llvm::None)); + module->push_back(func1); // Test fine grain invalidation of the function analysis manager. ModuleAnalysisManager mam(&*module, /*passInstrumentor=*/nullptr); @@ -87,10 +87,10 @@ TEST(AnalysisManagerTest, FineGrainChildFunctionAnalysisPreservation) { // Create a function and a module. std::unique_ptr module(new Module(&context)); - Function *func1 = - new Function(builder.getUnknownLoc(), "foo", - builder.getFunctionType(llvm::None, llvm::None)); - module->getFunctions().push_back(func1); + Function func1 = + Function::create(builder.getUnknownLoc(), "foo", + builder.getFunctionType(llvm::None, llvm::None)); + module->push_back(func1); // Test fine grain invalidation of a function analysis from within a module // analysis manager. -- cgit v1.2.3 From 926fb685deadfed2042163145ac52311914bf5c2 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Mon, 12 Aug 2019 19:12:42 -0700 Subject: Express ownership transfer in PassManager API through std::unique_ptr (NFC) Since raw pointers are always passed around for IR construct without implying any ownership transfer, it can be error prone to have implicit ownership transferred the same way. For example this code can seem harmless: Pass *pass = .... pm.addPass(pass); pm.addPass(pass); pm.run(module); PiperOrigin-RevId: 263053082 --- .../Linalg/Linalg3/include/linalg3/Transforms.h | 2 +- mlir/examples/Linalg/Linalg3/lib/Transforms.cpp | 4 +- mlir/examples/toy/Ch4/include/toy/Passes.h | 4 +- mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp | 4 +- mlir/examples/toy/Ch4/toyc.cpp | 1 + mlir/examples/toy/Ch5/include/toy/Lowering.h | 4 +- mlir/examples/toy/Ch5/include/toy/Passes.h | 4 +- mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp | 4 +- mlir/examples/toy/Ch5/mlir/LateLowering.cpp | 4 +- mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp | 4 +- mlir/examples/toy/Ch5/toyc.cpp | 1 + .../mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h | 6 +-- .../mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h | 4 +- .../mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h | 6 ++- .../StandardToLLVM/ConvertStandardToLLVMPass.h | 6 +-- mlir/include/mlir/Dialect/GPU/Passes.h | 4 +- mlir/include/mlir/Dialect/QuantOps/Passes.h | 6 ++- mlir/include/mlir/Dialect/SPIRV/Passes.h | 2 +- mlir/include/mlir/Linalg/Passes.h | 12 +++--- mlir/include/mlir/Pass/Pass.h | 6 +-- mlir/include/mlir/Pass/PassManager.h | 6 +-- mlir/include/mlir/Pass/PassRegistry.h | 7 +++- mlir/include/mlir/Quantizer/Transforms/Passes.h | 6 +-- mlir/include/mlir/Transforms/Passes.h | 48 +++++++++++----------- .../GPUToCUDA/ConvertKernelFuncToCubin.cpp | 4 +- .../GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp | 5 ++- .../GPUToCUDA/GenerateCubinAccessors.cpp | 4 +- .../Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp | 4 +- mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp | 11 ++--- .../StandardToLLVM/ConvertStandardToLLVM.cpp | 9 ++-- .../StandardToSPIRV/ConvertStandardToSPIRVPass.cpp | 5 ++- .../lib/Dialect/GPU/Transforms/KernelOutlining.cpp | 4 +- .../Dialect/QuantOps/Transforms/ConvertConst.cpp | 4 +- .../QuantOps/Transforms/ConvertSimQuant.cpp | 5 ++- mlir/lib/Linalg/Transforms/Fusion.cpp | 6 +-- mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp | 4 +- mlir/lib/Linalg/Transforms/LowerToLoops.cpp | 4 +- mlir/lib/Linalg/Transforms/Tiling.cpp | 6 +-- mlir/lib/Pass/Pass.cpp | 26 ++++++------ mlir/lib/Pass/PassDetail.h | 8 +++- .../Transforms/AddDefaultStatsTestPass.cpp | 4 +- .../Transforms/InferQuantizedTypesPass.cpp | 4 +- .../Transforms/RemoveInstrumentationPass.cpp | 5 ++- mlir/lib/Transforms/AffineDataCopyGeneration.cpp | 8 ++-- mlir/lib/Transforms/CSE.cpp | 4 +- mlir/lib/Transforms/Canonicalizer.cpp | 4 +- mlir/lib/Transforms/LoopCoalescing.cpp | 4 +- mlir/lib/Transforms/LoopFusion.cpp | 9 ++-- mlir/lib/Transforms/LoopInvariantCodeMotion.cpp | 4 +- mlir/lib/Transforms/LoopTiling.cpp | 5 ++- mlir/lib/Transforms/LoopUnroll.cpp | 4 +- mlir/lib/Transforms/LoopUnrollAndJam.cpp | 5 ++- mlir/lib/Transforms/LowerAffine.cpp | 4 +- mlir/lib/Transforms/LowerVectorTransfers.cpp | 4 +- mlir/lib/Transforms/MaterializeVectors.cpp | 4 +- mlir/lib/Transforms/MemRefDataFlowOpt.cpp | 4 +- mlir/lib/Transforms/PipelineDataTransfer.cpp | 4 +- mlir/lib/Transforms/SimplifyAffineStructures.cpp | 4 +- mlir/lib/Transforms/StripDebugInfo.cpp | 4 +- mlir/lib/Transforms/Vectorize.cpp | 4 +- mlir/test/lib/TestDialect/TestPatterns.cpp | 9 ++-- mlir/test/lib/Transforms/TestConstantFold.cpp | 4 +- mlir/test/lib/Transforms/TestLoopFusion.cpp | 4 +- mlir/test/lib/Transforms/TestLoopMapping.cpp | 2 +- .../lib/Transforms/TestLoopParametricTiling.cpp | 7 ++-- .../test/lib/Transforms/TestVectorizationUtils.cpp | 4 +- 66 files changed, 217 insertions(+), 169 deletions(-) (limited to 'mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp') diff --git a/mlir/examples/Linalg/Linalg3/include/linalg3/Transforms.h b/mlir/examples/Linalg/Linalg3/include/linalg3/Transforms.h index 4346b47cf49..123d6afba08 100644 --- a/mlir/examples/Linalg/Linalg3/include/linalg3/Transforms.h +++ b/mlir/examples/Linalg/Linalg3/include/linalg3/Transforms.h @@ -73,7 +73,7 @@ void lowerToLoops(mlir::FuncOp f); /// Creates a pass that rewrites linalg.load and linalg.store to affine.load and /// affine.store operations. -mlir::FunctionPassBase *createLowerLinalgLoadStorePass(); +std::unique_ptr createLowerLinalgLoadStorePass(); } // namespace linalg diff --git a/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp b/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp index 7fc4bb5c897..79fa4ca34f2 100644 --- a/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp +++ b/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp @@ -300,6 +300,6 @@ Rewriter::matchAndRewrite(linalg::StoreOp store, } } // namespace -FunctionPassBase *linalg::createLowerLinalgLoadStorePass() { - return new LowerLinalgLoadStorePass(); +std::unique_ptr linalg::createLowerLinalgLoadStorePass() { + return llvm::make_unique(); } diff --git a/mlir/examples/toy/Ch4/include/toy/Passes.h b/mlir/examples/toy/Ch4/include/toy/Passes.h index dd73b95f9c2..93cf0d5ba15 100644 --- a/mlir/examples/toy/Ch4/include/toy/Passes.h +++ b/mlir/examples/toy/Ch4/include/toy/Passes.h @@ -22,12 +22,14 @@ #ifndef MLIR_TUTORIAL_TOY_PASSES_H #define MLIR_TUTORIAL_TOY_PASSES_H +#include + namespace mlir { class Pass; } // namespace mlir namespace toy { -mlir::Pass *createShapeInferencePass(); +std::unique_ptr createShapeInferencePass(); } // namespace toy #endif // MLIR_TUTORIAL_TOY_PASSES_H diff --git a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp index 5c258f1ef5b..4a6bf8790e0 100644 --- a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp @@ -375,5 +375,7 @@ public: } // end anonymous namespace namespace toy { -mlir::Pass *createShapeInferencePass() { return new ShapeInferencePass(); } +std::unique_ptr createShapeInferencePass() { + return llvm::make_unique(); +} } // namespace toy diff --git a/mlir/examples/toy/Ch4/toyc.cpp b/mlir/examples/toy/Ch4/toyc.cpp index a273c9301ce..9e7a8a39e0a 100644 --- a/mlir/examples/toy/Ch4/toyc.cpp +++ b/mlir/examples/toy/Ch4/toyc.cpp @@ -28,6 +28,7 @@ #include "mlir/IR/MLIRContext.h" #include "mlir/IR/Module.h" #include "mlir/Parser.h" +#include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" #include "mlir/Transforms/Passes.h" diff --git a/mlir/examples/toy/Ch5/include/toy/Lowering.h b/mlir/examples/toy/Ch5/include/toy/Lowering.h index 362a3428346..4788ea3fbeb 100644 --- a/mlir/examples/toy/Ch5/include/toy/Lowering.h +++ b/mlir/examples/toy/Ch5/include/toy/Lowering.h @@ -35,10 +35,10 @@ class DialectConversion; namespace toy { /// Create a pass for lowering operations in the `Linalg` dialects, for a subset /// of the Toy IR (matmul). -mlir::Pass *createEarlyLoweringPass(); +std::unique_ptr createEarlyLoweringPass(); /// Create a pass for the late lowering toward LLVM dialect. -mlir::Pass *createLateLoweringPass(); +std::unique_ptr createLateLoweringPass(); } // namespace toy diff --git a/mlir/examples/toy/Ch5/include/toy/Passes.h b/mlir/examples/toy/Ch5/include/toy/Passes.h index dd73b95f9c2..93cf0d5ba15 100644 --- a/mlir/examples/toy/Ch5/include/toy/Passes.h +++ b/mlir/examples/toy/Ch5/include/toy/Passes.h @@ -22,12 +22,14 @@ #ifndef MLIR_TUTORIAL_TOY_PASSES_H #define MLIR_TUTORIAL_TOY_PASSES_H +#include + namespace mlir { class Pass; } // namespace mlir namespace toy { -mlir::Pass *createShapeInferencePass(); +std::unique_ptr createShapeInferencePass(); } // namespace toy #endif // MLIR_TUTORIAL_TOY_PASSES_H diff --git a/mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp b/mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp index 015a3fd64c2..96230fdfbea 100644 --- a/mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp +++ b/mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp @@ -142,5 +142,7 @@ struct EarlyLoweringPass : public FunctionPass { } // end anonymous namespace namespace toy { -Pass *createEarlyLoweringPass() { return new EarlyLoweringPass(); } +std::unique_ptr createEarlyLoweringPass() { + return llvm::make_unique(); +} } // namespace toy diff --git a/mlir/examples/toy/Ch5/mlir/LateLowering.cpp b/mlir/examples/toy/Ch5/mlir/LateLowering.cpp index 3b6bfc9df5d..6135e275a75 100644 --- a/mlir/examples/toy/Ch5/mlir/LateLowering.cpp +++ b/mlir/examples/toy/Ch5/mlir/LateLowering.cpp @@ -458,5 +458,7 @@ struct LateLoweringPass : public ModulePass { } // end anonymous namespace namespace toy { -Pass *createLateLoweringPass() { return new LateLoweringPass(); } +std::unique_ptr createLateLoweringPass() { + return llvm::make_unique(); +} } // namespace toy diff --git a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp index cef2939788c..6437c0b3f73 100644 --- a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp @@ -375,5 +375,7 @@ public: } // end anonymous namespace namespace toy { -mlir::Pass *createShapeInferencePass() { return new ShapeInferencePass(); } +std::unique_ptr createShapeInferencePass() { + return llvm::make_unique(); +} } // namespace toy diff --git a/mlir/examples/toy/Ch5/toyc.cpp b/mlir/examples/toy/Ch5/toyc.cpp index 1d80c3c018d..a21eda74d82 100644 --- a/mlir/examples/toy/Ch5/toyc.cpp +++ b/mlir/examples/toy/Ch5/toyc.cpp @@ -32,6 +32,7 @@ #include "mlir/IR/MLIRContext.h" #include "mlir/IR/Module.h" #include "mlir/Parser.h" +#include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" #include "mlir/Target/LLVMIR.h" #include "mlir/Transforms/Passes.h" diff --git a/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h b/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h index b19fb53e3e2..bd1a3fea0ff 100644 --- a/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h +++ b/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h @@ -39,7 +39,7 @@ using CubinGenerator = std::function; /// attached as a string attribute named 'nvvm.cubin' to the kernel function. /// After the transformation, the body of the kernel function is removed (i.e., /// it is turned into a declaration). -ModulePassBase * +std::unique_ptr createConvertGPUKernelToCubinPass(CubinGenerator cubinGenerator); /// Creates a pass to convert a gpu.launch_func operation into a sequence of @@ -48,11 +48,11 @@ createConvertGPUKernelToCubinPass(CubinGenerator cubinGenerator); /// This pass does not generate code to call CUDA directly but instead uses a /// small wrapper library that exports a stable and conveniently typed ABI /// ontop of CUDA. -ModulePassBase *createConvertGpuLaunchFuncToCudaCallsPass(); +std::unique_ptr createConvertGpuLaunchFuncToCudaCallsPass(); /// Creates a pass to augment a module with getter functions for all contained /// cubins as encoded via the 'nvvm.cubin' attribute. -ModulePassBase *createGenerateCubinAccessorPass(); +std::unique_ptr createGenerateCubinAccessorPass(); } // namespace mlir #endif // MLIR_CONVERSION_GPUTOCUDA_GPUTOCUDAPASS_H_ diff --git a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h index b53549fb275..f1c8601795c 100644 --- a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h +++ b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h @@ -17,11 +17,13 @@ #ifndef MLIR_CONVERSION_GPUTONVVM_GPUTONVVMPASS_H_ #define MLIR_CONVERSION_GPUTONVVM_GPUTONVVMPASS_H_ +#include + namespace mlir { struct FunctionPassBase; /// Creates a pass that lowers GPU dialect operations to NVVM counterparts. -FunctionPassBase *createLowerGpuOpsToNVVMOpsPass(); +std::unique_ptr createLowerGpuOpsToNVVMOpsPass(); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h index 52f0dd4babb..3d32c36c43c 100644 --- a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h +++ b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h @@ -17,6 +17,8 @@ #ifndef MLIR_CONVERSION_LOOPSTOGPU_LOOPSTOGPUPASS_H_ #define MLIR_CONVERSION_LOOPSTOGPU_LOOPSTOGPUPASS_H_ +#include + namespace mlir { class FunctionPassBase; @@ -28,8 +30,8 @@ class FunctionPassBase; /// parallelization is performed, it is under the responsibility of the caller /// to strip-mine the loops and to perform the dependence analysis before /// calling the conversion. -FunctionPassBase *createSimpleLoopsToGPUPass(unsigned numBlockDims, - unsigned numThreadDims); +std::unique_ptr +createSimpleLoopsToGPUPass(unsigned numBlockDims, unsigned numThreadDims); } // namespace mlir #endif // MLIR_CONVERSION_LOOPSTOGPU_LOOPSTOGPUPASS_H_ diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h index 941e382905f..a08b2fb45d6 100644 --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h @@ -57,12 +57,12 @@ void populateStdToLLVMConversionPatterns(LLVMTypeConverter &converter, OwningRewritePatternList &patterns); /// Creates a pass to convert the Standard dialect into the LLVMIR dialect. -ModulePassBase *createConvertToLLVMIRPass(); +std::unique_ptr createConvertToLLVMIRPass(); /// Creates a pass to convert operations to the LLVMIR dialect. The conversion /// is defined by a list of patterns and a type converter that will be obtained /// during the pass using the provided callbacks. -ModulePassBase * +std::unique_ptr createConvertToLLVMIRPass(LLVMPatternListFiller patternListFiller, LLVMTypeConverterMaker typeConverterMaker); @@ -71,7 +71,7 @@ createConvertToLLVMIRPass(LLVMPatternListFiller patternListFiller, /// callback and an optional type conversion class, an instance is created /// during the pass. template -ModulePassBase * +std::unique_ptr createConvertToLLVMIRPass(LLVMPatternListFiller patternListFiller) { return createConvertToLLVMIRPass(patternListFiller, [](MLIRContext *context) { return llvm::make_unique(context); diff --git a/mlir/include/mlir/Dialect/GPU/Passes.h b/mlir/include/mlir/Dialect/GPU/Passes.h index f9b569d50af..d562b5835c7 100644 --- a/mlir/include/mlir/Dialect/GPU/Passes.h +++ b/mlir/include/mlir/Dialect/GPU/Passes.h @@ -22,11 +22,13 @@ #ifndef MLIR_DIALECT_GPU_PASSES_H_ #define MLIR_DIALECT_GPU_PASSES_H_ +#include + namespace mlir { class ModulePassBase; -ModulePassBase *createGpuKernelOutliningPass(); +std::unique_ptr createGpuKernelOutliningPass(); } // namespace mlir diff --git a/mlir/include/mlir/Dialect/QuantOps/Passes.h b/mlir/include/mlir/Dialect/QuantOps/Passes.h index 6b647a87f4a..1d43f7087db 100644 --- a/mlir/include/mlir/Dialect/QuantOps/Passes.h +++ b/mlir/include/mlir/Dialect/QuantOps/Passes.h @@ -25,6 +25,8 @@ #ifndef MLIR_DIALECT_QUANTOPS_PASSES_H #define MLIR_DIALECT_QUANTOPS_PASSES_H +#include + namespace mlir { class FunctionPassBase; @@ -32,14 +34,14 @@ namespace quant { /// Creates a pass that converts quantization simulation operations (i.e. /// FakeQuant and those like it) to casts into/out of supported QuantizedTypes. -FunctionPassBase *createConvertSimulatedQuantPass(); +std::unique_ptr createConvertSimulatedQuantPass(); /// Creates a pass that converts constants followed by a qbarrier to a /// constant whose value is quantized. This is typically one of the last /// passes done when lowering to express actual quantized arithmetic in a /// low level representation. Because it modifies the constant, it is /// destructive and cannot be undone. -FunctionPassBase *createConvertConstPass(); +std::unique_ptr createConvertConstPass(); } // namespace quant } // namespace mlir diff --git a/mlir/include/mlir/Dialect/SPIRV/Passes.h b/mlir/include/mlir/Dialect/SPIRV/Passes.h index e896da7ae8a..85f4f79ed59 100644 --- a/mlir/include/mlir/Dialect/SPIRV/Passes.h +++ b/mlir/include/mlir/Dialect/SPIRV/Passes.h @@ -27,7 +27,7 @@ namespace mlir { namespace spirv { -ModulePassBase *createConvertStandardToSPIRVPass(); +std::unique_ptr createConvertStandardToSPIRVPass(); } // namespace spirv } // namespace mlir diff --git a/mlir/include/mlir/Linalg/Passes.h b/mlir/include/mlir/Linalg/Passes.h index 02941492059..57dd09cfc63 100644 --- a/mlir/include/mlir/Linalg/Passes.h +++ b/mlir/include/mlir/Linalg/Passes.h @@ -30,14 +30,16 @@ class FunctionPassBase; class ModulePassBase; namespace linalg { -FunctionPassBase *createLinalgFusionPass(ArrayRef tileSizes = {}); +std::unique_ptr +createLinalgFusionPass(ArrayRef tileSizes = {}); -FunctionPassBase *createLinalgTilingPass(ArrayRef tileSizes = {}, - bool promoteViews = false); +std::unique_ptr +createLinalgTilingPass(ArrayRef tileSizes = {}, + bool promoteViews = false); -FunctionPassBase *createLowerLinalgToLoopsPass(); +std::unique_ptr createLowerLinalgToLoopsPass(); -ModulePassBase *createLowerLinalgToLLVMPass(); +std::unique_ptr createLowerLinalgToLLVMPass(); } // namespace linalg } // namespace mlir diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h index b1531a357e5..f5c8d8bd1a6 100644 --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -104,7 +104,7 @@ protected: virtual void runOnFunction() = 0; /// A clone method to create a copy of this pass. - virtual FunctionPassBase *clone() const = 0; + virtual std::unique_ptr clone() const = 0; /// Return the current function being transformed. FuncOp getFunction() { return getPassState().irAndPassFailed.getPointer(); } @@ -259,8 +259,8 @@ struct FunctionPass : public detail::PassModel { } /// A clone method to create a copy of this pass. - FunctionPassBase *clone() const override { - return new T(*static_cast(this)); + std::unique_ptr clone() const override { + return llvm::make_unique(*static_cast(this)); } }; diff --git a/mlir/include/mlir/Pass/PassManager.h b/mlir/include/mlir/Pass/PassManager.h index 68dfeb099bc..b01445eae4c 100644 --- a/mlir/include/mlir/Pass/PassManager.h +++ b/mlir/include/mlir/Pass/PassManager.h @@ -71,16 +71,16 @@ public: /// Add an opaque pass pointer to the current manager. This takes ownership /// over the provided pass pointer. - void addPass(Pass *pass); + void addPass(std::unique_ptr pass); /// Add a module pass to the current manager. This takes ownership over the /// provided pass pointer. - void addPass(ModulePassBase *pass); + void addPass(std::unique_ptr pass); /// Add a function pass to the current manager. This takes ownership over the /// provided pass pointer. This will automatically create a function pass /// executor if necessary. - void addPass(FunctionPassBase *pass); + void addPass(std::unique_ptr pass); //===--------------------------------------------------------------------===// // Instrumentations diff --git a/mlir/include/mlir/Pass/PassRegistry.h b/mlir/include/mlir/Pass/PassRegistry.h index ea0fbbe39db..bd108f3e77f 100644 --- a/mlir/include/mlir/Pass/PassRegistry.h +++ b/mlir/include/mlir/Pass/PassRegistry.h @@ -29,6 +29,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" #include +#include namespace mlir { class Pass; @@ -37,7 +38,7 @@ class PassManager; /// A registry function that adds passes to the given pass manager. using PassRegistryFunction = std::function; -using PassAllocatorFunction = std::function; +using PassAllocatorFunction = std::function()>; /// A special type used by transformation passes to provide an address that can /// act as a unique identifier during pass registration. @@ -120,7 +121,9 @@ template struct PassRegistration { } PassRegistration(StringRef arg, StringRef description) { - PassAllocatorFunction constructor = [] { return new ConcretePass(); }; + PassAllocatorFunction constructor = [] { + return llvm::make_unique(); + }; registerPass(arg, description, PassID::getID(), constructor); } }; diff --git a/mlir/include/mlir/Quantizer/Transforms/Passes.h b/mlir/include/mlir/Quantizer/Transforms/Passes.h index 0d7b4cb55b3..f894ea801e0 100644 --- a/mlir/include/mlir/Quantizer/Transforms/Passes.h +++ b/mlir/include/mlir/Quantizer/Transforms/Passes.h @@ -33,17 +33,17 @@ class TargetConfiguration; /// Creates a pass that infers quantized types based on metadata discovered /// in the computation. -ModulePassBase * +std::unique_ptr createInferQuantizedTypesPass(SolverContext &solverContext, const TargetConfiguration &config); /// Creates a pass which removes any instrumentation and hint ops which have /// no effect on final runtime. -FunctionPassBase *createRemoveInstrumentationPass(); +std::unique_ptr createRemoveInstrumentationPass(); /// Adds default (dummy) statistics to ops that can benefit from runtime stats. /// Meant for testing. -FunctionPassBase *createAddDefaultStatsPass(); +std::unique_ptr createAddDefaultStatsPass(); } // namespace quantizer } // namespace mlir diff --git a/mlir/include/mlir/Transforms/Passes.h b/mlir/include/mlir/Transforms/Passes.h index ee36517cea7..693c7b0ae00 100644 --- a/mlir/include/mlir/Transforms/Passes.h +++ b/mlir/include/mlir/Transforms/Passes.h @@ -37,25 +37,25 @@ class ModulePassBase; /// top-down constant folding functionality; it is intended to be used for /// testing purpose. Use Canonicalizer pass, which exploits more simplification /// opportunties exposed by constant folding, for the general cases. -FunctionPassBase *createTestConstantFoldPass(); +std::unique_ptr createTestConstantFoldPass(); /// Creates an instance of the Canonicalizer pass. -FunctionPassBase *createCanonicalizerPass(); +std::unique_ptr createCanonicalizerPass(); /// Creates a pass to perform common sub expression elimination. -FunctionPassBase *createCSEPass(); +std::unique_ptr createCSEPass(); /// Creates a pass to vectorize loops, operations and data types using a /// target-independent, n-D super-vector abstraction. -FunctionPassBase * +std::unique_ptr createVectorizePass(llvm::ArrayRef virtualVectorSize); /// Creates a pass to allow independent testing of vectorizer functionality with /// FileCheck. -FunctionPassBase *createVectorizerTestPass(); +std::unique_ptr createVectorizerTestPass(); /// Creates a pass to lower super-vectors to target-dependent HW vectors. -FunctionPassBase * +std::unique_ptr createMaterializeVectorsPass(llvm::ArrayRef vectorSize); /// Creates a loop unrolling pass with the provided parameters. @@ -64,71 +64,73 @@ createMaterializeVectorsPass(llvm::ArrayRef vectorSize); /// factors supplied through other means. If -1 is passed as the unrollFactor /// and no callback is provided, anything passed from the command-line (if at /// all) or the default unroll factor is used (LoopUnroll:kDefaultUnrollFactor). -FunctionPassBase *createLoopUnrollPass( +std::unique_ptr createLoopUnrollPass( int unrollFactor = -1, int unrollFull = -1, const std::function &getUnrollFactor = nullptr); /// Creates a loop unroll jam pass to unroll jam by the specified factor. A /// factor of -1 lets the pass use the default factor or the one on the command /// line if provided. -FunctionPassBase *createLoopUnrollAndJamPass(int unrollJamFactor = -1); +std::unique_ptr +createLoopUnrollAndJamPass(int unrollJamFactor = -1); /// Creates an simplification pass for affine structures. -FunctionPassBase *createSimplifyAffineStructuresPass(); +std::unique_ptr createSimplifyAffineStructuresPass(); /// Creates a loop fusion pass which fuses loops. Buffers of size less than or /// equal to `localBufSizeThreshold` are promoted to memory space /// `fastMemorySpace'. -FunctionPassBase *createLoopFusionPass(unsigned fastMemorySpace = 0, - uint64_t localBufSizeThreshold = 0, - bool maximalFusion = false); +std::unique_ptr +createLoopFusionPass(unsigned fastMemorySpace = 0, + uint64_t localBufSizeThreshold = 0, + bool maximalFusion = false); /// Creates a loop invariant code motion pass that hoists loop invariant /// instructions out of the loop. -FunctionPassBase *createLoopInvariantCodeMotionPass(); +std::unique_ptr createLoopInvariantCodeMotionPass(); /// Creates a pass to pipeline explicit movement of data across levels of the /// memory hierarchy. -FunctionPassBase *createPipelineDataTransferPass(); +std::unique_ptr createPipelineDataTransferPass(); /// Lowers affine control flow operations (ForStmt, IfStmt and AffineApplyOp) /// to equivalent lower-level constructs (flow of basic blocks and arithmetic /// primitives). -FunctionPassBase *createLowerAffinePass(); +std::unique_ptr createLowerAffinePass(); /// Creates a pass to perform tiling on loop nests. -FunctionPassBase *createLoopTilingPass(uint64_t cacheSizeBytes); +std::unique_ptr createLoopTilingPass(uint64_t cacheSizeBytes); /// Creates a pass that performs parametric tiling so that the outermost loops /// have the given fixed number of iterations. Assumes outermost loop nests /// are permutable. -FunctionPassBase * +std::unique_ptr createSimpleParametricTilingPass(ArrayRef outerLoopSizes); /// Creates a pass that transforms perfectly nested loops with independent /// bounds into a single loop. -FunctionPassBase *createLoopCoalescingPass(); +std::unique_ptr createLoopCoalescingPass(); /// Performs packing (or explicit copying) of accessed memref regions into /// buffers in the specified faster memory space through either pointwise copies /// or DMA operations. -FunctionPassBase *createAffineDataCopyGenerationPass( +std::unique_ptr createAffineDataCopyGenerationPass( unsigned slowMemorySpace, unsigned fastMemorySpace, unsigned tagMemorySpace = 0, int minDmaTransferSize = 1024, uint64_t fastMemCapacityBytes = std::numeric_limits::max()); /// Creates a pass to lower VectorTransferReadOp and VectorTransferWriteOp. -FunctionPassBase *createLowerVectorTransfersPass(); +std::unique_ptr createLowerVectorTransfersPass(); /// Creates a pass to perform optimizations relying on memref dataflow such as /// store to load forwarding, elimination of dead stores, and dead allocs. -FunctionPassBase *createMemRefDataFlowOptPass(); +std::unique_ptr createMemRefDataFlowOptPass(); /// Creates a pass to strip debug information from a function. -FunctionPassBase *createStripDebugInfoPass(); +std::unique_ptr createStripDebugInfoPass(); /// Creates a pass which tests loop fusion utilities. -FunctionPassBase *createTestLoopFusionPass(); +std::unique_ptr createTestLoopFusionPass(); } // end namespace mlir diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp index 766377528a1..0223dee9ede 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp @@ -163,9 +163,9 @@ GpuKernelToCubinPass::translateGpuKernelToCubinAnnotation(FuncOp &function) { return success(); } -ModulePassBase * +std::unique_ptr mlir::createConvertGPUKernelToCubinPass(CubinGenerator cubinGenerator) { - return new GpuKernelToCubinPass(cubinGenerator); + return llvm::make_unique(cubinGenerator); } static PassRegistration diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp index bf7577856db..bf0816c8b71 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp @@ -382,8 +382,9 @@ void GpuLaunchFuncToCudaCallsPass::translateGpuLaunchCalls( launchOp.erase(); } -mlir::ModulePassBase *mlir::createConvertGpuLaunchFuncToCudaCallsPass() { - return new GpuLaunchFuncToCudaCallsPass(); +std::unique_ptr +mlir::createConvertGpuLaunchFuncToCudaCallsPass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp b/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp index 813a3bee0ad..fa481632e29 100644 --- a/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp @@ -141,8 +141,8 @@ private: } // anonymous namespace -ModulePassBase *createGenerateCubinAccessorPass() { - return new GpuGenerateCubinAccessorsPass(); +std::unique_ptr createGenerateCubinAccessorPass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp index e4a6f964f50..91671489f2d 100644 --- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp +++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp @@ -128,8 +128,8 @@ public: } // anonymous namespace -FunctionPassBase *createLowerGpuOpsToNVVMOpsPass() { - return new LowerGpuOpsToNVVMOpsPass(); +std::unique_ptr createLowerGpuOpsToNVVMOpsPass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp index 7c785b5c995..36869b87f1a 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp @@ -66,13 +66,14 @@ struct ForLoopMapper : public FunctionPass { }; } // namespace -FunctionPassBase *mlir::createSimpleLoopsToGPUPass(unsigned numBlockDims, - unsigned numThreadDims) { - return new ForLoopMapper(numBlockDims, numThreadDims); +std::unique_ptr +mlir::createSimpleLoopsToGPUPass(unsigned numBlockDims, + unsigned numThreadDims) { + return llvm::make_unique(numBlockDims, numThreadDims); } static PassRegistration registration(PASS_NAME, "Convert top-level loops to GPU kernels", [] { - return new ForLoopMapper(clNumBlockDims.getValue(), - clNumThreadDims.getValue()); + return llvm::make_unique(clNumBlockDims.getValue(), + clNumThreadDims.getValue()); }); diff --git a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp index c62a5d8719d..731c07e22c3 100644 --- a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp @@ -1132,14 +1132,15 @@ struct LLVMLoweringPass : public ModulePass { }; } // end namespace -ModulePassBase *mlir::createConvertToLLVMIRPass() { - return new LLVMLoweringPass; +std::unique_ptr mlir::createConvertToLLVMIRPass() { + return llvm::make_unique(); } -ModulePassBase * +std::unique_ptr mlir::createConvertToLLVMIRPass(LLVMPatternListFiller patternListFiller, LLVMTypeConverterMaker typeConverterMaker) { - return new LLVMLoweringPass(patternListFiller, typeConverterMaker); + return llvm::make_unique(patternListFiller, + typeConverterMaker); } static PassRegistration diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp index ad2c4b57fb4..3d4ef639cfa 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp @@ -48,8 +48,9 @@ void ConvertStandardToSPIRVPass::runOnModule() { } } -ModulePassBase *mlir::spirv::createConvertStandardToSPIRVPass() { - return new ConvertStandardToSPIRVPass(); +std::unique_ptr +mlir::spirv::createConvertStandardToSPIRVPass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp index 01decce28ac..b7be427be1b 100644 --- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp @@ -109,8 +109,8 @@ public: } // namespace -ModulePassBase *mlir::createGpuKernelOutliningPass() { - return new GpuKernelOutliningPass(); +std::unique_ptr mlir::createGpuKernelOutliningPass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp index 120d0cf0e56..9c48c672300 100644 --- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp +++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp @@ -112,8 +112,8 @@ void ConvertConstPass::runOnFunction() { applyPatternsGreedily(func, patterns); } -FunctionPassBase *mlir::quant::createConvertConstPass() { - return new ConvertConstPass(); +std::unique_ptr mlir::quant::createConvertConstPass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp index dfdce8964ba..924e6390d88 100644 --- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp +++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp @@ -103,8 +103,9 @@ void ConvertSimulatedQuantPass::runOnFunction() { signalPassFailure(); } -FunctionPassBase *mlir::quant::createConvertSimulatedQuantPass() { - return new ConvertSimulatedQuantPass(); +std::unique_ptr +mlir::quant::createConvertSimulatedQuantPass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/lib/Linalg/Transforms/Fusion.cpp b/mlir/lib/Linalg/Transforms/Fusion.cpp index 4864f394c88..992c4664b10 100644 --- a/mlir/lib/Linalg/Transforms/Fusion.cpp +++ b/mlir/lib/Linalg/Transforms/Fusion.cpp @@ -350,14 +350,14 @@ LinalgFusionPass::LinalgFusionPass(ArrayRef sizes) this->tileSizes.assign(sizes.begin(), sizes.end()); } -FunctionPassBase * +std::unique_ptr mlir::linalg::createLinalgFusionPass(ArrayRef tileSizes) { - return new LinalgFusionPass(tileSizes); + return llvm::make_unique(tileSizes); } static PassRegistration pass("linalg-fusion", "Fuse operations in the linalg dialect", [] { - auto *pass = new LinalgFusionPass(); + auto pass = llvm::make_unique(); pass->tileSizes.assign(clTileSizes.begin(), clTileSizes.end()); return pass; }); diff --git a/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp b/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp index 84452a2ec2c..49af61e33eb 100644 --- a/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp +++ b/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp @@ -741,8 +741,8 @@ void LowerLinalgToLLVMPass::runOnModule() { } } -ModulePassBase *mlir::linalg::createLowerLinalgToLLVMPass() { - return new LowerLinalgToLLVMPass(); +std::unique_ptr mlir::linalg::createLowerLinalgToLLVMPass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/lib/Linalg/Transforms/LowerToLoops.cpp b/mlir/lib/Linalg/Transforms/LowerToLoops.cpp index afeb5c43f91..24e56b11063 100644 --- a/mlir/lib/Linalg/Transforms/LowerToLoops.cpp +++ b/mlir/lib/Linalg/Transforms/LowerToLoops.cpp @@ -390,8 +390,8 @@ void LowerLinalgToLoopsPass::runOnFunction() { } } -FunctionPassBase *mlir::linalg::createLowerLinalgToLoopsPass() { - return new LowerLinalgToLoopsPass(); +std::unique_ptr mlir::linalg::createLowerLinalgToLoopsPass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/lib/Linalg/Transforms/Tiling.cpp b/mlir/lib/Linalg/Transforms/Tiling.cpp index 8090a587d42..48c0da8f88f 100644 --- a/mlir/lib/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Linalg/Transforms/Tiling.cpp @@ -527,15 +527,15 @@ LinalgTilingPass::LinalgTilingPass(ArrayRef sizes, bool promoteViews) { this->promoteViews = promoteViews; } -FunctionPassBase * +std::unique_ptr mlir::linalg::createLinalgTilingPass(ArrayRef tileSizes, bool promoteViews) { - return new LinalgTilingPass(tileSizes, promoteViews); + return llvm::make_unique(tileSizes, promoteViews); } static PassRegistration pass("linalg-tile", "Tile operations in the linalg dialect", [] { - auto *pass = new LinalgTilingPass(); + auto pass = llvm::make_unique(); pass->tileSizes.assign(clTileSizes.begin(), clTileSizes.end()); pass->promoteViews = clPromoteFullTileViews; return pass; diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp index 3ed7b248042..35d96634cf1 100644 --- a/mlir/lib/Pass/Pass.cpp +++ b/mlir/lib/Pass/Pass.cpp @@ -264,44 +264,44 @@ void PassManager::disableMultithreading(bool disable) { /// Add an opaque pass pointer to the current manager. This takes ownership /// over the provided pass pointer. -void PassManager::addPass(Pass *pass) { +void PassManager::addPass(std::unique_ptr pass) { switch (pass->getKind()) { case Pass::Kind::FunctionPass: - addPass(cast(pass)); + addPass(cast(std::move(pass))); break; case Pass::Kind::ModulePass: - addPass(cast(pass)); + addPass(cast(std::move(pass))); break; } } /// Add a module pass to the current manager. This takes ownership over the /// provided pass pointer. -void PassManager::addPass(ModulePassBase *pass) { +void PassManager::addPass(std::unique_ptr pass) { nestedExecutorStack.clear(); - mpe->addPass(pass); + mpe->addPass(std::move(pass)); // Add a verifier run if requested. if (verifyPasses) - mpe->addPass(new ModuleVerifierPass()); + mpe->addPass(llvm::make_unique()); } /// Add a function pass to the current manager. This takes ownership over the /// provided pass pointer. This will automatically create a function pass /// executor if necessary. -void PassManager::addPass(FunctionPassBase *pass) { +void PassManager::addPass(std::unique_ptr pass) { detail::FunctionPassExecutor *fpe; if (nestedExecutorStack.empty()) { /// Create an executor adaptor for this pass. if (disableThreads || !llvm::llvm_is_multithreaded()) { // If multi-threading is disabled, then create a synchronous adaptor. - auto *adaptor = new ModuleToFunctionPassAdaptor(); - addPass(adaptor); + auto adaptor = llvm::make_unique(); fpe = &adaptor->getFunctionExecutor(); + addPass(std::unique_ptr{adaptor.release()}); } else { - auto *adaptor = new ModuleToFunctionPassAdaptorParallel(); - addPass(adaptor); + auto adaptor = llvm::make_unique(); fpe = &adaptor->getFunctionExecutor(); + addPass(std::unique_ptr{adaptor.release()}); } /// Add the executor to the stack. @@ -309,11 +309,11 @@ void PassManager::addPass(FunctionPassBase *pass) { } else { fpe = cast(nestedExecutorStack.back()); } - fpe->addPass(pass); + fpe->addPass(std::move(pass)); // Add a verifier run if requested. if (verifyPasses) - fpe->addPass(new FunctionVerifierPass()); + fpe->addPass(llvm::make_unique()); } /// Add the provided instrumentation to the pass manager. This takes ownership diff --git a/mlir/lib/Pass/PassDetail.h b/mlir/lib/Pass/PassDetail.h index 0b41c44ef14..bb482a2bc65 100644 --- a/mlir/lib/Pass/PassDetail.h +++ b/mlir/lib/Pass/PassDetail.h @@ -66,7 +66,9 @@ public: /// Add a pass to the current executor. This takes ownership over the provided /// pass pointer. - void addPass(FunctionPassBase *pass) { passes.emplace_back(pass); } + void addPass(std::unique_ptr pass) { + passes.push_back(std::move(pass)); + } /// Returns the number of passes held by this executor. size_t size() const { return passes.size(); } @@ -94,7 +96,9 @@ public: /// Add a pass to the current executor. This takes ownership over the provided /// pass pointer. - void addPass(ModulePassBase *pass) { passes.emplace_back(pass); } + void addPass(std::unique_ptr pass) { + passes.push_back(std::move(pass)); + } static bool classof(const PassExecutor *pe) { return pe->getKind() == Kind::ModuleExecutor; diff --git a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp index 3f26bf075af..4868d3be291 100644 --- a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp +++ b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp @@ -118,8 +118,8 @@ void AddDefaultStatsPass::runWithConfig(SolverContext &solverContext, }); } -FunctionPassBase *mlir::quantizer::createAddDefaultStatsPass() { - return new AddDefaultStatsPass(); +std::unique_ptr mlir::quantizer::createAddDefaultStatsPass() { + return llvm::make_unique(); } static PassRegistration pass( diff --git a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp index 765a36e791a..e1365e769b3 100644 --- a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp +++ b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp @@ -286,9 +286,9 @@ void InferQuantizedTypesPass::transformResultType(CAGResultAnchor *anchor, } } -ModulePassBase *mlir::quantizer::createInferQuantizedTypesPass( +std::unique_ptr mlir::quantizer::createInferQuantizedTypesPass( SolverContext &solverContext, const TargetConfiguration &config) { - return new InferQuantizedTypesPass(solverContext, config); + return llvm::make_unique(solverContext, config); } static PassRegistration diff --git a/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp b/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp index d5fb28463d6..104a3b60404 100644 --- a/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp +++ b/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp @@ -66,8 +66,9 @@ void RemoveInstrumentationPass::runOnFunction() { applyPatternsGreedily(func, patterns); } -FunctionPassBase *mlir::quantizer::createRemoveInstrumentationPass() { - return new RemoveInstrumentationPass(); +std::unique_ptr +mlir::quantizer::createRemoveInstrumentationPass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/lib/Transforms/AffineDataCopyGeneration.cpp b/mlir/lib/Transforms/AffineDataCopyGeneration.cpp index 522ed4a4c09..e422bd24425 100644 --- a/mlir/lib/Transforms/AffineDataCopyGeneration.cpp +++ b/mlir/lib/Transforms/AffineDataCopyGeneration.cpp @@ -162,12 +162,12 @@ struct AffineDataCopyGeneration /// buffers in 'fastMemorySpace', and replaces memory operations to the former /// by the latter. Only load op's handled for now. /// TODO(bondhugula): extend this to store op's. -FunctionPassBase *mlir::createAffineDataCopyGenerationPass( +std::unique_ptr mlir::createAffineDataCopyGenerationPass( unsigned slowMemorySpace, unsigned fastMemorySpace, unsigned tagMemorySpace, int minDmaTransferSize, uint64_t fastMemCapacityBytes) { - return new AffineDataCopyGeneration(slowMemorySpace, fastMemorySpace, - tagMemorySpace, minDmaTransferSize, - fastMemCapacityBytes); + return llvm::make_unique( + slowMemorySpace, fastMemorySpace, tagMemorySpace, minDmaTransferSize, + fastMemCapacityBytes); } // Info comprising stride and number of elements transferred every stride. diff --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp index eeb63e7f9eb..59658526c25 100644 --- a/mlir/lib/Transforms/CSE.cpp +++ b/mlir/lib/Transforms/CSE.cpp @@ -258,7 +258,9 @@ void CSE::runOnFunction() { markAnalysesPreserved(); } -FunctionPassBase *mlir::createCSEPass() { return new CSE(); } +std::unique_ptr mlir::createCSEPass() { + return llvm::make_unique(); +} static PassRegistration pass("cse", "Eliminate common sub-expressions in functions"); diff --git a/mlir/lib/Transforms/Canonicalizer.cpp b/mlir/lib/Transforms/Canonicalizer.cpp index 80d8ea92b03..6f4a40f86f3 100644 --- a/mlir/lib/Transforms/Canonicalizer.cpp +++ b/mlir/lib/Transforms/Canonicalizer.cpp @@ -53,8 +53,8 @@ void Canonicalizer::runOnFunction() { } /// Create a Canonicalizer pass. -FunctionPassBase *mlir::createCanonicalizerPass() { - return new Canonicalizer(); +std::unique_ptr mlir::createCanonicalizerPass() { + return llvm::make_unique(); } static PassRegistration pass("canonicalize", diff --git a/mlir/lib/Transforms/LoopCoalescing.cpp b/mlir/lib/Transforms/LoopCoalescing.cpp index f47433c52c0..eb52e8d5802 100644 --- a/mlir/lib/Transforms/LoopCoalescing.cpp +++ b/mlir/lib/Transforms/LoopCoalescing.cpp @@ -96,8 +96,8 @@ public: } // namespace -FunctionPassBase *mlir::createLoopCoalescingPass() { - return new LoopCoalescingPass; +std::unique_ptr mlir::createLoopCoalescingPass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index ea1a03f09a3..2736ebc0f55 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -111,10 +111,11 @@ struct LoopFusion : public FunctionPass { } // end anonymous namespace -FunctionPassBase *mlir::createLoopFusionPass(unsigned fastMemorySpace, - uint64_t localBufSizeThreshold, - bool maximalFusion) { - return new LoopFusion(fastMemorySpace, localBufSizeThreshold, maximalFusion); +std::unique_ptr +mlir::createLoopFusionPass(unsigned fastMemorySpace, + uint64_t localBufSizeThreshold, bool maximalFusion) { + return llvm::make_unique(fastMemorySpace, localBufSizeThreshold, + maximalFusion); } namespace { diff --git a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp index d8b5b2d8b2c..09fe9afe808 100644 --- a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp +++ b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp @@ -76,8 +76,8 @@ static bool isMemRefDereferencingOp(Operation &op) { return false; } -FunctionPassBase *mlir::createLoopInvariantCodeMotionPass() { - return new LoopInvariantCodeMotion(); +std::unique_ptr mlir::createLoopInvariantCodeMotionPass() { + return llvm::make_unique(); } // Returns true if the individual op is loop invariant. diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp index 0a331cae100..d6ff9a94234 100644 --- a/mlir/lib/Transforms/LoopTiling.cpp +++ b/mlir/lib/Transforms/LoopTiling.cpp @@ -81,8 +81,9 @@ struct LoopTiling : public FunctionPass { /// Creates a pass to perform loop tiling on all suitable loop nests of a /// Function. -FunctionPassBase *mlir::createLoopTilingPass(uint64_t cacheSizeBytes) { - return new LoopTiling(cacheSizeBytes); +std::unique_ptr +mlir::createLoopTilingPass(uint64_t cacheSizeBytes) { + return llvm::make_unique(cacheSizeBytes); } // Move the loop body of AffineForOp 'src' from 'src' into the specified diff --git a/mlir/lib/Transforms/LoopUnroll.cpp b/mlir/lib/Transforms/LoopUnroll.cpp index 1c7f3393ada..c3db90e4b3a 100644 --- a/mlir/lib/Transforms/LoopUnroll.cpp +++ b/mlir/lib/Transforms/LoopUnroll.cpp @@ -180,10 +180,10 @@ LogicalResult LoopUnroll::runOnAffineForOp(AffineForOp forOp) { return loopUnrollByFactor(forOp, kDefaultUnrollFactor); } -FunctionPassBase *mlir::createLoopUnrollPass( +std::unique_ptr mlir::createLoopUnrollPass( int unrollFactor, int unrollFull, const std::function &getUnrollFactor) { - return new LoopUnroll( + return llvm::make_unique( unrollFactor == -1 ? None : Optional(unrollFactor), unrollFull == -1 ? None : Optional(unrollFull), getUnrollFactor); } diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp index 7650db1ce27..362aa8683cc 100644 --- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp +++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp @@ -82,8 +82,9 @@ struct LoopUnrollAndJam : public FunctionPass { }; } // end anonymous namespace -FunctionPassBase *mlir::createLoopUnrollAndJamPass(int unrollJamFactor) { - return new LoopUnrollAndJam( +std::unique_ptr +mlir::createLoopUnrollAndJamPass(int unrollJamFactor) { + return llvm::make_unique( unrollJamFactor == -1 ? None : Optional(unrollJamFactor)); } diff --git a/mlir/lib/Transforms/LowerAffine.cpp b/mlir/lib/Transforms/LowerAffine.cpp index 062134dea9c..f24bc6d88da 100644 --- a/mlir/lib/Transforms/LowerAffine.cpp +++ b/mlir/lib/Transforms/LowerAffine.cpp @@ -529,8 +529,8 @@ class LowerAffinePass : public FunctionPass { /// Lowers If and For operations within a function into their lower level CFG /// equivalent blocks. -FunctionPassBase *mlir::createLowerAffinePass() { - return new LowerAffinePass(); +std::unique_ptr mlir::createLowerAffinePass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/lib/Transforms/LowerVectorTransfers.cpp b/mlir/lib/Transforms/LowerVectorTransfers.cpp index e2d5920f1dd..e941850b5b1 100644 --- a/mlir/lib/Transforms/LowerVectorTransfers.cpp +++ b/mlir/lib/Transforms/LowerVectorTransfers.cpp @@ -373,8 +373,8 @@ struct LowerVectorTransfersPass } // end anonymous namespace -FunctionPassBase *mlir::createLowerVectorTransfersPass() { - return new LowerVectorTransfersPass(); +std::unique_ptr mlir::createLowerVectorTransfersPass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/lib/Transforms/MaterializeVectors.cpp b/mlir/lib/Transforms/MaterializeVectors.cpp index 17acc92f49a..24b1f77c939 100644 --- a/mlir/lib/Transforms/MaterializeVectors.cpp +++ b/mlir/lib/Transforms/MaterializeVectors.cpp @@ -766,9 +766,9 @@ void MaterializeVectorsPass::runOnFunction() { signalPassFailure(); } -FunctionPassBase * +std::unique_ptr mlir::createMaterializeVectorsPass(llvm::ArrayRef vectorSize) { - return new MaterializeVectorsPass(vectorSize); + return llvm::make_unique(vectorSize); } static PassRegistration diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp index 4f8b1c61cbf..b16dff93ee3 100644 --- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp +++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp @@ -88,8 +88,8 @@ struct MemRefDataFlowOpt : public FunctionPass { /// Creates a pass to perform optimizations relying on memref dataflow such as /// store to load forwarding, elimination of dead stores, and dead allocs. -FunctionPassBase *mlir::createMemRefDataFlowOptPass() { - return new MemRefDataFlowOpt(); +std::unique_ptr mlir::createMemRefDataFlowOptPass() { + return llvm::make_unique(); } // This is a straightforward implementation not optimized for speed. Optimize diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp index af456c31408..d4d91c9b0e2 100644 --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -49,8 +49,8 @@ struct PipelineDataTransfer : public FunctionPass { /// Creates a pass to pipeline explicit movement of data across levels of the /// memory hierarchy. -FunctionPassBase *mlir::createPipelineDataTransferPass() { - return new PipelineDataTransfer(); +std::unique_ptr mlir::createPipelineDataTransferPass() { + return llvm::make_unique(); } // Returns the position of the tag memref operand given a DMA operation. diff --git a/mlir/lib/Transforms/SimplifyAffineStructures.cpp b/mlir/lib/Transforms/SimplifyAffineStructures.cpp index 3b6c231d054..3cc9309a5d5 100644 --- a/mlir/lib/Transforms/SimplifyAffineStructures.cpp +++ b/mlir/lib/Transforms/SimplifyAffineStructures.cpp @@ -88,8 +88,8 @@ struct SimplifyAffineStructures } // end anonymous namespace -FunctionPassBase *mlir::createSimplifyAffineStructuresPass() { - return new SimplifyAffineStructures(); +std::unique_ptr mlir::createSimplifyAffineStructuresPass() { + return llvm::make_unique(); } void SimplifyAffineStructures::runOnFunction() { diff --git a/mlir/lib/Transforms/StripDebugInfo.cpp b/mlir/lib/Transforms/StripDebugInfo.cpp index c82354ed49e..21d8ef15219 100644 --- a/mlir/lib/Transforms/StripDebugInfo.cpp +++ b/mlir/lib/Transforms/StripDebugInfo.cpp @@ -38,8 +38,8 @@ void StripDebugInfo::runOnFunction() { } /// Creates a pass to strip debug information from a function. -FunctionPassBase *mlir::createStripDebugInfoPass() { - return new StripDebugInfo(); +std::unique_ptr mlir::createStripDebugInfoPass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp index ce254065332..932f00bfcbe 100644 --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -1276,9 +1276,9 @@ void Vectorize::runOnFunction() { LLVM_DEBUG(dbgs() << "\n"); } -FunctionPassBase * +std::unique_ptr mlir::createVectorizePass(llvm::ArrayRef virtualVectorSize) { - return new Vectorize(virtualVectorSize); + return llvm::make_unique(virtualVectorSize); } static PassRegistration diff --git a/mlir/test/lib/TestDialect/TestPatterns.cpp b/mlir/test/lib/TestDialect/TestPatterns.cpp index 584ff996fca..9b7fe8e94bf 100644 --- a/mlir/test/lib/TestDialect/TestPatterns.cpp +++ b/mlir/test/lib/TestDialect/TestPatterns.cpp @@ -247,6 +247,9 @@ static llvm::cl::opt clEnumValN(TestLegalizePatternDriver::ConversionMode::Partial, "partial", "Perform a partial conversion"))); -static mlir::PassRegistration legalizer_pass( - "test-legalize-patterns", "Run test dialect legalization patterns", - [] { return new TestLegalizePatternDriver(legalizerConversionMode); }); +static mlir::PassRegistration + legalizer_pass("test-legalize-patterns", + "Run test dialect legalization patterns", [] { + return llvm::make_unique( + legalizerConversionMode); + }); diff --git a/mlir/test/lib/Transforms/TestConstantFold.cpp b/mlir/test/lib/Transforms/TestConstantFold.cpp index 7d17f60c719..02c66ef86ac 100644 --- a/mlir/test/lib/Transforms/TestConstantFold.cpp +++ b/mlir/test/lib/Transforms/TestConstantFold.cpp @@ -74,8 +74,8 @@ void TestConstantFold::runOnFunction() { } /// Creates a constant folding pass. -FunctionPassBase *mlir::createTestConstantFoldPass() { - return new TestConstantFold(); +std::unique_ptr mlir::createTestConstantFoldPass() { + return llvm::make_unique(); } static PassRegistration diff --git a/mlir/test/lib/Transforms/TestLoopFusion.cpp b/mlir/test/lib/Transforms/TestLoopFusion.cpp index 39990968a34..bcb050769a1 100644 --- a/mlir/test/lib/Transforms/TestLoopFusion.cpp +++ b/mlir/test/lib/Transforms/TestLoopFusion.cpp @@ -58,8 +58,8 @@ struct TestLoopFusion : public FunctionPass { } // end anonymous namespace -FunctionPassBase *mlir::createTestLoopFusionPass() { - return new TestLoopFusion; +std::unique_ptr mlir::createTestLoopFusionPass() { + return llvm::make_unique(); } // Gathers all AffineForOps in 'block' at 'currLoopDepth' in 'depthToLoops'. diff --git a/mlir/test/lib/Transforms/TestLoopMapping.cpp b/mlir/test/lib/Transforms/TestLoopMapping.cpp index bf354670f92..a9da70a6d5e 100644 --- a/mlir/test/lib/Transforms/TestLoopMapping.cpp +++ b/mlir/test/lib/Transforms/TestLoopMapping.cpp @@ -62,4 +62,4 @@ public: static PassRegistration reg("test-mapping-to-processing-elements", "test mapping a single loop on a virtual processor grid", - [] { return new TestLoopMappingPass(); }); + [] { return llvm::make_unique(); }); diff --git a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp index d30eacc044d..e01ff66d825 100644 --- a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp +++ b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp @@ -55,9 +55,9 @@ public: }; } // end namespace -FunctionPassBase * +std::unique_ptr mlir::createSimpleParametricTilingPass(ArrayRef outerLoopSizes) { - return new SimpleParametricLoopTilingPass(outerLoopSizes); + return llvm::make_unique(outerLoopSizes); } static PassRegistration @@ -65,7 +65,8 @@ static PassRegistration "test application of parametric tiling to the outer loops so that the " "ranges of outer loops become static", [] { - auto *pass = new SimpleParametricLoopTilingPass({}); + auto pass = llvm::make_unique( + ArrayRef{}); pass->sizes.assign(clOuterLoopSizes.begin(), clOuterLoopSizes.end()); return pass; }); diff --git a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp index b51de412306..3bfe6b6fce3 100644 --- a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp +++ b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp @@ -290,8 +290,8 @@ void VectorizerTestPass::runOnFunction() { } } -FunctionPassBase *mlir::createVectorizerTestPass() { - return new VectorizerTestPass(); +std::unique_ptr mlir::createVectorizerTestPass() { + return llvm::make_unique(); } static PassRegistration -- cgit v1.2.3 From 79f53b0cf1fd204af0a09c8e085dd09a1ce0b6d9 Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Sat, 17 Aug 2019 11:05:35 -0700 Subject: Change from llvm::make_unique to std::make_unique Switch to C++14 standard method as llvm::make_unique has been removed ( https://reviews.llvm.org/D66259). Also mark some targets as c++14 to ease next integrates. PiperOrigin-RevId: 263953918 --- mlir/examples/Linalg/Linalg3/lib/Transforms.cpp | 2 +- mlir/examples/toy/Ch1/include/toy/Parser.h | 40 ++++++++++------------ mlir/examples/toy/Ch2/include/toy/Parser.h | 40 ++++++++++------------ mlir/examples/toy/Ch2/mlir/MLIRGen.cpp | 4 +-- mlir/examples/toy/Ch3/include/toy/Parser.h | 40 ++++++++++------------ mlir/examples/toy/Ch3/mlir/MLIRGen.cpp | 4 +-- mlir/examples/toy/Ch4/include/toy/Parser.h | 40 ++++++++++------------ mlir/examples/toy/Ch4/mlir/MLIRGen.cpp | 4 +-- mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp | 2 +- mlir/examples/toy/Ch5/include/toy/Parser.h | 40 ++++++++++------------ mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp | 2 +- mlir/examples/toy/Ch5/mlir/LateLowering.cpp | 2 +- mlir/examples/toy/Ch5/mlir/MLIRGen.cpp | 4 +-- mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp | 2 +- mlir/g3doc/Tutorials/Toy/Ch-4.md | 2 +- .../StandardToLLVM/ConvertStandardToLLVMPass.h | 2 +- mlir/include/mlir/IR/Dialect.h | 2 +- mlir/include/mlir/IR/PatternMatch.h | 2 +- mlir/include/mlir/Pass/AnalysisManager.h | 2 +- mlir/include/mlir/Pass/Pass.h | 2 +- mlir/include/mlir/Pass/PassRegistry.h | 2 +- .../Quantizer/Support/ConstraintAnalysisGraph.h | 6 ++-- mlir/lib/Analysis/AffineStructures.cpp | 2 +- mlir/lib/Analysis/Dominance.cpp | 2 +- mlir/lib/Analysis/Utils.cpp | 2 +- .../GPUToCUDA/ConvertKernelFuncToCubin.cpp | 4 +-- .../GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp | 2 +- .../GPUToCUDA/GenerateCubinAccessors.cpp | 2 +- .../Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp | 2 +- mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp | 6 ++-- .../StandardToLLVM/ConvertStandardToLLVM.cpp | 8 ++--- .../StandardToSPIRV/ConvertStandardToSPIRVPass.cpp | 2 +- .../lib/Dialect/GPU/Transforms/KernelOutlining.cpp | 2 +- .../Dialect/QuantOps/Transforms/ConvertConst.cpp | 2 +- .../QuantOps/Transforms/ConvertSimQuant.cpp | 2 +- mlir/lib/ExecutionEngine/ExecutionEngine.cpp | 12 +++---- mlir/lib/IR/Diagnostics.cpp | 2 +- mlir/lib/Linalg/Transforms/Fusion.cpp | 4 +-- mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp | 2 +- mlir/lib/Linalg/Transforms/LowerToLoops.cpp | 2 +- mlir/lib/Linalg/Transforms/Tiling.cpp | 4 +-- mlir/lib/Pass/Pass.cpp | 8 ++--- .../lib/Quantizer/Configurations/FxpMathConfig.cpp | 2 +- .../Quantizer/Support/ConstraintAnalysisGraph.cpp | 4 +-- .../Transforms/AddDefaultStatsTestPass.cpp | 2 +- .../Transforms/InferQuantizedTypesPass.cpp | 2 +- .../Transforms/RemoveInstrumentationPass.cpp | 2 +- mlir/lib/Support/FileUtilities.cpp | 4 +-- mlir/lib/TableGen/Pattern.cpp | 2 +- mlir/lib/Transforms/AffineDataCopyGeneration.cpp | 4 +-- mlir/lib/Transforms/CSE.cpp | 6 ++-- mlir/lib/Transforms/Canonicalizer.cpp | 2 +- mlir/lib/Transforms/LoopCoalescing.cpp | 2 +- mlir/lib/Transforms/LoopFusion.cpp | 4 +-- mlir/lib/Transforms/LoopInvariantCodeMotion.cpp | 2 +- mlir/lib/Transforms/LoopTiling.cpp | 2 +- mlir/lib/Transforms/LoopUnroll.cpp | 2 +- mlir/lib/Transforms/LoopUnrollAndJam.cpp | 2 +- mlir/lib/Transforms/LowerAffine.cpp | 2 +- mlir/lib/Transforms/LowerVectorTransfers.cpp | 2 +- mlir/lib/Transforms/MaterializeVectors.cpp | 2 +- mlir/lib/Transforms/MemRefDataFlowOpt.cpp | 2 +- mlir/lib/Transforms/PipelineDataTransfer.cpp | 2 +- mlir/lib/Transforms/SimplifyAffineStructures.cpp | 2 +- mlir/lib/Transforms/StripDebugInfo.cpp | 2 +- mlir/lib/Transforms/Utils/Utils.cpp | 4 +-- mlir/lib/Transforms/Vectorize.cpp | 2 +- mlir/test/lib/TestDialect/TestPatterns.cpp | 2 +- mlir/test/lib/Transforms/TestConstantFold.cpp | 2 +- mlir/test/lib/Transforms/TestLoopFusion.cpp | 2 +- mlir/test/lib/Transforms/TestLoopMapping.cpp | 2 +- .../lib/Transforms/TestLoopParametricTiling.cpp | 4 +-- .../test/lib/Transforms/TestVectorizationUtils.cpp | 2 +- mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp | 4 +-- 74 files changed, 195 insertions(+), 205 deletions(-) (limited to 'mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp') diff --git a/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp b/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp index 79fa4ca34f2..8731138bba5 100644 --- a/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp +++ b/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp @@ -301,5 +301,5 @@ Rewriter::matchAndRewrite(linalg::StoreOp store, } // namespace std::unique_ptr linalg::createLowerLinalgLoadStorePass() { - return llvm::make_unique(); + return std::make_unique(); } diff --git a/mlir/examples/toy/Ch1/include/toy/Parser.h b/mlir/examples/toy/Ch1/include/toy/Parser.h index bc7aa520624..75c660b7c78 100644 --- a/mlir/examples/toy/Ch1/include/toy/Parser.h +++ b/mlir/examples/toy/Ch1/include/toy/Parser.h @@ -62,7 +62,7 @@ public: if (lexer.getCurToken() != tok_eof) return parseError("nothing", "at end of module"); - return llvm::make_unique(std::move(functions)); + return std::make_unique(std::move(functions)); } private: @@ -81,7 +81,7 @@ private: if (!expr) return nullptr; } - return llvm::make_unique(std::move(loc), std::move(expr)); + return std::make_unique(std::move(loc), std::move(expr)); } /// Parse a literal number. @@ -89,7 +89,7 @@ private: std::unique_ptr ParseNumberExpr() { auto loc = lexer.getLastLocation(); auto Result = - llvm::make_unique(std::move(loc), lexer.getValue()); + std::make_unique(std::move(loc), lexer.getValue()); lexer.consume(tok_number); return std::move(Result); } @@ -157,8 +157,8 @@ private: "inside literal expession"); } } - return llvm::make_unique(std::move(loc), std::move(values), - std::move(dims)); + return std::make_unique(std::move(loc), std::move(values), + std::move(dims)); } /// parenexpr ::= '(' expression ')' @@ -184,7 +184,7 @@ private: lexer.getNextToken(); // eat identifier. if (lexer.getCurToken() != '(') // Simple variable ref. - return llvm::make_unique(std::move(loc), name); + return std::make_unique(std::move(loc), name); // This is a function call. lexer.consume(Token('(')); @@ -211,13 +211,11 @@ private: if (Args.size() != 1) return parseError("", "as argument to print()"); - return llvm::make_unique(std::move(loc), - std::move(Args[0])); + return std::make_unique(std::move(loc), std::move(Args[0])); } // Call to a user-defined function - return llvm::make_unique(std::move(loc), name, - std::move(Args)); + return std::make_unique(std::move(loc), name, std::move(Args)); } /// primary @@ -281,8 +279,8 @@ private: } // Merge LHS/RHS. - LHS = llvm::make_unique(std::move(loc), BinOp, - std::move(LHS), std::move(RHS)); + LHS = std::make_unique(std::move(loc), BinOp, + std::move(LHS), std::move(RHS)); } } @@ -302,7 +300,7 @@ private: return parseError("<", "to begin type"); lexer.getNextToken(); // eat < - auto type = llvm::make_unique(); + auto type = std::make_unique(); while (lexer.getCurToken() == tok_number) { type->shape.push_back(lexer.getValue()); @@ -341,11 +339,11 @@ private: } if (!type) - type = llvm::make_unique(); + type = std::make_unique(); lexer.consume(Token('=')); auto expr = ParseExpression(); - return llvm::make_unique(std::move(loc), std::move(id), - std::move(*type), std::move(expr)); + return std::make_unique(std::move(loc), std::move(id), + std::move(*type), std::move(expr)); } /// Parse a block: a list of expression separated by semicolons and wrapped in @@ -359,7 +357,7 @@ private: return parseError("{", "to begin block"); lexer.consume(Token('{')); - auto exprList = llvm::make_unique(); + auto exprList = std::make_unique(); // Ignore empty expressions: swallow sequences of semicolons. while (lexer.getCurToken() == ';') @@ -422,7 +420,7 @@ private: std::string name = lexer.getId(); auto loc = lexer.getLastLocation(); lexer.consume(tok_identifier); - auto decl = llvm::make_unique(std::move(loc), name); + auto decl = std::make_unique(std::move(loc), name); args.push_back(std::move(decl)); if (lexer.getCurToken() != ',') break; @@ -437,8 +435,8 @@ private: // success. lexer.consume(Token(')')); - return llvm::make_unique(std::move(loc), FnName, - std::move(args)); + return std::make_unique(std::move(loc), FnName, + std::move(args)); } /// Parse a function definition, we expect a prototype initiated with the @@ -451,7 +449,7 @@ private: return nullptr; if (auto block = ParseBlock()) - return llvm::make_unique(std::move(Proto), std::move(block)); + return std::make_unique(std::move(Proto), std::move(block)); return nullptr; } diff --git a/mlir/examples/toy/Ch2/include/toy/Parser.h b/mlir/examples/toy/Ch2/include/toy/Parser.h index bc7aa520624..75c660b7c78 100644 --- a/mlir/examples/toy/Ch2/include/toy/Parser.h +++ b/mlir/examples/toy/Ch2/include/toy/Parser.h @@ -62,7 +62,7 @@ public: if (lexer.getCurToken() != tok_eof) return parseError("nothing", "at end of module"); - return llvm::make_unique(std::move(functions)); + return std::make_unique(std::move(functions)); } private: @@ -81,7 +81,7 @@ private: if (!expr) return nullptr; } - return llvm::make_unique(std::move(loc), std::move(expr)); + return std::make_unique(std::move(loc), std::move(expr)); } /// Parse a literal number. @@ -89,7 +89,7 @@ private: std::unique_ptr ParseNumberExpr() { auto loc = lexer.getLastLocation(); auto Result = - llvm::make_unique(std::move(loc), lexer.getValue()); + std::make_unique(std::move(loc), lexer.getValue()); lexer.consume(tok_number); return std::move(Result); } @@ -157,8 +157,8 @@ private: "inside literal expession"); } } - return llvm::make_unique(std::move(loc), std::move(values), - std::move(dims)); + return std::make_unique(std::move(loc), std::move(values), + std::move(dims)); } /// parenexpr ::= '(' expression ')' @@ -184,7 +184,7 @@ private: lexer.getNextToken(); // eat identifier. if (lexer.getCurToken() != '(') // Simple variable ref. - return llvm::make_unique(std::move(loc), name); + return std::make_unique(std::move(loc), name); // This is a function call. lexer.consume(Token('(')); @@ -211,13 +211,11 @@ private: if (Args.size() != 1) return parseError("", "as argument to print()"); - return llvm::make_unique(std::move(loc), - std::move(Args[0])); + return std::make_unique(std::move(loc), std::move(Args[0])); } // Call to a user-defined function - return llvm::make_unique(std::move(loc), name, - std::move(Args)); + return std::make_unique(std::move(loc), name, std::move(Args)); } /// primary @@ -281,8 +279,8 @@ private: } // Merge LHS/RHS. - LHS = llvm::make_unique(std::move(loc), BinOp, - std::move(LHS), std::move(RHS)); + LHS = std::make_unique(std::move(loc), BinOp, + std::move(LHS), std::move(RHS)); } } @@ -302,7 +300,7 @@ private: return parseError("<", "to begin type"); lexer.getNextToken(); // eat < - auto type = llvm::make_unique(); + auto type = std::make_unique(); while (lexer.getCurToken() == tok_number) { type->shape.push_back(lexer.getValue()); @@ -341,11 +339,11 @@ private: } if (!type) - type = llvm::make_unique(); + type = std::make_unique(); lexer.consume(Token('=')); auto expr = ParseExpression(); - return llvm::make_unique(std::move(loc), std::move(id), - std::move(*type), std::move(expr)); + return std::make_unique(std::move(loc), std::move(id), + std::move(*type), std::move(expr)); } /// Parse a block: a list of expression separated by semicolons and wrapped in @@ -359,7 +357,7 @@ private: return parseError("{", "to begin block"); lexer.consume(Token('{')); - auto exprList = llvm::make_unique(); + auto exprList = std::make_unique(); // Ignore empty expressions: swallow sequences of semicolons. while (lexer.getCurToken() == ';') @@ -422,7 +420,7 @@ private: std::string name = lexer.getId(); auto loc = lexer.getLastLocation(); lexer.consume(tok_identifier); - auto decl = llvm::make_unique(std::move(loc), name); + auto decl = std::make_unique(std::move(loc), name); args.push_back(std::move(decl)); if (lexer.getCurToken() != ',') break; @@ -437,8 +435,8 @@ private: // success. lexer.consume(Token(')')); - return llvm::make_unique(std::move(loc), FnName, - std::move(args)); + return std::make_unique(std::move(loc), FnName, + std::move(args)); } /// Parse a function definition, we expect a prototype initiated with the @@ -451,7 +449,7 @@ private: return nullptr; if (auto block = ParseBlock()) - return llvm::make_unique(std::move(Proto), std::move(block)); + return std::make_unique(std::move(Proto), std::move(block)); return nullptr; } diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp index 7b874b92cc4..c09c4ad679c 100644 --- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp @@ -43,11 +43,11 @@ using namespace toy; using llvm::cast; using llvm::dyn_cast; using llvm::isa; -using llvm::make_unique; using llvm::ScopedHashTableScope; using llvm::SmallVector; using llvm::StringRef; using llvm::Twine; +using std::make_unique; namespace { @@ -172,7 +172,7 @@ private: // Create a builder for the function, it will be used throughout the codegen // to create operations in this function. - builder = llvm::make_unique(function.getBody()); + builder = std::make_unique(function.getBody()); // Emit the body of the function. if (!mlirGen(*funcAST.getBody())) { diff --git a/mlir/examples/toy/Ch3/include/toy/Parser.h b/mlir/examples/toy/Ch3/include/toy/Parser.h index bc7aa520624..75c660b7c78 100644 --- a/mlir/examples/toy/Ch3/include/toy/Parser.h +++ b/mlir/examples/toy/Ch3/include/toy/Parser.h @@ -62,7 +62,7 @@ public: if (lexer.getCurToken() != tok_eof) return parseError("nothing", "at end of module"); - return llvm::make_unique(std::move(functions)); + return std::make_unique(std::move(functions)); } private: @@ -81,7 +81,7 @@ private: if (!expr) return nullptr; } - return llvm::make_unique(std::move(loc), std::move(expr)); + return std::make_unique(std::move(loc), std::move(expr)); } /// Parse a literal number. @@ -89,7 +89,7 @@ private: std::unique_ptr ParseNumberExpr() { auto loc = lexer.getLastLocation(); auto Result = - llvm::make_unique(std::move(loc), lexer.getValue()); + std::make_unique(std::move(loc), lexer.getValue()); lexer.consume(tok_number); return std::move(Result); } @@ -157,8 +157,8 @@ private: "inside literal expession"); } } - return llvm::make_unique(std::move(loc), std::move(values), - std::move(dims)); + return std::make_unique(std::move(loc), std::move(values), + std::move(dims)); } /// parenexpr ::= '(' expression ')' @@ -184,7 +184,7 @@ private: lexer.getNextToken(); // eat identifier. if (lexer.getCurToken() != '(') // Simple variable ref. - return llvm::make_unique(std::move(loc), name); + return std::make_unique(std::move(loc), name); // This is a function call. lexer.consume(Token('(')); @@ -211,13 +211,11 @@ private: if (Args.size() != 1) return parseError("", "as argument to print()"); - return llvm::make_unique(std::move(loc), - std::move(Args[0])); + return std::make_unique(std::move(loc), std::move(Args[0])); } // Call to a user-defined function - return llvm::make_unique(std::move(loc), name, - std::move(Args)); + return std::make_unique(std::move(loc), name, std::move(Args)); } /// primary @@ -281,8 +279,8 @@ private: } // Merge LHS/RHS. - LHS = llvm::make_unique(std::move(loc), BinOp, - std::move(LHS), std::move(RHS)); + LHS = std::make_unique(std::move(loc), BinOp, + std::move(LHS), std::move(RHS)); } } @@ -302,7 +300,7 @@ private: return parseError("<", "to begin type"); lexer.getNextToken(); // eat < - auto type = llvm::make_unique(); + auto type = std::make_unique(); while (lexer.getCurToken() == tok_number) { type->shape.push_back(lexer.getValue()); @@ -341,11 +339,11 @@ private: } if (!type) - type = llvm::make_unique(); + type = std::make_unique(); lexer.consume(Token('=')); auto expr = ParseExpression(); - return llvm::make_unique(std::move(loc), std::move(id), - std::move(*type), std::move(expr)); + return std::make_unique(std::move(loc), std::move(id), + std::move(*type), std::move(expr)); } /// Parse a block: a list of expression separated by semicolons and wrapped in @@ -359,7 +357,7 @@ private: return parseError("{", "to begin block"); lexer.consume(Token('{')); - auto exprList = llvm::make_unique(); + auto exprList = std::make_unique(); // Ignore empty expressions: swallow sequences of semicolons. while (lexer.getCurToken() == ';') @@ -422,7 +420,7 @@ private: std::string name = lexer.getId(); auto loc = lexer.getLastLocation(); lexer.consume(tok_identifier); - auto decl = llvm::make_unique(std::move(loc), name); + auto decl = std::make_unique(std::move(loc), name); args.push_back(std::move(decl)); if (lexer.getCurToken() != ',') break; @@ -437,8 +435,8 @@ private: // success. lexer.consume(Token(')')); - return llvm::make_unique(std::move(loc), FnName, - std::move(args)); + return std::make_unique(std::move(loc), FnName, + std::move(args)); } /// Parse a function definition, we expect a prototype initiated with the @@ -451,7 +449,7 @@ private: return nullptr; if (auto block = ParseBlock()) - return llvm::make_unique(std::move(Proto), std::move(block)); + return std::make_unique(std::move(Proto), std::move(block)); return nullptr; } diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp index e3b06a7f7df..b3ba2f9281c 100644 --- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp @@ -44,11 +44,11 @@ using namespace toy; using llvm::cast; using llvm::dyn_cast; using llvm::isa; -using llvm::make_unique; using llvm::ScopedHashTableScope; using llvm::SmallVector; using llvm::StringRef; using llvm::Twine; +using std::make_unique; namespace { @@ -173,7 +173,7 @@ private: // Create a builder for the function, it will be used throughout the codegen // to create operations in this function. - builder = llvm::make_unique(function.getBody()); + builder = std::make_unique(function.getBody()); // Emit the body of the function. if (!mlirGen(*funcAST.getBody())) { diff --git a/mlir/examples/toy/Ch4/include/toy/Parser.h b/mlir/examples/toy/Ch4/include/toy/Parser.h index bc7aa520624..75c660b7c78 100644 --- a/mlir/examples/toy/Ch4/include/toy/Parser.h +++ b/mlir/examples/toy/Ch4/include/toy/Parser.h @@ -62,7 +62,7 @@ public: if (lexer.getCurToken() != tok_eof) return parseError("nothing", "at end of module"); - return llvm::make_unique(std::move(functions)); + return std::make_unique(std::move(functions)); } private: @@ -81,7 +81,7 @@ private: if (!expr) return nullptr; } - return llvm::make_unique(std::move(loc), std::move(expr)); + return std::make_unique(std::move(loc), std::move(expr)); } /// Parse a literal number. @@ -89,7 +89,7 @@ private: std::unique_ptr ParseNumberExpr() { auto loc = lexer.getLastLocation(); auto Result = - llvm::make_unique(std::move(loc), lexer.getValue()); + std::make_unique(std::move(loc), lexer.getValue()); lexer.consume(tok_number); return std::move(Result); } @@ -157,8 +157,8 @@ private: "inside literal expession"); } } - return llvm::make_unique(std::move(loc), std::move(values), - std::move(dims)); + return std::make_unique(std::move(loc), std::move(values), + std::move(dims)); } /// parenexpr ::= '(' expression ')' @@ -184,7 +184,7 @@ private: lexer.getNextToken(); // eat identifier. if (lexer.getCurToken() != '(') // Simple variable ref. - return llvm::make_unique(std::move(loc), name); + return std::make_unique(std::move(loc), name); // This is a function call. lexer.consume(Token('(')); @@ -211,13 +211,11 @@ private: if (Args.size() != 1) return parseError("", "as argument to print()"); - return llvm::make_unique(std::move(loc), - std::move(Args[0])); + return std::make_unique(std::move(loc), std::move(Args[0])); } // Call to a user-defined function - return llvm::make_unique(std::move(loc), name, - std::move(Args)); + return std::make_unique(std::move(loc), name, std::move(Args)); } /// primary @@ -281,8 +279,8 @@ private: } // Merge LHS/RHS. - LHS = llvm::make_unique(std::move(loc), BinOp, - std::move(LHS), std::move(RHS)); + LHS = std::make_unique(std::move(loc), BinOp, + std::move(LHS), std::move(RHS)); } } @@ -302,7 +300,7 @@ private: return parseError("<", "to begin type"); lexer.getNextToken(); // eat < - auto type = llvm::make_unique(); + auto type = std::make_unique(); while (lexer.getCurToken() == tok_number) { type->shape.push_back(lexer.getValue()); @@ -341,11 +339,11 @@ private: } if (!type) - type = llvm::make_unique(); + type = std::make_unique(); lexer.consume(Token('=')); auto expr = ParseExpression(); - return llvm::make_unique(std::move(loc), std::move(id), - std::move(*type), std::move(expr)); + return std::make_unique(std::move(loc), std::move(id), + std::move(*type), std::move(expr)); } /// Parse a block: a list of expression separated by semicolons and wrapped in @@ -359,7 +357,7 @@ private: return parseError("{", "to begin block"); lexer.consume(Token('{')); - auto exprList = llvm::make_unique(); + auto exprList = std::make_unique(); // Ignore empty expressions: swallow sequences of semicolons. while (lexer.getCurToken() == ';') @@ -422,7 +420,7 @@ private: std::string name = lexer.getId(); auto loc = lexer.getLastLocation(); lexer.consume(tok_identifier); - auto decl = llvm::make_unique(std::move(loc), name); + auto decl = std::make_unique(std::move(loc), name); args.push_back(std::move(decl)); if (lexer.getCurToken() != ',') break; @@ -437,8 +435,8 @@ private: // success. lexer.consume(Token(')')); - return llvm::make_unique(std::move(loc), FnName, - std::move(args)); + return std::make_unique(std::move(loc), FnName, + std::move(args)); } /// Parse a function definition, we expect a prototype initiated with the @@ -451,7 +449,7 @@ private: return nullptr; if (auto block = ParseBlock()) - return llvm::make_unique(std::move(Proto), std::move(block)); + return std::make_unique(std::move(Proto), std::move(block)); return nullptr; } diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp index e61d1aaa99d..fd385a47004 100644 --- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp @@ -44,11 +44,11 @@ using namespace toy; using llvm::cast; using llvm::dyn_cast; using llvm::isa; -using llvm::make_unique; using llvm::ScopedHashTableScope; using llvm::SmallVector; using llvm::StringRef; using llvm::Twine; +using std::make_unique; namespace { @@ -173,7 +173,7 @@ private: // Create a builder for the function, it will be used throughout the codegen // to create operations in this function. - builder = llvm::make_unique(function.getBody()); + builder = std::make_unique(function.getBody()); // Emit the body of the function. if (!mlirGen(*funcAST.getBody())) { diff --git a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp index 4a6bf8790e0..793f153291e 100644 --- a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp @@ -376,6 +376,6 @@ public: namespace toy { std::unique_ptr createShapeInferencePass() { - return llvm::make_unique(); + return std::make_unique(); } } // namespace toy diff --git a/mlir/examples/toy/Ch5/include/toy/Parser.h b/mlir/examples/toy/Ch5/include/toy/Parser.h index bc7aa520624..75c660b7c78 100644 --- a/mlir/examples/toy/Ch5/include/toy/Parser.h +++ b/mlir/examples/toy/Ch5/include/toy/Parser.h @@ -62,7 +62,7 @@ public: if (lexer.getCurToken() != tok_eof) return parseError("nothing", "at end of module"); - return llvm::make_unique(std::move(functions)); + return std::make_unique(std::move(functions)); } private: @@ -81,7 +81,7 @@ private: if (!expr) return nullptr; } - return llvm::make_unique(std::move(loc), std::move(expr)); + return std::make_unique(std::move(loc), std::move(expr)); } /// Parse a literal number. @@ -89,7 +89,7 @@ private: std::unique_ptr ParseNumberExpr() { auto loc = lexer.getLastLocation(); auto Result = - llvm::make_unique(std::move(loc), lexer.getValue()); + std::make_unique(std::move(loc), lexer.getValue()); lexer.consume(tok_number); return std::move(Result); } @@ -157,8 +157,8 @@ private: "inside literal expession"); } } - return llvm::make_unique(std::move(loc), std::move(values), - std::move(dims)); + return std::make_unique(std::move(loc), std::move(values), + std::move(dims)); } /// parenexpr ::= '(' expression ')' @@ -184,7 +184,7 @@ private: lexer.getNextToken(); // eat identifier. if (lexer.getCurToken() != '(') // Simple variable ref. - return llvm::make_unique(std::move(loc), name); + return std::make_unique(std::move(loc), name); // This is a function call. lexer.consume(Token('(')); @@ -211,13 +211,11 @@ private: if (Args.size() != 1) return parseError("", "as argument to print()"); - return llvm::make_unique(std::move(loc), - std::move(Args[0])); + return std::make_unique(std::move(loc), std::move(Args[0])); } // Call to a user-defined function - return llvm::make_unique(std::move(loc), name, - std::move(Args)); + return std::make_unique(std::move(loc), name, std::move(Args)); } /// primary @@ -281,8 +279,8 @@ private: } // Merge LHS/RHS. - LHS = llvm::make_unique(std::move(loc), BinOp, - std::move(LHS), std::move(RHS)); + LHS = std::make_unique(std::move(loc), BinOp, + std::move(LHS), std::move(RHS)); } } @@ -302,7 +300,7 @@ private: return parseError("<", "to begin type"); lexer.getNextToken(); // eat < - auto type = llvm::make_unique(); + auto type = std::make_unique(); while (lexer.getCurToken() == tok_number) { type->shape.push_back(lexer.getValue()); @@ -341,11 +339,11 @@ private: } if (!type) - type = llvm::make_unique(); + type = std::make_unique(); lexer.consume(Token('=')); auto expr = ParseExpression(); - return llvm::make_unique(std::move(loc), std::move(id), - std::move(*type), std::move(expr)); + return std::make_unique(std::move(loc), std::move(id), + std::move(*type), std::move(expr)); } /// Parse a block: a list of expression separated by semicolons and wrapped in @@ -359,7 +357,7 @@ private: return parseError("{", "to begin block"); lexer.consume(Token('{')); - auto exprList = llvm::make_unique(); + auto exprList = std::make_unique(); // Ignore empty expressions: swallow sequences of semicolons. while (lexer.getCurToken() == ';') @@ -422,7 +420,7 @@ private: std::string name = lexer.getId(); auto loc = lexer.getLastLocation(); lexer.consume(tok_identifier); - auto decl = llvm::make_unique(std::move(loc), name); + auto decl = std::make_unique(std::move(loc), name); args.push_back(std::move(decl)); if (lexer.getCurToken() != ',') break; @@ -437,8 +435,8 @@ private: // success. lexer.consume(Token(')')); - return llvm::make_unique(std::move(loc), FnName, - std::move(args)); + return std::make_unique(std::move(loc), FnName, + std::move(args)); } /// Parse a function definition, we expect a prototype initiated with the @@ -451,7 +449,7 @@ private: return nullptr; if (auto block = ParseBlock()) - return llvm::make_unique(std::move(Proto), std::move(block)); + return std::make_unique(std::move(Proto), std::move(block)); return nullptr; } diff --git a/mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp b/mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp index 96230fdfbea..c55a0dbd949 100644 --- a/mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp +++ b/mlir/examples/toy/Ch5/mlir/EarlyLowering.cpp @@ -143,6 +143,6 @@ struct EarlyLoweringPass : public FunctionPass { namespace toy { std::unique_ptr createEarlyLoweringPass() { - return llvm::make_unique(); + return std::make_unique(); } } // namespace toy diff --git a/mlir/examples/toy/Ch5/mlir/LateLowering.cpp b/mlir/examples/toy/Ch5/mlir/LateLowering.cpp index 29d83aeb663..8146e763303 100644 --- a/mlir/examples/toy/Ch5/mlir/LateLowering.cpp +++ b/mlir/examples/toy/Ch5/mlir/LateLowering.cpp @@ -455,6 +455,6 @@ struct LateLoweringPass : public ModulePass { namespace toy { std::unique_ptr createLateLoweringPass() { - return llvm::make_unique(); + return std::make_unique(); } } // namespace toy diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp index 8d7d169c7d2..88fb95048da 100644 --- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp @@ -44,11 +44,11 @@ using namespace toy; using llvm::cast; using llvm::dyn_cast; using llvm::isa; -using llvm::make_unique; using llvm::ScopedHashTableScope; using llvm::SmallVector; using llvm::StringRef; using llvm::Twine; +using std::make_unique; namespace { @@ -173,7 +173,7 @@ private: // Create a builder for the function, it will be used throughout the codegen // to create operations in this function. - builder = llvm::make_unique(function.getBody()); + builder = std::make_unique(function.getBody()); // Emit the body of the function. if (!mlirGen(*funcAST.getBody())) { diff --git a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp index 6437c0b3f73..b6808d713eb 100644 --- a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp @@ -376,6 +376,6 @@ public: namespace toy { std::unique_ptr createShapeInferencePass() { - return llvm::make_unique(); + return std::make_unique(); } } // namespace toy diff --git a/mlir/g3doc/Tutorials/Toy/Ch-4.md b/mlir/g3doc/Tutorials/Toy/Ch-4.md index 343d8f9e00b..1551e129379 100644 --- a/mlir/g3doc/Tutorials/Toy/Ch-4.md +++ b/mlir/g3doc/Tutorials/Toy/Ch-4.md @@ -112,7 +112,7 @@ method: /// supports, for use by the canonicalization pass. static void getCanonicalizationPatterns(mlir::OwningRewritePatternList &results, mlir::MLIRContext *context) { - results.push_back(llvm::make_unique(context)); + results.push_back(std::make_unique(context)); } ``` diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h index a08b2fb45d6..d2f416b35fe 100644 --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h @@ -74,7 +74,7 @@ template std::unique_ptr createConvertToLLVMIRPass(LLVMPatternListFiller patternListFiller) { return createConvertToLLVMIRPass(patternListFiller, [](MLIRContext *context) { - return llvm::make_unique(context); + return std::make_unique(context); }); } diff --git a/mlir/include/mlir/IR/Dialect.h b/mlir/include/mlir/IR/Dialect.h index 683701f3bc4..7ed647b61f9 100644 --- a/mlir/include/mlir/IR/Dialect.h +++ b/mlir/include/mlir/IR/Dialect.h @@ -262,7 +262,7 @@ protected: addInterfaces(); } template void addInterfaces() { - addInterface(llvm::make_unique(this)); + addInterface(std::make_unique(this)); } private: diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h index d47b924d888..5e4fe60a7bd 100644 --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -422,7 +422,7 @@ public: // FIXME: In c++17 this can be simplified by using 'fold expressions'. using dummy = int[]; (void)dummy{ - 0, (patterns.emplace_back(llvm::make_unique(arg, args...)), 0)...}; + 0, (patterns.emplace_back(std::make_unique(arg, args...)), 0)...}; } private: diff --git a/mlir/include/mlir/Pass/AnalysisManager.h b/mlir/include/mlir/Pass/AnalysisManager.h index 1f44515ceb1..ae98831f2b1 100644 --- a/mlir/include/mlir/Pass/AnalysisManager.h +++ b/mlir/include/mlir/Pass/AnalysisManager.h @@ -123,7 +123,7 @@ public: if (pi) pi->runBeforeAnalysis(getAnalysisName(), id, ir); - it->second = llvm::make_unique>(ir); + it->second = std::make_unique>(ir); if (pi) pi->runAfterAnalysis(getAnalysisName(), id, ir); diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h index f5c8d8bd1a6..3a3444af532 100644 --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -260,7 +260,7 @@ struct FunctionPass : public detail::PassModel { /// A clone method to create a copy of this pass. std::unique_ptr clone() const override { - return llvm::make_unique(*static_cast(this)); + return std::make_unique(*static_cast(this)); } }; diff --git a/mlir/include/mlir/Pass/PassRegistry.h b/mlir/include/mlir/Pass/PassRegistry.h index bd108f3e77f..eea3778d8b1 100644 --- a/mlir/include/mlir/Pass/PassRegistry.h +++ b/mlir/include/mlir/Pass/PassRegistry.h @@ -122,7 +122,7 @@ template struct PassRegistration { PassRegistration(StringRef arg, StringRef description) { PassAllocatorFunction constructor = [] { - return llvm::make_unique(); + return std::make_unique(); }; registerPass(arg, description, PassID::getID(), constructor); } diff --git a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h index 8f2a0e52b30..63f62dbeeeb 100644 --- a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h +++ b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h @@ -279,7 +279,7 @@ public: Args... args) { static_assert(std::is_convertible(), "T must be a CAGConstraingNode"); - T *constraintNode = addNode(llvm::make_unique(args...)); + T *constraintNode = addNode(std::make_unique(args...)); for (auto *anchor : anchors) anchor->addOutgoing(constraintNode); return constraintNode; @@ -292,7 +292,7 @@ public: Args... args) { static_assert(std::is_convertible(), "T must be a CAGConstraingNode"); - T *constraintNode = addNode(llvm::make_unique(args...)); + T *constraintNode = addNode(std::make_unique(args...)); fromAnchor->addOutgoing(constraintNode); for (auto *toAnchor : toAnchors) { constraintNode->addOutgoing(toAnchor); @@ -312,7 +312,7 @@ public: T *constraintNode; if (cluster.empty()) { // Create new. - constraintNode = addNode(llvm::make_unique()); + constraintNode = addNode(std::make_unique()); } else { // Merge existing. constraintNode = cluster[0]; diff --git a/mlir/lib/Analysis/AffineStructures.cpp b/mlir/lib/Analysis/AffineStructures.cpp index 46e45351d54..b2b2c6970b9 100644 --- a/mlir/lib/Analysis/AffineStructures.cpp +++ b/mlir/lib/Analysis/AffineStructures.cpp @@ -303,7 +303,7 @@ FlatAffineConstraints::FlatAffineConstraints( // Clones this object. std::unique_ptr FlatAffineConstraints::clone() const { - return llvm::make_unique(*this); + return std::make_unique(*this); } // Construct from an IntegerSet. diff --git a/mlir/lib/Analysis/Dominance.cpp b/mlir/lib/Analysis/Dominance.cpp index e384a56a71d..ead8d7e070c 100644 --- a/mlir/lib/Analysis/Dominance.cpp +++ b/mlir/lib/Analysis/Dominance.cpp @@ -45,7 +45,7 @@ void DominanceInfoBase::recalculate(Operation *op) { // Don't compute dominance if the region is empty. if (region.empty()) continue; - auto opDominance = llvm::make_unique(); + auto opDominance = std::make_unique(); opDominance->recalculate(region); dominanceInfos.try_emplace(®ion, std::move(opDominance)); } diff --git a/mlir/lib/Analysis/Utils.cpp b/mlir/lib/Analysis/Utils.cpp index fc36cc58f8e..85e39e37f65 100644 --- a/mlir/lib/Analysis/Utils.cpp +++ b/mlir/lib/Analysis/Utils.cpp @@ -913,7 +913,7 @@ static Optional getMemoryFootprintBytes(Block &block, } // Compute the memref region symbolic in any IVs enclosing this block. - auto region = llvm::make_unique(opInst->getLoc()); + auto region = std::make_unique(opInst->getLoc()); if (failed( region->compute(opInst, /*loopDepth=*/getNestingDepth(*block.begin())))) { diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp index 0223dee9ede..29771fe7ea5 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp @@ -106,7 +106,7 @@ OwnedCubin GpuKernelToCubinPass::compilePtxToCubinForTesting(const std::string &ptx, FuncOp &function) { const char data[] = "CUBIN"; - return llvm::make_unique>(data, data + sizeof(data) - 1); + return std::make_unique>(data, data + sizeof(data) - 1); } OwnedCubin GpuKernelToCubinPass::convertModuleToCubin(llvm::Module &llvmModule, @@ -165,7 +165,7 @@ GpuKernelToCubinPass::translateGpuKernelToCubinAnnotation(FuncOp &function) { std::unique_ptr mlir::createConvertGPUKernelToCubinPass(CubinGenerator cubinGenerator) { - return llvm::make_unique(cubinGenerator); + return std::make_unique(cubinGenerator); } static PassRegistration diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp index bf0816c8b71..b3864a39560 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp @@ -384,7 +384,7 @@ void GpuLaunchFuncToCudaCallsPass::translateGpuLaunchCalls( std::unique_ptr mlir::createConvertGpuLaunchFuncToCudaCallsPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp b/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp index 332a1324865..b819de2471e 100644 --- a/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp @@ -120,7 +120,7 @@ private: } // anonymous namespace std::unique_ptr createGenerateCubinAccessorPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp index 91671489f2d..32b0caf180a 100644 --- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp +++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp @@ -129,7 +129,7 @@ public: } // anonymous namespace std::unique_ptr createLowerGpuOpsToNVVMOpsPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp index 36869b87f1a..4b241e497c6 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp @@ -69,11 +69,11 @@ struct ForLoopMapper : public FunctionPass { std::unique_ptr mlir::createSimpleLoopsToGPUPass(unsigned numBlockDims, unsigned numThreadDims) { - return llvm::make_unique(numBlockDims, numThreadDims); + return std::make_unique(numBlockDims, numThreadDims); } static PassRegistration registration(PASS_NAME, "Convert top-level loops to GPU kernels", [] { - return llvm::make_unique(clNumBlockDims.getValue(), - clNumThreadDims.getValue()); + return std::make_unique(clNumBlockDims.getValue(), + clNumThreadDims.getValue()); }); diff --git a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp index 731c07e22c3..9ba06db7aba 100644 --- a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp @@ -1082,7 +1082,7 @@ Type LLVMTypeConverter::packFunctionResults(ArrayRef types) { /// Create an instance of LLVMTypeConverter in the given context. static std::unique_ptr makeStandardToLLVMTypeConverter(MLIRContext *context) { - return llvm::make_unique(context); + return std::make_unique(context); } namespace { @@ -1133,14 +1133,14 @@ struct LLVMLoweringPass : public ModulePass { } // end namespace std::unique_ptr mlir::createConvertToLLVMIRPass() { - return llvm::make_unique(); + return std::make_unique(); } std::unique_ptr mlir::createConvertToLLVMIRPass(LLVMPatternListFiller patternListFiller, LLVMTypeConverterMaker typeConverterMaker) { - return llvm::make_unique(patternListFiller, - typeConverterMaker); + return std::make_unique(patternListFiller, + typeConverterMaker); } static PassRegistration diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp index 3d4ef639cfa..174a4477560 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp @@ -50,7 +50,7 @@ void ConvertStandardToSPIRVPass::runOnModule() { std::unique_ptr mlir::spirv::createConvertStandardToSPIRVPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp index b7be427be1b..ea64ea8058b 100644 --- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp @@ -110,7 +110,7 @@ public: } // namespace std::unique_ptr mlir::createGpuKernelOutliningPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp index 9c48c672300..efb202b7491 100644 --- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp +++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp @@ -113,7 +113,7 @@ void ConvertConstPass::runOnFunction() { } std::unique_ptr mlir::quant::createConvertConstPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp index 924e6390d88..129671979ca 100644 --- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp +++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp @@ -105,7 +105,7 @@ void ConvertSimulatedQuantPass::runOnFunction() { std::unique_ptr mlir::quant::createConvertSimulatedQuantPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp index 99bf43de8c1..4450bf4d403 100644 --- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp @@ -132,13 +132,13 @@ public: : irTransformer(transform), objectLayer( session, - [this]() { return llvm::make_unique(session); }), + [this]() { return std::make_unique(session); }), compileLayer( session, objectLayer, llvm::orc::ConcurrentIRCompiler(std::move(machineBuilder))), transformLayer(session, compileLayer, makeIRTransformFunction()), dataLayout(layout), mangler(session, this->dataLayout), - threadSafeCtx(llvm::make_unique()) { + threadSafeCtx(std::make_unique()) { session.getMainJITDylib().addGenerator( cantFail(llvm::orc::DynamicLibrarySearchGenerator::GetForCurrentProcess( layout.getGlobalPrefix()))); @@ -156,9 +156,9 @@ public: if (!dataLayout) return dataLayout.takeError(); - return llvm::make_unique(std::move(*machineBuilder), - std::move(*dataLayout), transformer, - sharedLibPaths); + return std::make_unique(std::move(*machineBuilder), + std::move(*dataLayout), transformer, + sharedLibPaths); } // Add an LLVM module to the main library managed by the JIT engine. @@ -328,7 +328,7 @@ Expected> ExecutionEngine::create(ModuleOp m, std::function transformer, ArrayRef sharedLibPaths) { - auto engine = llvm::make_unique(); + auto engine = std::make_unique(); auto expectedJIT = impl::OrcJIT::createDefault(transformer, sharedLibPaths); if (!expectedJIT) return expectedJIT.takeError(); diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp index 28894066023..e9963ece379 100644 --- a/mlir/lib/IR/Diagnostics.cpp +++ b/mlir/lib/IR/Diagnostics.cpp @@ -160,7 +160,7 @@ Diagnostic &Diagnostic::attachNote(llvm::Optional noteLoc) { /// Append and return a new note. notes.push_back( - llvm::make_unique(*noteLoc, DiagnosticSeverity::Note)); + std::make_unique(*noteLoc, DiagnosticSeverity::Note)); return *notes.back(); } diff --git a/mlir/lib/Linalg/Transforms/Fusion.cpp b/mlir/lib/Linalg/Transforms/Fusion.cpp index 992c4664b10..a2a63d5bedf 100644 --- a/mlir/lib/Linalg/Transforms/Fusion.cpp +++ b/mlir/lib/Linalg/Transforms/Fusion.cpp @@ -352,12 +352,12 @@ LinalgFusionPass::LinalgFusionPass(ArrayRef sizes) std::unique_ptr mlir::linalg::createLinalgFusionPass(ArrayRef tileSizes) { - return llvm::make_unique(tileSizes); + return std::make_unique(tileSizes); } static PassRegistration pass("linalg-fusion", "Fuse operations in the linalg dialect", [] { - auto pass = llvm::make_unique(); + auto pass = std::make_unique(); pass->tileSizes.assign(clTileSizes.begin(), clTileSizes.end()); return pass; }); diff --git a/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp b/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp index 908191ccd66..de183f8f76e 100644 --- a/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp +++ b/mlir/lib/Linalg/Transforms/LowerToLLVMDialect.cpp @@ -735,7 +735,7 @@ void LowerLinalgToLLVMPass::runOnModule() { } std::unique_ptr mlir::linalg::createLowerLinalgToLLVMPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/Linalg/Transforms/LowerToLoops.cpp b/mlir/lib/Linalg/Transforms/LowerToLoops.cpp index 24e56b11063..faef51f5c8c 100644 --- a/mlir/lib/Linalg/Transforms/LowerToLoops.cpp +++ b/mlir/lib/Linalg/Transforms/LowerToLoops.cpp @@ -391,7 +391,7 @@ void LowerLinalgToLoopsPass::runOnFunction() { } std::unique_ptr mlir::linalg::createLowerLinalgToLoopsPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/Linalg/Transforms/Tiling.cpp b/mlir/lib/Linalg/Transforms/Tiling.cpp index 48c0da8f88f..051278e12f4 100644 --- a/mlir/lib/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Linalg/Transforms/Tiling.cpp @@ -530,12 +530,12 @@ LinalgTilingPass::LinalgTilingPass(ArrayRef sizes, bool promoteViews) { std::unique_ptr mlir::linalg::createLinalgTilingPass(ArrayRef tileSizes, bool promoteViews) { - return llvm::make_unique(tileSizes, promoteViews); + return std::make_unique(tileSizes, promoteViews); } static PassRegistration pass("linalg-tile", "Tile operations in the linalg dialect", [] { - auto pass = llvm::make_unique(); + auto pass = std::make_unique(); pass->tileSizes.assign(clTileSizes.begin(), clTileSizes.end()); pass->promoteViews = clPromoteFullTileViews; return pass; diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp index ba3b4742cc7..13f2738b002 100644 --- a/mlir/lib/Pass/Pass.cpp +++ b/mlir/lib/Pass/Pass.cpp @@ -283,7 +283,7 @@ void PassManager::addPass(std::unique_ptr pass) { // Add a verifier run if requested. if (verifyPasses) - mpe->addPass(llvm::make_unique()); + mpe->addPass(std::make_unique()); } /// Add a function pass to the current manager. This takes ownership over the @@ -295,11 +295,11 @@ void PassManager::addPass(std::unique_ptr pass) { /// Create an executor adaptor for this pass. if (disableThreads || !llvm::llvm_is_multithreaded()) { // If multi-threading is disabled, then create a synchronous adaptor. - auto adaptor = llvm::make_unique(); + auto adaptor = std::make_unique(); fpe = &adaptor->getFunctionExecutor(); addPass(std::unique_ptr{adaptor.release()}); } else { - auto adaptor = llvm::make_unique(); + auto adaptor = std::make_unique(); fpe = &adaptor->getFunctionExecutor(); addPass(std::unique_ptr{adaptor.release()}); } @@ -313,7 +313,7 @@ void PassManager::addPass(std::unique_ptr pass) { // Add a verifier run if requested. if (verifyPasses) - fpe->addPass(llvm::make_unique()); + fpe->addPass(std::make_unique()); } /// Add the provided instrumentation to the pass manager. This takes ownership diff --git a/mlir/lib/Quantizer/Configurations/FxpMathConfig.cpp b/mlir/lib/Quantizer/Configurations/FxpMathConfig.cpp index 6a0cff83ced..4119bde5ac1 100644 --- a/mlir/lib/Quantizer/Configurations/FxpMathConfig.cpp +++ b/mlir/lib/Quantizer/Configurations/FxpMathConfig.cpp @@ -283,5 +283,5 @@ struct FxpMathTargetConfigImpl : public FxpMathTargetConfig { std::unique_ptr FxpMathTargetConfig::create(SolverContext &context) { - return llvm::make_unique(context); + return std::make_unique(context); } diff --git a/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp b/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp index b4d48b78025..cfed2a2647c 100644 --- a/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp +++ b/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp @@ -68,7 +68,7 @@ CAGOperandAnchor *CAGSlice::getOperandAnchor(Operation *op, } // Create. - auto anchor = llvm::make_unique(op, operandIdx); + auto anchor = std::make_unique(op, operandIdx); auto *unowned = anchor.release(); unowned->nodeId = allNodes.size(); allNodes.push_back(unowned); @@ -87,7 +87,7 @@ CAGResultAnchor *CAGSlice::getResultAnchor(Operation *op, unsigned resultIdx) { } // Create. - auto anchor = llvm::make_unique(op, resultIdx); + auto anchor = std::make_unique(op, resultIdx); auto *unowned = anchor.release(); unowned->nodeId = allNodes.size(); allNodes.push_back(unowned); diff --git a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp index 4868d3be291..a2d38ce211d 100644 --- a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp +++ b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp @@ -119,7 +119,7 @@ void AddDefaultStatsPass::runWithConfig(SolverContext &solverContext, } std::unique_ptr mlir::quantizer::createAddDefaultStatsPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration pass( diff --git a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp index e1365e769b3..ff293fc93aa 100644 --- a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp +++ b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp @@ -288,7 +288,7 @@ void InferQuantizedTypesPass::transformResultType(CAGResultAnchor *anchor, std::unique_ptr mlir::quantizer::createInferQuantizedTypesPass( SolverContext &solverContext, const TargetConfiguration &config) { - return llvm::make_unique(solverContext, config); + return std::make_unique(solverContext, config); } static PassRegistration diff --git a/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp b/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp index 104a3b60404..b9fbf27d24f 100644 --- a/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp +++ b/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp @@ -68,7 +68,7 @@ void RemoveInstrumentationPass::runOnFunction() { std::unique_ptr mlir::quantizer::createRemoveInstrumentationPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/Support/FileUtilities.cpp b/mlir/lib/Support/FileUtilities.cpp index fb9f5cf86da..6f0dc93b235 100644 --- a/mlir/lib/Support/FileUtilities.cpp +++ b/mlir/lib/Support/FileUtilities.cpp @@ -43,8 +43,8 @@ mlir::openInputFile(StringRef inputFilename, std::string *errorMessage) { std::unique_ptr mlir::openOutputFile(StringRef outputFilename, std::string *errorMessage) { std::error_code error; - auto result = llvm::make_unique(outputFilename, error, - llvm::sys::fs::F_None); + auto result = std::make_unique(outputFilename, error, + llvm::sys::fs::F_None); if (error) { if (errorMessage) *errorMessage = "cannot open output file '" + outputFilename.str() + diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp index 344bcaa94b8..7fe3f6272d9 100644 --- a/mlir/lib/TableGen/Pattern.cpp +++ b/mlir/lib/TableGen/Pattern.cpp @@ -122,7 +122,7 @@ Operator &tblgen::DagNode::getDialectOp(RecordOperatorMap *mapper) const { auto it = mapper->find(opDef); if (it != mapper->end()) return *it->second; - return *mapper->try_emplace(opDef, llvm::make_unique(opDef)) + return *mapper->try_emplace(opDef, std::make_unique(opDef)) .first->second; } diff --git a/mlir/lib/Transforms/AffineDataCopyGeneration.cpp b/mlir/lib/Transforms/AffineDataCopyGeneration.cpp index e422bd24425..5030f722519 100644 --- a/mlir/lib/Transforms/AffineDataCopyGeneration.cpp +++ b/mlir/lib/Transforms/AffineDataCopyGeneration.cpp @@ -165,7 +165,7 @@ struct AffineDataCopyGeneration std::unique_ptr mlir::createAffineDataCopyGenerationPass( unsigned slowMemorySpace, unsigned fastMemorySpace, unsigned tagMemorySpace, int minDmaTransferSize, uint64_t fastMemCapacityBytes) { - return llvm::make_unique( + return std::make_unique( slowMemorySpace, fastMemorySpace, tagMemorySpace, minDmaTransferSize, fastMemCapacityBytes); } @@ -743,7 +743,7 @@ uint64_t AffineDataCopyGeneration::runOnBlock(Block::iterator begin, } // Compute the MemRefRegion accessed. - auto region = llvm::make_unique(opInst->getLoc()); + auto region = std::make_unique(opInst->getLoc()); if (failed(region->compute(opInst, copyDepth))) { LLVM_DEBUG(llvm::dbgs() << "Error obtaining memory region: semi-affine maps?\n"); diff --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp index 59658526c25..bb89aef7fef 100644 --- a/mlir/lib/Transforms/CSE.cpp +++ b/mlir/lib/Transforms/CSE.cpp @@ -213,7 +213,7 @@ void CSE::simplifyRegion(ScopedMapTy &knownValues, DominanceInfo &domInfo, std::deque> stack; // Process the nodes of the dom tree for this region. - stack.emplace_back(llvm::make_unique( + stack.emplace_back(std::make_unique( knownValues, domInfo.getRootNode(®ion))); while (!stack.empty()) { @@ -229,7 +229,7 @@ void CSE::simplifyRegion(ScopedMapTy &knownValues, DominanceInfo &domInfo, if (currentNode->childIterator != currentNode->node->end()) { auto *childNode = *(currentNode->childIterator++); stack.emplace_back( - llvm::make_unique(knownValues, childNode)); + std::make_unique(knownValues, childNode)); } else { // Finally, if the node and all of its children have been processed // then we delete the node. @@ -259,7 +259,7 @@ void CSE::runOnFunction() { } std::unique_ptr mlir::createCSEPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/Transforms/Canonicalizer.cpp b/mlir/lib/Transforms/Canonicalizer.cpp index 6f4a40f86f3..db6c8ee26e6 100644 --- a/mlir/lib/Transforms/Canonicalizer.cpp +++ b/mlir/lib/Transforms/Canonicalizer.cpp @@ -54,7 +54,7 @@ void Canonicalizer::runOnFunction() { /// Create a Canonicalizer pass. std::unique_ptr mlir::createCanonicalizerPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration pass("canonicalize", diff --git a/mlir/lib/Transforms/LoopCoalescing.cpp b/mlir/lib/Transforms/LoopCoalescing.cpp index eb52e8d5802..2ce0fbd011b 100644 --- a/mlir/lib/Transforms/LoopCoalescing.cpp +++ b/mlir/lib/Transforms/LoopCoalescing.cpp @@ -97,7 +97,7 @@ public: } // namespace std::unique_ptr mlir::createLoopCoalescingPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index 2736ebc0f55..98d01b24be0 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -114,8 +114,8 @@ struct LoopFusion : public FunctionPass { std::unique_ptr mlir::createLoopFusionPass(unsigned fastMemorySpace, uint64_t localBufSizeThreshold, bool maximalFusion) { - return llvm::make_unique(fastMemorySpace, localBufSizeThreshold, - maximalFusion); + return std::make_unique(fastMemorySpace, localBufSizeThreshold, + maximalFusion); } namespace { diff --git a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp index 09fe9afe808..fddc890edcf 100644 --- a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp +++ b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp @@ -77,7 +77,7 @@ static bool isMemRefDereferencingOp(Operation &op) { } std::unique_ptr mlir::createLoopInvariantCodeMotionPass() { - return llvm::make_unique(); + return std::make_unique(); } // Returns true if the individual op is loop invariant. diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp index d6ff9a94234..c521a8f6f5d 100644 --- a/mlir/lib/Transforms/LoopTiling.cpp +++ b/mlir/lib/Transforms/LoopTiling.cpp @@ -83,7 +83,7 @@ struct LoopTiling : public FunctionPass { /// Function. std::unique_ptr mlir::createLoopTilingPass(uint64_t cacheSizeBytes) { - return llvm::make_unique(cacheSizeBytes); + return std::make_unique(cacheSizeBytes); } // Move the loop body of AffineForOp 'src' from 'src' into the specified diff --git a/mlir/lib/Transforms/LoopUnroll.cpp b/mlir/lib/Transforms/LoopUnroll.cpp index c3db90e4b3a..fbe1dcc09f9 100644 --- a/mlir/lib/Transforms/LoopUnroll.cpp +++ b/mlir/lib/Transforms/LoopUnroll.cpp @@ -183,7 +183,7 @@ LogicalResult LoopUnroll::runOnAffineForOp(AffineForOp forOp) { std::unique_ptr mlir::createLoopUnrollPass( int unrollFactor, int unrollFull, const std::function &getUnrollFactor) { - return llvm::make_unique( + return std::make_unique( unrollFactor == -1 ? None : Optional(unrollFactor), unrollFull == -1 ? None : Optional(unrollFull), getUnrollFactor); } diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp index 362aa8683cc..ef92861adf9 100644 --- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp +++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp @@ -84,7 +84,7 @@ struct LoopUnrollAndJam : public FunctionPass { std::unique_ptr mlir::createLoopUnrollAndJamPass(int unrollJamFactor) { - return llvm::make_unique( + return std::make_unique( unrollJamFactor == -1 ? None : Optional(unrollJamFactor)); } diff --git a/mlir/lib/Transforms/LowerAffine.cpp b/mlir/lib/Transforms/LowerAffine.cpp index f24bc6d88da..1879ff63af2 100644 --- a/mlir/lib/Transforms/LowerAffine.cpp +++ b/mlir/lib/Transforms/LowerAffine.cpp @@ -530,7 +530,7 @@ class LowerAffinePass : public FunctionPass { /// Lowers If and For operations within a function into their lower level CFG /// equivalent blocks. std::unique_ptr mlir::createLowerAffinePass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/Transforms/LowerVectorTransfers.cpp b/mlir/lib/Transforms/LowerVectorTransfers.cpp index e941850b5b1..8cb50e805f8 100644 --- a/mlir/lib/Transforms/LowerVectorTransfers.cpp +++ b/mlir/lib/Transforms/LowerVectorTransfers.cpp @@ -374,7 +374,7 @@ struct LowerVectorTransfersPass } // end anonymous namespace std::unique_ptr mlir::createLowerVectorTransfersPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/Transforms/MaterializeVectors.cpp b/mlir/lib/Transforms/MaterializeVectors.cpp index 24b1f77c939..811c6fc7ad5 100644 --- a/mlir/lib/Transforms/MaterializeVectors.cpp +++ b/mlir/lib/Transforms/MaterializeVectors.cpp @@ -768,7 +768,7 @@ void MaterializeVectorsPass::runOnFunction() { std::unique_ptr mlir::createMaterializeVectorsPass(llvm::ArrayRef vectorSize) { - return llvm::make_unique(vectorSize); + return std::make_unique(vectorSize); } static PassRegistration diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp index b16dff93ee3..59a4fbe93ab 100644 --- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp +++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp @@ -89,7 +89,7 @@ struct MemRefDataFlowOpt : public FunctionPass { /// Creates a pass to perform optimizations relying on memref dataflow such as /// store to load forwarding, elimination of dead stores, and dead allocs. std::unique_ptr mlir::createMemRefDataFlowOptPass() { - return llvm::make_unique(); + return std::make_unique(); } // This is a straightforward implementation not optimized for speed. Optimize diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp index d4d91c9b0e2..db78f500867 100644 --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -50,7 +50,7 @@ struct PipelineDataTransfer : public FunctionPass { /// Creates a pass to pipeline explicit movement of data across levels of the /// memory hierarchy. std::unique_ptr mlir::createPipelineDataTransferPass() { - return llvm::make_unique(); + return std::make_unique(); } // Returns the position of the tag memref operand given a DMA operation. diff --git a/mlir/lib/Transforms/SimplifyAffineStructures.cpp b/mlir/lib/Transforms/SimplifyAffineStructures.cpp index 3cc9309a5d5..97193b49a74 100644 --- a/mlir/lib/Transforms/SimplifyAffineStructures.cpp +++ b/mlir/lib/Transforms/SimplifyAffineStructures.cpp @@ -89,7 +89,7 @@ struct SimplifyAffineStructures } // end anonymous namespace std::unique_ptr mlir::createSimplifyAffineStructuresPass() { - return llvm::make_unique(); + return std::make_unique(); } void SimplifyAffineStructures::runOnFunction() { diff --git a/mlir/lib/Transforms/StripDebugInfo.cpp b/mlir/lib/Transforms/StripDebugInfo.cpp index 21d8ef15219..15db8b58e88 100644 --- a/mlir/lib/Transforms/StripDebugInfo.cpp +++ b/mlir/lib/Transforms/StripDebugInfo.cpp @@ -39,7 +39,7 @@ void StripDebugInfo::runOnFunction() { /// Creates a pass to strip debug information from a function. std::unique_ptr mlir::createStripDebugInfoPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp index 250c76913c2..ffc19d1a1d3 100644 --- a/mlir/lib/Transforms/Utils/Utils.cpp +++ b/mlir/lib/Transforms/Utils/Utils.cpp @@ -82,11 +82,11 @@ bool mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, std::unique_ptr domInfo; std::unique_ptr postDomInfo; if (domInstFilter) - domInfo = llvm::make_unique( + domInfo = std::make_unique( domInstFilter->getParentOfType()); if (postDomInstFilter) - postDomInfo = llvm::make_unique( + postDomInfo = std::make_unique( postDomInstFilter->getParentOfType()); // The ops where memref replacement succeeds are replaced with new ones. diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp index 932f00bfcbe..d00174ba2fa 100644 --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -1278,7 +1278,7 @@ void Vectorize::runOnFunction() { std::unique_ptr mlir::createVectorizePass(llvm::ArrayRef virtualVectorSize) { - return llvm::make_unique(virtualVectorSize); + return std::make_unique(virtualVectorSize); } static PassRegistration diff --git a/mlir/test/lib/TestDialect/TestPatterns.cpp b/mlir/test/lib/TestDialect/TestPatterns.cpp index 9b7fe8e94bf..bde640b2691 100644 --- a/mlir/test/lib/TestDialect/TestPatterns.cpp +++ b/mlir/test/lib/TestDialect/TestPatterns.cpp @@ -250,6 +250,6 @@ static llvm::cl::opt static mlir::PassRegistration legalizer_pass("test-legalize-patterns", "Run test dialect legalization patterns", [] { - return llvm::make_unique( + return std::make_unique( legalizerConversionMode); }); diff --git a/mlir/test/lib/Transforms/TestConstantFold.cpp b/mlir/test/lib/Transforms/TestConstantFold.cpp index 02c66ef86ac..34480f09f57 100644 --- a/mlir/test/lib/Transforms/TestConstantFold.cpp +++ b/mlir/test/lib/Transforms/TestConstantFold.cpp @@ -75,7 +75,7 @@ void TestConstantFold::runOnFunction() { /// Creates a constant folding pass. std::unique_ptr mlir::createTestConstantFoldPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/test/lib/Transforms/TestLoopFusion.cpp b/mlir/test/lib/Transforms/TestLoopFusion.cpp index bcb050769a1..8b55d351bdc 100644 --- a/mlir/test/lib/Transforms/TestLoopFusion.cpp +++ b/mlir/test/lib/Transforms/TestLoopFusion.cpp @@ -59,7 +59,7 @@ struct TestLoopFusion : public FunctionPass { } // end anonymous namespace std::unique_ptr mlir::createTestLoopFusionPass() { - return llvm::make_unique(); + return std::make_unique(); } // Gathers all AffineForOps in 'block' at 'currLoopDepth' in 'depthToLoops'. diff --git a/mlir/test/lib/Transforms/TestLoopMapping.cpp b/mlir/test/lib/Transforms/TestLoopMapping.cpp index a9da70a6d5e..f4aa6469a99 100644 --- a/mlir/test/lib/Transforms/TestLoopMapping.cpp +++ b/mlir/test/lib/Transforms/TestLoopMapping.cpp @@ -62,4 +62,4 @@ public: static PassRegistration reg("test-mapping-to-processing-elements", "test mapping a single loop on a virtual processor grid", - [] { return llvm::make_unique(); }); + [] { return std::make_unique(); }); diff --git a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp index e01ff66d825..cf68ec1b9a7 100644 --- a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp +++ b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp @@ -57,7 +57,7 @@ public: std::unique_ptr mlir::createSimpleParametricTilingPass(ArrayRef outerLoopSizes) { - return llvm::make_unique(outerLoopSizes); + return std::make_unique(outerLoopSizes); } static PassRegistration @@ -65,7 +65,7 @@ static PassRegistration "test application of parametric tiling to the outer loops so that the " "ranges of outer loops become static", [] { - auto pass = llvm::make_unique( + auto pass = std::make_unique( ArrayRef{}); pass->sizes.assign(clOuterLoopSizes.begin(), clOuterLoopSizes.end()); return pass; diff --git a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp index 3bfe6b6fce3..6fe277dcfcb 100644 --- a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp +++ b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp @@ -291,7 +291,7 @@ void VectorizerTestPass::runOnFunction() { } std::unique_ptr mlir::createVectorizerTestPass() { - return llvm::make_unique(); + return std::make_unique(); } static PassRegistration diff --git a/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp b/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp index f75413fdaed..1d174eb8395 100644 --- a/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp +++ b/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp @@ -98,8 +98,8 @@ OwnedCubin compilePtxToCubin(const std::string ptx, FuncOp &function) { "cuLinkComplete"); char *cubinAsChar = static_cast(cubinData); - OwnedCubin result = llvm::make_unique>( - cubinAsChar, cubinAsChar + cubinSize); + OwnedCubin result = + std::make_unique>(cubinAsChar, cubinAsChar + cubinSize); // This will also destroy the cubin data. RETURN_ON_CUDA_ERROR(cuLinkDestroy(linkState), "cuLinkDestroy"); -- cgit v1.2.3 From f1b100c77ba005899c60f3dea74607d5daad3f52 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Fri, 13 Sep 2019 13:33:46 -0700 Subject: NFC: Finish replacing FunctionPassBase/ModulePassBase with OpPassBase. These directives were temporary during the generalization of FunctionPass/ModulePass to OpPass. PiperOrigin-RevId: 268970259 --- .../Linalg/Linalg1/include/linalg1/Passes.h | 3 +- .../Linalg/Linalg1/lib/ConvertToLLVMDialect.cpp | 2 +- .../Linalg/Linalg3/include/linalg3/Transforms.h | 4 +- mlir/examples/Linalg/Linalg3/lib/Transforms.cpp | 2 +- mlir/include/mlir/Analysis/Passes.h | 8 ++-- .../ControlFlowToCFG/ConvertControlFlowToCFG.h | 3 +- .../mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h | 8 ++-- .../mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h | 3 +- .../mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h | 3 +- .../StandardToLLVM/ConvertStandardToLLVMPass.h | 7 ++-- .../mlir/Conversion/VectorToLLVM/VectorToLLVM.h | 3 +- mlir/include/mlir/Dialect/FxpMathOps/Passes.h | 5 +-- mlir/include/mlir/Dialect/GPU/Passes.h | 3 +- mlir/include/mlir/Dialect/Linalg/Passes.h | 10 ++--- mlir/include/mlir/Dialect/QuantOps/Passes.h | 5 +-- mlir/include/mlir/Dialect/SPIRV/Passes.h | 2 +- mlir/include/mlir/Pass/Pass.h | 5 --- mlir/include/mlir/Quantizer/Transforms/Passes.h | 6 +-- mlir/include/mlir/Transforms/Passes.h | 45 +++++++++++----------- mlir/include/mlir/Transforms/ViewOpGraph.h | 3 +- mlir/include/mlir/Transforms/ViewRegionGraph.h | 7 ++-- mlir/lib/Analysis/MemRefBoundCheck.cpp | 4 +- mlir/lib/Analysis/TestMemRefDependenceCheck.cpp | 5 ++- mlir/lib/Analysis/TestParallelismDetection.cpp | 4 +- .../ControlFlowToCFG/ConvertControlFlowToCFG.cpp | 2 +- .../GPUToCUDA/ConvertKernelFuncToCubin.cpp | 2 +- .../GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp | 2 +- .../GPUToCUDA/GenerateCubinAccessors.cpp | 2 +- .../Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp | 2 +- mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp | 2 +- mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp | 2 +- .../StandardToLLVM/ConvertStandardToLLVM.cpp | 4 +- .../StandardToSPIRV/ConvertStandardToSPIRVPass.cpp | 2 +- mlir/lib/Conversion/VectorToLLVM/VectorToLLVM.cpp | 2 +- .../FxpMathOps/Transforms/LowerUniformRealMath.cpp | 4 +- .../lib/Dialect/GPU/Transforms/KernelOutlining.cpp | 2 +- mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp | 2 +- .../Linalg/Transforms/LowerToLLVMDialect.cpp | 3 +- .../lib/Dialect/Linalg/Transforms/LowerToLoops.cpp | 3 +- mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp | 2 +- .../Dialect/QuantOps/Transforms/ConvertConst.cpp | 2 +- .../QuantOps/Transforms/ConvertSimQuant.cpp | 2 +- .../Transforms/AddDefaultStatsTestPass.cpp | 3 +- .../Transforms/InferQuantizedTypesPass.cpp | 3 +- .../Transforms/RemoveInstrumentationPass.cpp | 2 +- mlir/lib/Transforms/AffineDataCopyGeneration.cpp | 2 +- mlir/lib/Transforms/CSE.cpp | 2 +- mlir/lib/Transforms/Canonicalizer.cpp | 2 +- mlir/lib/Transforms/LoopCoalescing.cpp | 2 +- mlir/lib/Transforms/LoopFusion.cpp | 2 +- mlir/lib/Transforms/LoopInvariantCodeMotion.cpp | 2 +- mlir/lib/Transforms/LoopTiling.cpp | 2 +- mlir/lib/Transforms/LoopUnroll.cpp | 2 +- mlir/lib/Transforms/LoopUnrollAndJam.cpp | 2 +- mlir/lib/Transforms/LowerAffine.cpp | 2 +- mlir/lib/Transforms/LowerVectorTransfers.cpp | 2 +- mlir/lib/Transforms/MaterializeVectors.cpp | 2 +- mlir/lib/Transforms/MemRefDataFlowOpt.cpp | 2 +- mlir/lib/Transforms/PipelineDataTransfer.cpp | 2 +- mlir/lib/Transforms/SimplifyAffineStructures.cpp | 2 +- mlir/lib/Transforms/StripDebugInfo.cpp | 2 +- mlir/lib/Transforms/Vectorize.cpp | 2 +- mlir/lib/Transforms/ViewOpGraph.cpp | 2 +- mlir/lib/Transforms/ViewRegionGraph.cpp | 6 +-- mlir/test/lib/Transforms/TestConstantFold.cpp | 2 +- mlir/test/lib/Transforms/TestLoopFusion.cpp | 2 +- .../lib/Transforms/TestLoopParametricTiling.cpp | 2 +- .../test/lib/Transforms/TestVectorizationUtils.cpp | 2 +- mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp | 2 +- 69 files changed, 119 insertions(+), 133 deletions(-) (limited to 'mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp') diff --git a/mlir/examples/Linalg/Linalg1/include/linalg1/Passes.h b/mlir/examples/Linalg/Linalg1/include/linalg1/Passes.h index 0347e182a50..8be517db917 100644 --- a/mlir/examples/Linalg/Linalg1/include/linalg1/Passes.h +++ b/mlir/examples/Linalg/Linalg1/include/linalg1/Passes.h @@ -29,12 +29,11 @@ namespace mlir { class ModuleOp; template class OpPassBase; -using ModulePassBase = OpPassBase; } // namespace mlir namespace linalg { -mlir::ModulePassBase *createLowerLinalgToLLVMPass(); +mlir::OpPassBase *createLowerLinalgToLLVMPass(); } // namespace linalg diff --git a/mlir/examples/Linalg/Linalg1/lib/ConvertToLLVMDialect.cpp b/mlir/examples/Linalg/Linalg1/lib/ConvertToLLVMDialect.cpp index 9073169b260..abbd9c95ac9 100644 --- a/mlir/examples/Linalg/Linalg1/lib/ConvertToLLVMDialect.cpp +++ b/mlir/examples/Linalg/Linalg1/lib/ConvertToLLVMDialect.cpp @@ -440,7 +440,7 @@ struct LowerLinalgToLLVMPass : public ModulePass { }; } // namespace -ModulePassBase *linalg::createLowerLinalgToLLVMPass() { +OpPassBase *linalg::createLowerLinalgToLLVMPass() { return new LowerLinalgToLLVMPass(); } diff --git a/mlir/examples/Linalg/Linalg3/include/linalg3/Transforms.h b/mlir/examples/Linalg/Linalg3/include/linalg3/Transforms.h index 849d65a6b6f..5381734721c 100644 --- a/mlir/examples/Linalg/Linalg3/include/linalg3/Transforms.h +++ b/mlir/examples/Linalg/Linalg3/include/linalg3/Transforms.h @@ -31,7 +31,6 @@ class Operation; class Value; template class OpPassBase; -using FunctionPassBase = OpPassBase; } // namespace mlir namespace linalg { @@ -75,7 +74,8 @@ void lowerToLoops(mlir::FuncOp f); /// Creates a pass that rewrites linalg.load and linalg.store to affine.load and /// affine.store operations. -std::unique_ptr createLowerLinalgLoadStorePass(); +std::unique_ptr> +createLowerLinalgLoadStorePass(); } // namespace linalg diff --git a/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp b/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp index ce2656520fa..184f1da528f 100644 --- a/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp +++ b/mlir/examples/Linalg/Linalg3/lib/Transforms.cpp @@ -300,6 +300,6 @@ Rewriter::matchAndRewrite(linalg::StoreOp store, } } // namespace -std::unique_ptr linalg::createLowerLinalgLoadStorePass() { +std::unique_ptr> linalg::createLowerLinalgLoadStorePass() { return std::make_unique(); } diff --git a/mlir/include/mlir/Analysis/Passes.h b/mlir/include/mlir/Analysis/Passes.h index 8c947e6c222..b233ab5f209 100644 --- a/mlir/include/mlir/Analysis/Passes.h +++ b/mlir/include/mlir/Analysis/Passes.h @@ -24,21 +24,21 @@ #define MLIR_ANALYSIS_PASSES_H #include "mlir/Support/LLVM.h" +#include namespace mlir { class FuncOp; template class OpPassBase; -using FunctionPassBase = OpPassBase; /// Creates a pass to check memref accesses in a Function. -FunctionPassBase *createMemRefBoundCheckPass(); +std::unique_ptr> createMemRefBoundCheckPass(); /// Creates a pass to check memref access dependences in a Function. -FunctionPassBase *createTestMemRefDependenceCheckPass(); +std::unique_ptr> createTestMemRefDependenceCheckPass(); /// Creates a pass to test parallelism detection; emits note for parallel loops. -FunctionPassBase *createParallelismDetectionTestPass(); +std::unique_ptr> createParallelismDetectionTestPass(); } // end namespace mlir diff --git a/mlir/include/mlir/Conversion/ControlFlowToCFG/ConvertControlFlowToCFG.h b/mlir/include/mlir/Conversion/ControlFlowToCFG/ConvertControlFlowToCFG.h index 56b0ed1d290..b6a29da3900 100644 --- a/mlir/include/mlir/Conversion/ControlFlowToCFG/ConvertControlFlowToCFG.h +++ b/mlir/include/mlir/Conversion/ControlFlowToCFG/ConvertControlFlowToCFG.h @@ -26,7 +26,6 @@ class FuncOp; struct LogicalResult; class MLIRContext; template class OpPassBase; -using FunctionPassBase = OpPassBase; class RewritePattern; // Owning list of rewriting patterns. @@ -39,7 +38,7 @@ void populateLoopToStdConversionPatterns(OwningRewritePatternList &patterns, MLIRContext *ctx); /// Creates a pass to convert loop.for, loop.if and loop.terminator ops to CFG. -std::unique_ptr createLowerToCFGPass(); +std::unique_ptr> createLowerToCFGPass(); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h b/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h index 8d5c5013599..161f68701d6 100644 --- a/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h +++ b/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h @@ -36,7 +36,6 @@ class LLVMDialect; } template class OpPassBase; -using ModulePassBase = OpPassBase; using OwnedCubin = std::unique_ptr>; using CubinGenerator = std::function; @@ -50,7 +49,7 @@ using CubinGenerator = std::function; /// attached as a string attribute named 'nvvm.cubin' to the kernel function. /// After the transformation, the body of the kernel function is removed (i.e., /// it is turned into a declaration). -std::unique_ptr +std::unique_ptr> createConvertGPUKernelToCubinPass(CubinGenerator cubinGenerator); /// Creates a pass to convert a gpu.launch_func operation into a sequence of @@ -59,11 +58,12 @@ createConvertGPUKernelToCubinPass(CubinGenerator cubinGenerator); /// This pass does not generate code to call CUDA directly but instead uses a /// small wrapper library that exports a stable and conveniently typed ABI /// ontop of CUDA. -std::unique_ptr createConvertGpuLaunchFuncToCudaCallsPass(); +std::unique_ptr> +createConvertGpuLaunchFuncToCudaCallsPass(); /// Creates a pass to augment a module with getter functions for all contained /// cubins as encoded via the 'nvvm.cubin' attribute. -std::unique_ptr createGenerateCubinAccessorPass(); +std::unique_ptr> createGenerateCubinAccessorPass(); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h index 01e50baa592..9a15b41f7de 100644 --- a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h +++ b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h @@ -25,14 +25,13 @@ class OwningRewritePatternList; class ModuleOp; template class OpPassBase; -using ModulePassBase = OpPassBase; /// Collect a set of patterns to convert from the GPU dialect to NVVM. void populateGpuToNVVMConversionPatterns(LLVMTypeConverter &converter, OwningRewritePatternList &patterns); /// Creates a pass that lowers GPU dialect operations to NVVM counterparts. -std::unique_ptr createLowerGpuOpsToNVVMOpsPass(); +std::unique_ptr> createLowerGpuOpsToNVVMOpsPass(); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h index 9ef21ea97b6..960a93dd566 100644 --- a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h +++ b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h @@ -22,7 +22,6 @@ namespace mlir { class FuncOp; template class OpPassBase; -using FunctionPassBase = OpPassBase; /// Create a pass that converts loop nests into GPU kernels. It considers /// top-level affine.for and linalg.for operations as roots of loop nests and @@ -32,7 +31,7 @@ using FunctionPassBase = OpPassBase; /// parallelization is performed, it is under the responsibility of the caller /// to strip-mine the loops and to perform the dependence analysis before /// calling the conversion. -std::unique_ptr +std::unique_ptr> createSimpleLoopsToGPUPass(unsigned numBlockDims, unsigned numThreadDims); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h index 589571d0a46..98e105aa2b5 100644 --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h @@ -34,7 +34,6 @@ struct LogicalResult; class MLIRContext; class ModuleOp; template class OpPassBase; -using ModulePassBase = OpPassBase; class RewritePattern; class Type; @@ -58,12 +57,12 @@ void populateStdToLLVMConversionPatterns(LLVMTypeConverter &converter, OwningRewritePatternList &patterns); /// Creates a pass to convert the Standard dialect into the LLVMIR dialect. -std::unique_ptr createLowerToLLVMPass(); +std::unique_ptr> createLowerToLLVMPass(); /// Creates a pass to convert operations to the LLVMIR dialect. The conversion /// is defined by a list of patterns and a type converter that will be obtained /// during the pass using the provided callbacks. -std::unique_ptr +std::unique_ptr> createLowerToLLVMPass(LLVMPatternListFiller patternListFiller, LLVMTypeConverterMaker typeConverterMaker); @@ -72,7 +71,7 @@ createLowerToLLVMPass(LLVMPatternListFiller patternListFiller, /// callback and an optional type conversion class, an instance is created /// during the pass. template -std::unique_ptr +std::unique_ptr> createLowerToLLVMPass(LLVMPatternListFiller patternListFiller) { return createLowerToLLVMPass(patternListFiller, [](MLIRContext *context) { return std::make_unique(context); diff --git a/mlir/include/mlir/Conversion/VectorToLLVM/VectorToLLVM.h b/mlir/include/mlir/Conversion/VectorToLLVM/VectorToLLVM.h index c781858a672..34d783ae131 100644 --- a/mlir/include/mlir/Conversion/VectorToLLVM/VectorToLLVM.h +++ b/mlir/include/mlir/Conversion/VectorToLLVM/VectorToLLVM.h @@ -23,14 +23,13 @@ class ModuleOp; class OwningRewritePatternList; template class OpPassBase; -using ModulePassBase = OpPassBase; /// Collect a set of patterns to convert from the Vector dialect to LLVM. void populateVectorToLLVMConversionPatterns(LLVMTypeConverter &converter, OwningRewritePatternList &patterns); /// Create a pass to convert vector operations to the LLVMIR dialect. -ModulePassBase *createLowerVectorToLLVMPass(); +OpPassBase *createLowerVectorToLLVMPass(); } // namespace mlir #endif // MLIR_CONVERSION_VECTORTOLLVM_VECTORTOLLVM_H_ diff --git a/mlir/include/mlir/Dialect/FxpMathOps/Passes.h b/mlir/include/mlir/Dialect/FxpMathOps/Passes.h index f4099ab7754..415b1c0b253 100644 --- a/mlir/include/mlir/Dialect/FxpMathOps/Passes.h +++ b/mlir/include/mlir/Dialect/FxpMathOps/Passes.h @@ -25,7 +25,6 @@ namespace mlir { class FuncOp; template class OpPassBase; -using FunctionPassBase = OpPassBase; namespace fxpmath { @@ -33,11 +32,11 @@ namespace fxpmath { /// arithmetic. This will leave unrecognized real math ops as-is and is /// typically followed by a pass that lowers any unrecognized ops to a pure /// floating point form. -FunctionPassBase *createLowerUniformRealMathPass(); +OpPassBase *createLowerUniformRealMathPass(); /// Creates a pass that lowers uniform-quantized qcast/dcast ops to equivalent /// operations that perform quantize/dequantize. -FunctionPassBase *createLowerUniformCastsPass(); +OpPassBase *createLowerUniformCastsPass(); } // namespace fxpmath } // namespace mlir diff --git a/mlir/include/mlir/Dialect/GPU/Passes.h b/mlir/include/mlir/Dialect/GPU/Passes.h index 14a9f013c99..7c8ce02db90 100644 --- a/mlir/include/mlir/Dialect/GPU/Passes.h +++ b/mlir/include/mlir/Dialect/GPU/Passes.h @@ -28,9 +28,8 @@ namespace mlir { class ModuleOp; template class OpPassBase; -using ModulePassBase = OpPassBase; -std::unique_ptr createGpuKernelOutliningPass(); +std::unique_ptr> createGpuKernelOutliningPass(); } // namespace mlir diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.h b/mlir/include/mlir/Dialect/Linalg/Passes.h index 118e278ef60..2b58df71a48 100644 --- a/mlir/include/mlir/Dialect/Linalg/Passes.h +++ b/mlir/include/mlir/Dialect/Linalg/Passes.h @@ -29,20 +29,18 @@ namespace mlir { class FuncOp; class ModuleOp; template class OpPassBase; -using FunctionPassBase = OpPassBase; -using ModulePassBase = OpPassBase; namespace linalg { -std::unique_ptr +std::unique_ptr> createLinalgFusionPass(ArrayRef tileSizes = {}); -std::unique_ptr +std::unique_ptr> createLinalgTilingPass(ArrayRef tileSizes = {}, bool promoteViews = false); -std::unique_ptr createLowerLinalgToLoopsPass(); +std::unique_ptr> createLowerLinalgToLoopsPass(); -std::unique_ptr createLowerLinalgToLLVMPass(); +std::unique_ptr> createLowerLinalgToLLVMPass(); } // namespace linalg } // namespace mlir diff --git a/mlir/include/mlir/Dialect/QuantOps/Passes.h b/mlir/include/mlir/Dialect/QuantOps/Passes.h index 5e5fd700f92..c57d7bf41fe 100644 --- a/mlir/include/mlir/Dialect/QuantOps/Passes.h +++ b/mlir/include/mlir/Dialect/QuantOps/Passes.h @@ -30,20 +30,19 @@ namespace mlir { class FuncOp; template class OpPassBase; -using FunctionPassBase = OpPassBase; namespace quant { /// Creates a pass that converts quantization simulation operations (i.e. /// FakeQuant and those like it) to casts into/out of supported QuantizedTypes. -std::unique_ptr createConvertSimulatedQuantPass(); +std::unique_ptr> createConvertSimulatedQuantPass(); /// Creates a pass that converts constants followed by a qbarrier to a /// constant whose value is quantized. This is typically one of the last /// passes done when lowering to express actual quantized arithmetic in a /// low level representation. Because it modifies the constant, it is /// destructive and cannot be undone. -std::unique_ptr createConvertConstPass(); +std::unique_ptr> createConvertConstPass(); } // namespace quant } // namespace mlir diff --git a/mlir/include/mlir/Dialect/SPIRV/Passes.h b/mlir/include/mlir/Dialect/SPIRV/Passes.h index 85f4f79ed59..ce4c19bf059 100644 --- a/mlir/include/mlir/Dialect/SPIRV/Passes.h +++ b/mlir/include/mlir/Dialect/SPIRV/Passes.h @@ -27,7 +27,7 @@ namespace mlir { namespace spirv { -std::unique_ptr createConvertStandardToSPIRVPass(); +std::unique_ptr> createConvertStandardToSPIRVPass(); } // namespace spirv } // namespace mlir diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h index fc440d5cb2e..441fd29bdd1 100644 --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -298,11 +298,6 @@ template struct ModulePass : public OpPass { /// Return the current module being transformed. ModuleOp getModule() { return this->getOperation(); } }; - -/// Using directives defining legacy base classes. -// TODO(riverriddle) These should be removed in favor of OpPassBase. -using FunctionPassBase = OpPassBase; -using ModulePassBase = OpPassBase; } // end namespace mlir #endif // MLIR_PASS_PASS_H diff --git a/mlir/include/mlir/Quantizer/Transforms/Passes.h b/mlir/include/mlir/Quantizer/Transforms/Passes.h index f894ea801e0..4fdea58daf4 100644 --- a/mlir/include/mlir/Quantizer/Transforms/Passes.h +++ b/mlir/include/mlir/Quantizer/Transforms/Passes.h @@ -33,17 +33,17 @@ class TargetConfiguration; /// Creates a pass that infers quantized types based on metadata discovered /// in the computation. -std::unique_ptr +std::unique_ptr> createInferQuantizedTypesPass(SolverContext &solverContext, const TargetConfiguration &config); /// Creates a pass which removes any instrumentation and hint ops which have /// no effect on final runtime. -std::unique_ptr createRemoveInstrumentationPass(); +std::unique_ptr> createRemoveInstrumentationPass(); /// Adds default (dummy) statistics to ops that can benefit from runtime stats. /// Meant for testing. -std::unique_ptr createAddDefaultStatsPass(); +std::unique_ptr> createAddDefaultStatsPass(); } // namespace quantizer } // namespace mlir diff --git a/mlir/include/mlir/Transforms/Passes.h b/mlir/include/mlir/Transforms/Passes.h index 0c777ec6035..2656a777d23 100644 --- a/mlir/include/mlir/Transforms/Passes.h +++ b/mlir/include/mlir/Transforms/Passes.h @@ -33,32 +33,30 @@ class AffineForOp; class FuncOp; class ModuleOp; template class OpPassBase; -using FunctionPassBase = OpPassBase; -using ModulePassBase = OpPassBase; /// Creates a constant folding pass. Note that this pass solely provides simple /// top-down constant folding functionality; it is intended to be used for /// testing purpose. Use Canonicalizer pass, which exploits more simplification /// opportunties exposed by constant folding, for the general cases. -std::unique_ptr createTestConstantFoldPass(); +std::unique_ptr> createTestConstantFoldPass(); /// Creates an instance of the Canonicalizer pass. -std::unique_ptr createCanonicalizerPass(); +std::unique_ptr> createCanonicalizerPass(); /// Creates a pass to perform common sub expression elimination. -std::unique_ptr createCSEPass(); +std::unique_ptr> createCSEPass(); /// Creates a pass to vectorize loops, operations and data types using a /// target-independent, n-D super-vector abstraction. -std::unique_ptr +std::unique_ptr> createVectorizePass(llvm::ArrayRef virtualVectorSize); /// Creates a pass to allow independent testing of vectorizer functionality with /// FileCheck. -std::unique_ptr createVectorizerTestPass(); +std::unique_ptr> createVectorizerTestPass(); /// Creates a pass to lower super-vectors to target-dependent HW vectors. -std::unique_ptr +std::unique_ptr> createMaterializeVectorsPass(llvm::ArrayRef vectorSize); /// Creates a loop unrolling pass with the provided parameters. @@ -67,75 +65,76 @@ createMaterializeVectorsPass(llvm::ArrayRef vectorSize); /// factors supplied through other means. If -1 is passed as the unrollFactor /// and no callback is provided, anything passed from the command-line (if at /// all) or the default unroll factor is used (LoopUnroll:kDefaultUnrollFactor). -std::unique_ptr createLoopUnrollPass( +std::unique_ptr> createLoopUnrollPass( int unrollFactor = -1, int unrollFull = -1, const std::function &getUnrollFactor = nullptr); /// Creates a loop unroll jam pass to unroll jam by the specified factor. A /// factor of -1 lets the pass use the default factor or the one on the command /// line if provided. -std::unique_ptr +std::unique_ptr> createLoopUnrollAndJamPass(int unrollJamFactor = -1); /// Creates a simplification pass for affine structures (maps and sets). In /// addition, this pass also normalizes memrefs to have the trivial (identity) /// layout map. -std::unique_ptr createSimplifyAffineStructuresPass(); +std::unique_ptr> createSimplifyAffineStructuresPass(); /// Creates a loop fusion pass which fuses loops. Buffers of size less than or /// equal to `localBufSizeThreshold` are promoted to memory space /// `fastMemorySpace'. -std::unique_ptr +std::unique_ptr> createLoopFusionPass(unsigned fastMemorySpace = 0, uint64_t localBufSizeThreshold = 0, bool maximalFusion = false); /// Creates a loop invariant code motion pass that hoists loop invariant /// instructions out of the loop. -std::unique_ptr createLoopInvariantCodeMotionPass(); +std::unique_ptr> createLoopInvariantCodeMotionPass(); /// Creates a pass to pipeline explicit movement of data across levels of the /// memory hierarchy. -std::unique_ptr createPipelineDataTransferPass(); +std::unique_ptr> createPipelineDataTransferPass(); /// Lowers affine control flow operations (ForStmt, IfStmt and AffineApplyOp) /// to equivalent lower-level constructs (flow of basic blocks and arithmetic /// primitives). -std::unique_ptr createLowerAffinePass(); +std::unique_ptr> createLowerAffinePass(); /// Creates a pass to perform tiling on loop nests. -std::unique_ptr createLoopTilingPass(uint64_t cacheSizeBytes); +std::unique_ptr> +createLoopTilingPass(uint64_t cacheSizeBytes); /// Creates a pass that performs parametric tiling so that the outermost loops /// have the given fixed number of iterations. Assumes outermost loop nests /// are permutable. -std::unique_ptr +std::unique_ptr> createSimpleParametricTilingPass(ArrayRef outerLoopSizes); /// Creates a pass that transforms perfectly nested loops with independent /// bounds into a single loop. -std::unique_ptr createLoopCoalescingPass(); +std::unique_ptr> createLoopCoalescingPass(); /// Performs packing (or explicit copying) of accessed memref regions into /// buffers in the specified faster memory space through either pointwise copies /// or DMA operations. -std::unique_ptr createAffineDataCopyGenerationPass( +std::unique_ptr> createAffineDataCopyGenerationPass( unsigned slowMemorySpace, unsigned fastMemorySpace, unsigned tagMemorySpace = 0, int minDmaTransferSize = 1024, uint64_t fastMemCapacityBytes = std::numeric_limits::max()); /// Creates a pass to lower VectorTransferReadOp and VectorTransferWriteOp. -std::unique_ptr createLowerVectorTransfersPass(); +std::unique_ptr> createLowerVectorTransfersPass(); /// Creates a pass to perform optimizations relying on memref dataflow such as /// store to load forwarding, elimination of dead stores, and dead allocs. -std::unique_ptr createMemRefDataFlowOptPass(); +std::unique_ptr> createMemRefDataFlowOptPass(); /// Creates a pass to strip debug information from a function. -std::unique_ptr createStripDebugInfoPass(); +std::unique_ptr> createStripDebugInfoPass(); /// Creates a pass which tests loop fusion utilities. -std::unique_ptr createTestLoopFusionPass(); +std::unique_ptr> createTestLoopFusionPass(); } // end namespace mlir diff --git a/mlir/include/mlir/Transforms/ViewOpGraph.h b/mlir/include/mlir/Transforms/ViewOpGraph.h index 9ba85c242ea..4f9856e9f93 100644 --- a/mlir/include/mlir/Transforms/ViewOpGraph.h +++ b/mlir/include/mlir/Transforms/ViewOpGraph.h @@ -30,7 +30,6 @@ namespace mlir { class Block; class ModuleOp; template class OpPassBase; -using ModulePassBase = OpPassBase; /// Displays the graph in a window. This is for use from the debugger and /// depends on Graphviz to generate the graph. @@ -42,7 +41,7 @@ llvm::raw_ostream &writeGraph(llvm::raw_ostream &os, Block &block, bool shortNames = false, const Twine &title = ""); /// Creates a pass to print op graphs. -std::unique_ptr +std::unique_ptr> createPrintOpGraphPass(llvm::raw_ostream &os = llvm::errs(), bool shortNames = false, const llvm::Twine &title = ""); diff --git a/mlir/include/mlir/Transforms/ViewRegionGraph.h b/mlir/include/mlir/Transforms/ViewRegionGraph.h index f54d35643eb..626afc31284 100644 --- a/mlir/include/mlir/Transforms/ViewRegionGraph.h +++ b/mlir/include/mlir/Transforms/ViewRegionGraph.h @@ -29,7 +29,6 @@ namespace mlir { class FuncOp; template class OpPassBase; -using FunctionPassBase = OpPassBase; class Region; /// Displays the CFG in a window. This is for use from the debugger and @@ -42,9 +41,9 @@ llvm::raw_ostream &writeGraph(llvm::raw_ostream &os, Region ®ion, bool shortNames = false, const Twine &title = ""); /// Creates a pass to print CFG graphs. -FunctionPassBase *createPrintCFGGraphPass(llvm::raw_ostream &os = llvm::errs(), - bool shortNames = false, - const llvm::Twine &title = ""); +OpPassBase * +createPrintCFGGraphPass(llvm::raw_ostream &os = llvm::errs(), + bool shortNames = false, const llvm::Twine &title = ""); } // end namespace mlir diff --git a/mlir/lib/Analysis/MemRefBoundCheck.cpp b/mlir/lib/Analysis/MemRefBoundCheck.cpp index 849407520da..1d115b13082 100644 --- a/mlir/lib/Analysis/MemRefBoundCheck.cpp +++ b/mlir/lib/Analysis/MemRefBoundCheck.cpp @@ -43,8 +43,8 @@ struct MemRefBoundCheck : public FunctionPass { } // end anonymous namespace -FunctionPassBase *mlir::createMemRefBoundCheckPass() { - return new MemRefBoundCheck(); +std::unique_ptr> mlir::createMemRefBoundCheckPass() { + return std::make_unique(); } void MemRefBoundCheck::runOnFunction() { diff --git a/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp b/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp index 477121fcc24..c73bf72f127 100644 --- a/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp +++ b/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp @@ -45,8 +45,9 @@ struct TestMemRefDependenceCheck } // end anonymous namespace -FunctionPassBase *mlir::createTestMemRefDependenceCheckPass() { - return new TestMemRefDependenceCheck(); +std::unique_ptr> +mlir::createTestMemRefDependenceCheckPass() { + return std::make_unique(); } // Returns a result string which represents the direction vector (if there was diff --git a/mlir/lib/Analysis/TestParallelismDetection.cpp b/mlir/lib/Analysis/TestParallelismDetection.cpp index 75982a8e0c5..a9f9ea94a45 100644 --- a/mlir/lib/Analysis/TestParallelismDetection.cpp +++ b/mlir/lib/Analysis/TestParallelismDetection.cpp @@ -36,8 +36,8 @@ struct TestParallelismDetection } // end anonymous namespace -FunctionPassBase *mlir::createParallelismDetectionTestPass() { - return new TestParallelismDetection(); +std::unique_ptr> mlir::createParallelismDetectionTestPass() { + return std::make_unique(); } // Walks the function and emits a note for all 'affine.for' ops detected as diff --git a/mlir/lib/Conversion/ControlFlowToCFG/ConvertControlFlowToCFG.cpp b/mlir/lib/Conversion/ControlFlowToCFG/ConvertControlFlowToCFG.cpp index 81426aaa243..cbff101e15d 100644 --- a/mlir/lib/Conversion/ControlFlowToCFG/ConvertControlFlowToCFG.cpp +++ b/mlir/lib/Conversion/ControlFlowToCFG/ConvertControlFlowToCFG.cpp @@ -270,7 +270,7 @@ void ControlFlowToCFGPass::runOnFunction() { signalPassFailure(); } -std::unique_ptr mlir::createLowerToCFGPass() { +std::unique_ptr> mlir::createLowerToCFGPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp index 29771fe7ea5..2cefa787ae8 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp @@ -163,7 +163,7 @@ GpuKernelToCubinPass::translateGpuKernelToCubinAnnotation(FuncOp &function) { return success(); } -std::unique_ptr +std::unique_ptr> mlir::createConvertGPUKernelToCubinPass(CubinGenerator cubinGenerator) { return std::make_unique(cubinGenerator); } diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp index ba0bc475168..5a435a5cc88 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp @@ -369,7 +369,7 @@ void GpuLaunchFuncToCudaCallsPass::translateGpuLaunchCalls( launchOp.erase(); } -std::unique_ptr +std::unique_ptr> mlir::createConvertGpuLaunchFuncToCudaCallsPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp b/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp index c4daf8af956..f8c6f5d15ff 100644 --- a/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/GenerateCubinAccessors.cpp @@ -110,7 +110,7 @@ private: } // anonymous namespace -std::unique_ptr createGenerateCubinAccessorPass() { +std::unique_ptr> createGenerateCubinAccessorPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp index ed7ebfbced1..1ae83ae9ae2 100644 --- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp +++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp @@ -162,7 +162,7 @@ void mlir::populateGpuToNVVMConversionPatterns( converter); } -std::unique_ptr mlir::createLowerGpuOpsToNVVMOpsPass() { +std::unique_ptr> mlir::createLowerGpuOpsToNVVMOpsPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp index 6746594ce87..544232e9860 100644 --- a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp @@ -166,7 +166,7 @@ void GPUToSPIRVPass::runOnModule() { } } -ModulePassBase *createGPUToSPIRVPass() { return new GPUToSPIRVPass(); } +OpPassBase *createGPUToSPIRVPass() { return new GPUToSPIRVPass(); } static PassRegistration pass("convert-gpu-to-spirv", "Convert GPU dialect to SPIR-V dialect"); diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp index 9dd9fdbbb87..6d4cb9d8256 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp @@ -66,7 +66,7 @@ struct ForLoopMapper : public FunctionPass { }; } // namespace -std::unique_ptr +std::unique_ptr> mlir::createSimpleLoopsToGPUPass(unsigned numBlockDims, unsigned numThreadDims) { return std::make_unique(numBlockDims, numThreadDims); diff --git a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp index 8d0dc6bb6b2..ce844e9dfc8 100644 --- a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp @@ -1222,11 +1222,11 @@ struct LLVMLoweringPass : public ModulePass { }; } // end namespace -std::unique_ptr mlir::createLowerToLLVMPass() { +std::unique_ptr> mlir::createLowerToLLVMPass() { return std::make_unique(); } -std::unique_ptr +std::unique_ptr> mlir::createLowerToLLVMPass(LLVMPatternListFiller patternListFiller, LLVMTypeConverterMaker typeConverterMaker) { return std::make_unique(patternListFiller, diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp index 174a4477560..dcecb84453f 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp @@ -48,7 +48,7 @@ void ConvertStandardToSPIRVPass::runOnModule() { } } -std::unique_ptr +std::unique_ptr> mlir::spirv::createConvertStandardToSPIRVPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/VectorToLLVM/VectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/VectorToLLVM.cpp index 174e3d6910c..2b15637ae14 100644 --- a/mlir/lib/Conversion/VectorToLLVM/VectorToLLVM.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/VectorToLLVM.cpp @@ -194,7 +194,7 @@ void LowerVectorToLLVMPass::runOnModule() { } } -ModulePassBase *mlir::createLowerVectorToLLVMPass() { +OpPassBase *mlir::createLowerVectorToLLVMPass() { return new LowerVectorToLLVMPass(); } diff --git a/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp b/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp index 83307da957b..a4fd98bb89e 100644 --- a/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp +++ b/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp @@ -372,7 +372,7 @@ void LowerUniformRealMathPass::runOnFunction() { applyPatternsGreedily(fn, patterns); } -FunctionPassBase *mlir::fxpmath::createLowerUniformRealMathPass() { +OpPassBase *mlir::fxpmath::createLowerUniformRealMathPass() { return new LowerUniformRealMathPass(); } @@ -392,7 +392,7 @@ void LowerUniformCastsPass::runOnFunction() { applyPatternsGreedily(fn, patterns); } -FunctionPassBase *mlir::fxpmath::createLowerUniformCastsPass() { +OpPassBase *mlir::fxpmath::createLowerUniformCastsPass() { return new LowerUniformCastsPass(); } diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp index 26449f6e6f1..4328fb39c29 100644 --- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp @@ -147,7 +147,7 @@ public: } // namespace -std::unique_ptr mlir::createGpuKernelOutliningPass() { +std::unique_ptr> mlir::createGpuKernelOutliningPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp index 0ce6c82679b..bfad37dffaf 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp @@ -349,7 +349,7 @@ LinalgFusionPass::LinalgFusionPass(ArrayRef sizes) this->tileSizes.assign(sizes.begin(), sizes.end()); } -std::unique_ptr +std::unique_ptr> mlir::linalg::createLinalgFusionPass(ArrayRef tileSizes) { return std::make_unique(tileSizes); } diff --git a/mlir/lib/Dialect/Linalg/Transforms/LowerToLLVMDialect.cpp b/mlir/lib/Dialect/Linalg/Transforms/LowerToLLVMDialect.cpp index 59d78d2e870..48b4eda8697 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/LowerToLLVMDialect.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LowerToLLVMDialect.cpp @@ -907,7 +907,8 @@ void LowerLinalgToLLVMPass::runOnModule() { } } -std::unique_ptr mlir::linalg::createLowerLinalgToLLVMPass() { +std::unique_ptr> +mlir::linalg::createLowerLinalgToLLVMPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Linalg/Transforms/LowerToLoops.cpp b/mlir/lib/Dialect/Linalg/Transforms/LowerToLoops.cpp index 54c0350504e..64773903f87 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/LowerToLoops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LowerToLoops.cpp @@ -390,7 +390,8 @@ void LowerLinalgToLoopsPass::runOnFunction() { } } -std::unique_ptr mlir::linalg::createLowerLinalgToLoopsPass() { +std::unique_ptr> +mlir::linalg::createLowerLinalgToLoopsPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp index cacec86dc35..f13ce6485bd 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -527,7 +527,7 @@ LinalgTilingPass::LinalgTilingPass(ArrayRef sizes, bool promoteViews) { this->promoteViews = promoteViews; } -std::unique_ptr +std::unique_ptr> mlir::linalg::createLinalgTilingPass(ArrayRef tileSizes, bool promoteViews) { return std::make_unique(tileSizes, promoteViews); diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp index e3a17b057d4..61636dcdd8b 100644 --- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp +++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp @@ -112,7 +112,7 @@ void ConvertConstPass::runOnFunction() { applyPatternsGreedily(func, patterns); } -std::unique_ptr mlir::quant::createConvertConstPass() { +std::unique_ptr> mlir::quant::createConvertConstPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp index 1000b1fabbf..e65f30d035b 100644 --- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp +++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp @@ -147,7 +147,7 @@ void ConvertSimulatedQuantPass::runOnFunction() { signalPassFailure(); } -std::unique_ptr +std::unique_ptr> mlir::quant::createConvertSimulatedQuantPass() { return std::make_unique(); } diff --git a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp index a2d38ce211d..696c1e2db3a 100644 --- a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp +++ b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp @@ -118,7 +118,8 @@ void AddDefaultStatsPass::runWithConfig(SolverContext &solverContext, }); } -std::unique_ptr mlir::quantizer::createAddDefaultStatsPass() { +std::unique_ptr> +mlir::quantizer::createAddDefaultStatsPass() { return std::make_unique(); } diff --git a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp index ff293fc93aa..7c449e32c4c 100644 --- a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp +++ b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp @@ -286,7 +286,8 @@ void InferQuantizedTypesPass::transformResultType(CAGResultAnchor *anchor, } } -std::unique_ptr mlir::quantizer::createInferQuantizedTypesPass( +std::unique_ptr> +mlir::quantizer::createInferQuantizedTypesPass( SolverContext &solverContext, const TargetConfiguration &config) { return std::make_unique(solverContext, config); } diff --git a/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp b/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp index b9fbf27d24f..0266520bec3 100644 --- a/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp +++ b/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp @@ -66,7 +66,7 @@ void RemoveInstrumentationPass::runOnFunction() { applyPatternsGreedily(func, patterns); } -std::unique_ptr +std::unique_ptr> mlir::quantizer::createRemoveInstrumentationPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/AffineDataCopyGeneration.cpp b/mlir/lib/Transforms/AffineDataCopyGeneration.cpp index fa483008d15..5b2a3185469 100644 --- a/mlir/lib/Transforms/AffineDataCopyGeneration.cpp +++ b/mlir/lib/Transforms/AffineDataCopyGeneration.cpp @@ -165,7 +165,7 @@ struct AffineDataCopyGeneration /// buffers in 'fastMemorySpace', and replaces memory operations to the former /// by the latter. Only load op's handled for now. /// TODO(bondhugula): extend this to store op's. -std::unique_ptr mlir::createAffineDataCopyGenerationPass( +std::unique_ptr> mlir::createAffineDataCopyGenerationPass( unsigned slowMemorySpace, unsigned fastMemorySpace, unsigned tagMemorySpace, int minDmaTransferSize, uint64_t fastMemCapacityBytes) { return std::make_unique( diff --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp index bb89aef7fef..0e6dae6c549 100644 --- a/mlir/lib/Transforms/CSE.cpp +++ b/mlir/lib/Transforms/CSE.cpp @@ -258,7 +258,7 @@ void CSE::runOnFunction() { markAnalysesPreserved(); } -std::unique_ptr mlir::createCSEPass() { +std::unique_ptr> mlir::createCSEPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/Canonicalizer.cpp b/mlir/lib/Transforms/Canonicalizer.cpp index db6c8ee26e6..7e08d363648 100644 --- a/mlir/lib/Transforms/Canonicalizer.cpp +++ b/mlir/lib/Transforms/Canonicalizer.cpp @@ -53,7 +53,7 @@ void Canonicalizer::runOnFunction() { } /// Create a Canonicalizer pass. -std::unique_ptr mlir::createCanonicalizerPass() { +std::unique_ptr> mlir::createCanonicalizerPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/LoopCoalescing.cpp b/mlir/lib/Transforms/LoopCoalescing.cpp index 8e220607f06..c1eec56526e 100644 --- a/mlir/lib/Transforms/LoopCoalescing.cpp +++ b/mlir/lib/Transforms/LoopCoalescing.cpp @@ -96,7 +96,7 @@ public: } // namespace -std::unique_ptr mlir::createLoopCoalescingPass() { +std::unique_ptr> mlir::createLoopCoalescingPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index a17481f89c9..8257bf05f5d 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -111,7 +111,7 @@ struct LoopFusion : public FunctionPass { } // end anonymous namespace -std::unique_ptr +std::unique_ptr> mlir::createLoopFusionPass(unsigned fastMemorySpace, uint64_t localBufSizeThreshold, bool maximalFusion) { return std::make_unique(fastMemorySpace, localBufSizeThreshold, diff --git a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp index 6150996a3d4..ed0adbf21a0 100644 --- a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp +++ b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp @@ -76,7 +76,7 @@ static bool isMemRefDereferencingOp(Operation &op) { return false; } -std::unique_ptr mlir::createLoopInvariantCodeMotionPass() { +std::unique_ptr> mlir::createLoopInvariantCodeMotionPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp index 02787b12e3d..d90e727b0ac 100644 --- a/mlir/lib/Transforms/LoopTiling.cpp +++ b/mlir/lib/Transforms/LoopTiling.cpp @@ -81,7 +81,7 @@ struct LoopTiling : public FunctionPass { /// Creates a pass to perform loop tiling on all suitable loop nests of a /// Function. -std::unique_ptr +std::unique_ptr> mlir::createLoopTilingPass(uint64_t cacheSizeBytes) { return std::make_unique(cacheSizeBytes); } diff --git a/mlir/lib/Transforms/LoopUnroll.cpp b/mlir/lib/Transforms/LoopUnroll.cpp index 5e132794149..40f48ada4d7 100644 --- a/mlir/lib/Transforms/LoopUnroll.cpp +++ b/mlir/lib/Transforms/LoopUnroll.cpp @@ -180,7 +180,7 @@ LogicalResult LoopUnroll::runOnAffineForOp(AffineForOp forOp) { return loopUnrollByFactor(forOp, kDefaultUnrollFactor); } -std::unique_ptr mlir::createLoopUnrollPass( +std::unique_ptr> mlir::createLoopUnrollPass( int unrollFactor, int unrollFull, const std::function &getUnrollFactor) { return std::make_unique( diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp index b6b2f3d4ad7..559f94bedf0 100644 --- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp +++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp @@ -82,7 +82,7 @@ struct LoopUnrollAndJam : public FunctionPass { }; } // end anonymous namespace -std::unique_ptr +std::unique_ptr> mlir::createLoopUnrollAndJamPass(int unrollJamFactor) { return std::make_unique( unrollJamFactor == -1 ? None : Optional(unrollJamFactor)); diff --git a/mlir/lib/Transforms/LowerAffine.cpp b/mlir/lib/Transforms/LowerAffine.cpp index e8a8284d392..2ed01a7cc32 100644 --- a/mlir/lib/Transforms/LowerAffine.cpp +++ b/mlir/lib/Transforms/LowerAffine.cpp @@ -529,7 +529,7 @@ class LowerAffinePass : public FunctionPass { /// Lowers If and For operations within a function into their lower level CFG /// equivalent blocks. -std::unique_ptr mlir::createLowerAffinePass() { +std::unique_ptr> mlir::createLowerAffinePass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/LowerVectorTransfers.cpp b/mlir/lib/Transforms/LowerVectorTransfers.cpp index 86ab2484e2a..126a29edffb 100644 --- a/mlir/lib/Transforms/LowerVectorTransfers.cpp +++ b/mlir/lib/Transforms/LowerVectorTransfers.cpp @@ -373,7 +373,7 @@ struct LowerVectorTransfersPass } // end anonymous namespace -std::unique_ptr mlir::createLowerVectorTransfersPass() { +std::unique_ptr> mlir::createLowerVectorTransfersPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/MaterializeVectors.cpp b/mlir/lib/Transforms/MaterializeVectors.cpp index bfdd5bf05f2..737af704992 100644 --- a/mlir/lib/Transforms/MaterializeVectors.cpp +++ b/mlir/lib/Transforms/MaterializeVectors.cpp @@ -766,7 +766,7 @@ void MaterializeVectorsPass::runOnFunction() { signalPassFailure(); } -std::unique_ptr +std::unique_ptr> mlir::createMaterializeVectorsPass(llvm::ArrayRef vectorSize) { return std::make_unique(vectorSize); } diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp index f922d508c69..58703394479 100644 --- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp +++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp @@ -88,7 +88,7 @@ struct MemRefDataFlowOpt : public FunctionPass { /// Creates a pass to perform optimizations relying on memref dataflow such as /// store to load forwarding, elimination of dead stores, and dead allocs. -std::unique_ptr mlir::createMemRefDataFlowOptPass() { +std::unique_ptr> mlir::createMemRefDataFlowOptPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp index fe201572ca3..d8d8dba9620 100644 --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -49,7 +49,7 @@ struct PipelineDataTransfer : public FunctionPass { /// Creates a pass to pipeline explicit movement of data across levels of the /// memory hierarchy. -std::unique_ptr mlir::createPipelineDataTransferPass() { +std::unique_ptr> mlir::createPipelineDataTransferPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/SimplifyAffineStructures.cpp b/mlir/lib/Transforms/SimplifyAffineStructures.cpp index 5eaf8f3460a..e243c1bec54 100644 --- a/mlir/lib/Transforms/SimplifyAffineStructures.cpp +++ b/mlir/lib/Transforms/SimplifyAffineStructures.cpp @@ -86,7 +86,7 @@ struct SimplifyAffineStructures } // end anonymous namespace -std::unique_ptr mlir::createSimplifyAffineStructuresPass() { +std::unique_ptr> mlir::createSimplifyAffineStructuresPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/StripDebugInfo.cpp b/mlir/lib/Transforms/StripDebugInfo.cpp index 15db8b58e88..772df3da3c7 100644 --- a/mlir/lib/Transforms/StripDebugInfo.cpp +++ b/mlir/lib/Transforms/StripDebugInfo.cpp @@ -38,7 +38,7 @@ void StripDebugInfo::runOnFunction() { } /// Creates a pass to strip debug information from a function. -std::unique_ptr mlir::createStripDebugInfoPass() { +std::unique_ptr> mlir::createStripDebugInfoPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp index 89e3da7477d..606cdb77a42 100644 --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -1276,7 +1276,7 @@ void Vectorize::runOnFunction() { LLVM_DEBUG(dbgs() << "\n"); } -std::unique_ptr +std::unique_ptr> mlir::createVectorizePass(llvm::ArrayRef virtualVectorSize) { return std::make_unique(virtualVectorSize); } diff --git a/mlir/lib/Transforms/ViewOpGraph.cpp b/mlir/lib/Transforms/ViewOpGraph.cpp index afb65c7d148..7f65a143a96 100644 --- a/mlir/lib/Transforms/ViewOpGraph.cpp +++ b/mlir/lib/Transforms/ViewOpGraph.cpp @@ -153,7 +153,7 @@ llvm::raw_ostream &mlir::writeGraph(llvm::raw_ostream &os, mlir::Block &block, return llvm::WriteGraph(os, &block, shortNames, title); } -std::unique_ptr +std::unique_ptr> mlir::createPrintOpGraphPass(llvm::raw_ostream &os, bool shortNames, const llvm::Twine &title) { return std::make_unique(os, shortNames, title); diff --git a/mlir/lib/Transforms/ViewRegionGraph.cpp b/mlir/lib/Transforms/ViewRegionGraph.cpp index 5a0e8e5ea99..91ac397200a 100644 --- a/mlir/lib/Transforms/ViewRegionGraph.cpp +++ b/mlir/lib/Transforms/ViewRegionGraph.cpp @@ -85,9 +85,9 @@ private: }; } // namespace -FunctionPassBase *mlir::createPrintCFGGraphPass(llvm::raw_ostream &os, - bool shortNames, - const llvm::Twine &title) { +OpPassBase *mlir::createPrintCFGGraphPass(llvm::raw_ostream &os, + bool shortNames, + const llvm::Twine &title) { return new PrintCFGPass(os, shortNames, title); } diff --git a/mlir/test/lib/Transforms/TestConstantFold.cpp b/mlir/test/lib/Transforms/TestConstantFold.cpp index b1c895257c3..15ecaabb149 100644 --- a/mlir/test/lib/Transforms/TestConstantFold.cpp +++ b/mlir/test/lib/Transforms/TestConstantFold.cpp @@ -74,7 +74,7 @@ void TestConstantFold::runOnFunction() { } /// Creates a constant folding pass. -std::unique_ptr mlir::createTestConstantFoldPass() { +std::unique_ptr> mlir::createTestConstantFoldPass() { return std::make_unique(); } diff --git a/mlir/test/lib/Transforms/TestLoopFusion.cpp b/mlir/test/lib/Transforms/TestLoopFusion.cpp index 604b42817e2..026a897fa8d 100644 --- a/mlir/test/lib/Transforms/TestLoopFusion.cpp +++ b/mlir/test/lib/Transforms/TestLoopFusion.cpp @@ -58,7 +58,7 @@ struct TestLoopFusion : public FunctionPass { } // end anonymous namespace -std::unique_ptr mlir::createTestLoopFusionPass() { +std::unique_ptr> mlir::createTestLoopFusionPass() { return std::make_unique(); } diff --git a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp index 6dc0bfde371..bce1e08402d 100644 --- a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp +++ b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp @@ -55,7 +55,7 @@ public: }; } // end namespace -std::unique_ptr +std::unique_ptr> mlir::createSimpleParametricTilingPass(ArrayRef outerLoopSizes) { return std::make_unique(outerLoopSizes); } diff --git a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp index 3f00eb01e11..4fdb66071bf 100644 --- a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp +++ b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp @@ -290,7 +290,7 @@ void VectorizerTestPass::runOnFunction() { } } -std::unique_ptr mlir::createVectorizerTestPass() { +std::unique_ptr> mlir::createVectorizerTestPass() { return std::make_unique(); } diff --git a/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp b/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp index df69407fa9e..deddc63eb10 100644 --- a/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp +++ b/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp @@ -140,7 +140,7 @@ static LogicalResult runMLIRPasses(ModuleOp m) { PassManager pm(m.getContext()); pm.addPass(createGpuKernelOutliningPass()); - pm.addPass(static_cast>( + pm.addPass(static_cast>>( std::make_unique())); pm.addPass(createConvertGPUKernelToCubinPass(&compilePtxToCubin)); pm.addPass(createGenerateCubinAccessorPass()); -- cgit v1.2.3 From 8c95223e3c9555165fb9f56db35c3c8e85ddd4c1 Mon Sep 17 00:00:00 2001 From: Feng Liu Date: Thu, 3 Oct 2019 20:28:40 -0700 Subject: Add `axis` attribute to the quant.stats op The first dim length of the axisStats attribute should equals to the slice size of the input argument when splitted by the axis dimension. PiperOrigin-RevId: 272798042 --- mlir/include/mlir/Dialect/QuantOps/QuantOps.td | 21 ++++++++++++---- mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp | 1 + .../Transforms/AddDefaultStatsTestPass.cpp | 6 ++--- mlir/test/Dialect/QuantOps/parse-ops-invalid.mlir | 28 +++++++++++++++++----- mlir/test/Dialect/QuantOps/parse-ops.mlir | 2 +- 5 files changed, 43 insertions(+), 15 deletions(-) (limited to 'mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp') diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantOps.td b/mlir/include/mlir/Dialect/QuantOps/QuantOps.td index d95b4527607..761f6ce3403 100644 --- a/mlir/include/mlir/Dialect/QuantOps/QuantOps.td +++ b/mlir/include/mlir/Dialect/QuantOps/QuantOps.td @@ -197,18 +197,23 @@ def quant_StatisticsOp : quant_Op<"stats", [SameOperandsAndResultType]> { Currently, only dim=2 is supported, which is interpreted as [min, max]. `layerStats` must be a rank 1 tensor: [2] - `axisStats` must be a rank 2 tensor: [N, 2], where N=the rank of `arg`. + `axisStats` must be a rank 2 tensor: [N, 2], where N=the slice size + splitted by the `axis` dimension. For example: + , axis=3 => N=2 + , axis=2 => N=6 }]; let arguments = (ins quant_RealValueType:$arg, ElementsAttr:$layerStats, - OptionalAttr:$axisStats); + OptionalAttr:$axisStats, + OptionalAttr:$axis); let results = (outs quant_RealValueType); let verifier = [{ auto tensorArg = arg()->getType().dyn_cast(); - auto argRank = tensorArg ? tensorArg.getRank() : 0; + if (!tensorArg) return emitOpError("arg needs to be tensor type."); + // Verify layerStats attribute. { auto layerStatsType = layerStats().getType(); @@ -222,15 +227,21 @@ def quant_StatisticsOp : quant_Op<"stats", [SameOperandsAndResultType]> { } // Verify axisStats (optional) attribute. if (axisStats()) { + if (!axis()) return emitOpError("axis must be specified for axisStats"); + + auto shape = tensorArg.getShape(); + auto argSliceSize = std::accumulate(std::next(shape.begin(), + axis()->getSExtValue()), shape.end(), 1, std::multiplies()); + auto axisStatsType = axisStats()->getType(); if (!axisStatsType.getElementType().isa()) { return emitOpError("axisStats must have a floating point element type"); } if (axisStatsType.getRank() != 2 || axisStatsType.getDimSize(1) != 2 || - axisStatsType.getDimSize(0) != argRank) { + axisStatsType.getDimSize(0) != argSliceSize) { return emitOpError("axisStats must have shape [N,2] " - "where N = the argument rank"); + "where N = the slice size defined by the axis dim"); } } return success(); diff --git a/mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp b/mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp index 3bd49d43adc..b618ac07f17 100644 --- a/mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp +++ b/mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp @@ -26,6 +26,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/MathExtras.h" +#include using namespace mlir; using namespace mlir::quant; diff --git a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp index 696c1e2db3a..a82a288caf3 100644 --- a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp +++ b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp @@ -82,8 +82,8 @@ void AddDefaultStatsPass::runWithConfig(SolverContext &solverContext, APFloat maxValue(1.0f); ElementsAttr layerStats = DenseFPElementsAttr::get( b.getTensorType({2}, b.getF32Type()), {minValue, maxValue}); - auto statsOp = - b.create(func.getLoc(), arg, layerStats, nullptr); + auto statsOp = b.create(func.getLoc(), arg, layerStats, + nullptr, nullptr); arg->replaceAllUsesWith(statsOp); // StatsOp contained a use to 'arg' so make sure to reset it after replacing @@ -109,7 +109,7 @@ void AddDefaultStatsPass::runWithConfig(SolverContext &solverContext, ElementsAttr layerStats = DenseFPElementsAttr::get( b.getTensorType({2}, b.getF32Type()), {minValue, maxValue}); auto statsOp = b.create(op->getLoc(), op->getResult(0), - layerStats, nullptr); + layerStats, nullptr, nullptr); originalResult->replaceAllUsesWith(statsOp); // StatsOp contained a use to 'op' so make sure to reset it after replacing diff --git a/mlir/test/Dialect/QuantOps/parse-ops-invalid.mlir b/mlir/test/Dialect/QuantOps/parse-ops-invalid.mlir index 7a9b96bb2cd..272c53070c7 100644 --- a/mlir/test/Dialect/QuantOps/parse-ops-invalid.mlir +++ b/mlir/test/Dialect/QuantOps/parse-ops-invalid.mlir @@ -40,15 +40,15 @@ func @invalidStatisticsMismatchedAxisType(%arg0: tensor<8x4x3xf32>) -> tensor<8x [-1, 1], [-8, 8], [-1, 0] - ]> : tensor<3x2xi8> + ]> : tensor<3x2xi8>, axis = 3 : i64 } : (tensor<8x4x3xf32>) -> tensor<8x4x3xf32> return %0 : tensor<8x4x3xf32> } // ----- -func @invalidStatisticsMismatchedAxisRank(%arg0: tensor<8x4x3xf32>) -> +func @invalidStatisticsMismatchedAxisSize(%arg0: tensor<8x4x3xf32>) -> tensor<8x4x3xf32> { - // expected-error@+1 {{axisStats must have shape [N,2] where N = the argument rank}} + // expected-error@+1 {{axisStats must have shape [N,2] where N = the slice size defined by the axis dim}} %0 = "quant.stats"(%arg0) { layerStats = dense<[-1.0, 1.0]> : tensor<2xf32>, axisStats = dense<[ @@ -56,7 +56,7 @@ func @invalidStatisticsMismatchedAxisRank(%arg0: tensor<8x4x3xf32>) -> [-8.0, 8.0], [-0.5, 0.5], [-2.0, 3.5] - ]> : tensor<4x2xf32> + ]> : tensor<4x2xf32>, axis = 3 : i64 } : (tensor<8x4x3xf32>) -> tensor<8x4x3xf32> return %0 : tensor<8x4x3xf32> } @@ -64,14 +64,30 @@ func @invalidStatisticsMismatchedAxisRank(%arg0: tensor<8x4x3xf32>) -> // ----- func @invalidStatisticsMismatchedAxisShape(%arg0: tensor<8x4x3xf32>) -> tensor<8x4x3xf32> { - // expected-error@+1 {{axisStats must have shape [N,2] where N = the argument rank}} + // expected-error@+1 {{axisStats must have shape [N,2] where N = the slice size defined by the axis dim}} %0 = "quant.stats"(%arg0) { layerStats = dense<[-1.0, 1.0]> : tensor<2xf32>, axisStats = dense<[ [-1.0, 1.0, 1.0], [-8.0, 8.0, 1.0], [-0.5, 0.5, 1.0] - ]> : tensor<3x3xf32> + ]> : tensor<3x3xf32>, axis = 3 : i64 } : (tensor<8x4x3xf32>) -> tensor<8x4x3xf32> return %0 : tensor<8x4x3xf32> } + +// ----- +func @axisIsRequiredForAxisStats(%arg0: tensor<8x4x3xf32>) -> tensor<8x4x3xf32> { + // expected-error@+1 {{axis must be specified for axisStats}} + %1 = "quant.stats"(%arg0) { + layerStats = dense<[-1.0, 1.0]> : tensor<2xf32>, + axisStats = dense<[ + [-1.0, 1.0], + [-8.0, 8.0], + [-0.5, 0.5] + ]> : tensor<3x2xf32> + } : (tensor<8x4x3xf32>) -> tensor<8x4x3xf32> + return %1 : tensor<8x4x3xf32> +} + +// ----- diff --git a/mlir/test/Dialect/QuantOps/parse-ops.mlir b/mlir/test/Dialect/QuantOps/parse-ops.mlir index 7d6d1abb253..bdcd751a969 100644 --- a/mlir/test/Dialect/QuantOps/parse-ops.mlir +++ b/mlir/test/Dialect/QuantOps/parse-ops.mlir @@ -50,7 +50,7 @@ func @validStatistics(%arg0: tensor<8x4x3xf32>) -> tensor<8x4x3xf32> { [-1.0, 1.0], [-8.0, 8.0], [-0.5, 0.5] - ]> : tensor<3x2xf32> + ]> : tensor<3x2xf32>, axis = 2 : i64 } : (tensor<8x4x3xf32>) -> tensor<8x4x3xf32> return %1 : tensor<8x4x3xf32> } -- cgit v1.2.3 From 2acc220f17bacbf933d024a68385a909b44352fd Mon Sep 17 00:00:00 2001 From: River Riddle Date: Thu, 17 Oct 2019 20:08:01 -0700 Subject: NFC: Remove trivial builder get methods. These don't add any value, and some are even more restrictive than the respective static 'get' method. PiperOrigin-RevId: 275391240 --- mlir/examples/toy/Ch2/mlir/Dialect.cpp | 10 +-- mlir/examples/toy/Ch2/mlir/MLIRGen.cpp | 6 +- mlir/examples/toy/Ch3/mlir/Dialect.cpp | 10 +-- mlir/examples/toy/Ch3/mlir/MLIRGen.cpp | 6 +- mlir/examples/toy/Ch4/mlir/Dialect.cpp | 10 +-- mlir/examples/toy/Ch4/mlir/MLIRGen.cpp | 6 +- mlir/examples/toy/Ch5/mlir/Dialect.cpp | 10 +-- mlir/examples/toy/Ch5/mlir/MLIRGen.cpp | 6 +- mlir/examples/toy/Ch6/mlir/Dialect.cpp | 10 +-- mlir/examples/toy/Ch6/mlir/MLIRGen.cpp | 6 +- .../StandardToSPIRV/ConvertStandardToSPIRV.h | 5 +- .../mlir/Dialect/AffineOps/AffineOpsBase.td | 2 +- mlir/include/mlir/Dialect/StandardOps/Ops.td | 4 +- mlir/include/mlir/IR/Builders.h | 28 +-------- mlir/include/mlir/IR/OpBase.td | 6 +- mlir/lib/Analysis/LoopAnalysis.cpp | 2 +- .../StandardToSPIRV/ConvertStandardToSPIRV.cpp | 2 +- mlir/lib/Dialect/AffineOps/AffineOps.cpp | 28 ++++----- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 6 +- mlir/lib/Dialect/SPIRV/SPIRVOps.cpp | 2 +- .../Dialect/SPIRV/Serialization/Deserializer.cpp | 8 +-- .../DecorateSPIRVCompositeTypeLayoutPass.cpp | 2 +- mlir/lib/Dialect/StandardOps/Ops.cpp | 8 +-- mlir/lib/Dialect/VectorOps/VectorOps.cpp | 4 +- mlir/lib/IR/Builders.cpp | 72 +--------------------- mlir/lib/IR/Function.cpp | 2 +- mlir/lib/IR/FunctionSupport.cpp | 2 +- mlir/lib/Parser/Parser.cpp | 20 +++--- .../Transforms/AddDefaultStatsTestPass.cpp | 4 +- mlir/lib/Transforms/LoopFusion.cpp | 6 +- mlir/lib/Transforms/LoopTiling.cpp | 4 +- mlir/lib/Transforms/LoopUnrollAndJam.cpp | 2 +- mlir/lib/Transforms/PipelineDataTransfer.cpp | 8 +-- mlir/lib/Transforms/Utils/LoopUtils.cpp | 24 ++++---- mlir/lib/Transforms/Utils/Utils.cpp | 14 ++--- mlir/lib/Transforms/Vectorize.cpp | 2 +- mlir/test/EDSC/builder-api-test.cpp | 2 +- mlir/unittests/Dialect/SPIRV/SerializationTest.cpp | 2 +- 38 files changed, 128 insertions(+), 223 deletions(-) (limited to 'mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp') diff --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp index 0603943270b..d0746bb3c79 100644 --- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp @@ -50,7 +50,7 @@ ToyDialect::ToyDialect(mlir::MLIRContext *ctx) : mlir::Dialect("toy", ctx) { /// expected to fill in order to build the operation. static void buildConstantOp(mlir::Builder *builder, mlir::OperationState &result, double value) { - auto dataType = builder->getTensorType({}, builder->getF64Type()); + auto dataType = RankedTensorType::get({}, builder->getF64Type()); auto dataAttribute = DenseElementsAttr::get(dataType, value); ConstantOp::build(builder, result, dataType, dataAttribute); } @@ -88,7 +88,7 @@ static mlir::LogicalResult verify(ConstantOp op) { static void buildAddOp(mlir::Builder *builder, mlir::OperationState &result, mlir::Value *lhs, mlir::Value *rhs) { - result.addTypes(builder->getTensorType(builder->getF64Type())); + result.addTypes(UnrankedTensorType::get(builder->getF64Type())); result.addOperands({lhs, rhs}); } @@ -96,14 +96,14 @@ static void buildGenericCallOp(mlir::Builder *builder, mlir::OperationState &result, StringRef callee, ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. - result.addTypes(builder->getTensorType(builder->getF64Type())); + result.addTypes(UnrankedTensorType::get(builder->getF64Type())); result.addOperands(arguments); result.addAttribute("callee", builder->getSymbolRefAttr(callee)); } static void buildMulOp(mlir::Builder *builder, mlir::OperationState &result, mlir::Value *lhs, mlir::Value *rhs) { - result.addTypes(builder->getTensorType(builder->getF64Type())); + result.addTypes(UnrankedTensorType::get(builder->getF64Type())); result.addOperands({lhs, rhs}); } @@ -144,7 +144,7 @@ static mlir::LogicalResult verify(ReturnOp op) { static void buildTransposeOp(mlir::Builder *builder, mlir::OperationState &result, mlir::Value *value) { - result.addTypes(builder->getTensorType(builder->getF64Type())); + result.addTypes(UnrankedTensorType::get(builder->getF64Type())); result.addOperands(value); } diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp index 5f12d0a8798..55391d72245 100644 --- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp @@ -282,7 +282,7 @@ private: // The type of this attribute is tensor of 64-bit floating-point with the // shape of the literal. mlir::Type elementType = builder.getF64Type(); - auto dataType = builder.getTensorType(lit.getDims(), elementType); + auto dataType = mlir::RankedTensorType::get(lit.getDims(), elementType); // This is the actual attribute that holds the list of values for this // tensor literal. @@ -443,10 +443,10 @@ private: mlir::Type getType(ArrayRef shape) { // If the shape is empty, then this type is unranked. if (shape.empty()) - return builder.getTensorType(builder.getF64Type()); + return mlir::UnrankedTensorType::get(builder.getF64Type()); // Otherwise, we use the given shape. - return builder.getTensorType(shape, builder.getF64Type()); + return mlir::RankedTensorType::get(shape, builder.getF64Type()); } /// Build an MLIR type from a Toy AST variable type (forward to the generic diff --git a/mlir/examples/toy/Ch3/mlir/Dialect.cpp b/mlir/examples/toy/Ch3/mlir/Dialect.cpp index 5ca50d961bf..37292a2d98a 100644 --- a/mlir/examples/toy/Ch3/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch3/mlir/Dialect.cpp @@ -50,7 +50,7 @@ ToyDialect::ToyDialect(mlir::MLIRContext *ctx) : mlir::Dialect("toy", ctx) { /// expected to fill in order to build the operation. static void buildConstantOp(mlir::Builder *builder, mlir::OperationState &state, double value) { - auto dataType = builder->getTensorType({}, builder->getF64Type()); + auto dataType = RankedTensorType::get({}, builder->getF64Type()); auto dataAttribute = DenseElementsAttr::get(dataType, value); ConstantOp::build(builder, state, dataType, dataAttribute); } @@ -88,7 +88,7 @@ static mlir::LogicalResult verify(ConstantOp op) { static void buildAddOp(mlir::Builder *builder, mlir::OperationState &state, mlir::Value *lhs, mlir::Value *rhs) { - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -96,14 +96,14 @@ static void buildGenericCallOp(mlir::Builder *builder, mlir::OperationState &state, StringRef callee, ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(arguments); state.addAttribute("callee", builder->getSymbolRefAttr(callee)); } static void buildMulOp(mlir::Builder *builder, mlir::OperationState &state, mlir::Value *lhs, mlir::Value *rhs) { - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -144,7 +144,7 @@ static mlir::LogicalResult verify(ReturnOp op) { static void buildTransposeOp(mlir::Builder *builder, mlir::OperationState &state, mlir::Value *value) { - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp index 5f12d0a8798..55391d72245 100644 --- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp @@ -282,7 +282,7 @@ private: // The type of this attribute is tensor of 64-bit floating-point with the // shape of the literal. mlir::Type elementType = builder.getF64Type(); - auto dataType = builder.getTensorType(lit.getDims(), elementType); + auto dataType = mlir::RankedTensorType::get(lit.getDims(), elementType); // This is the actual attribute that holds the list of values for this // tensor literal. @@ -443,10 +443,10 @@ private: mlir::Type getType(ArrayRef shape) { // If the shape is empty, then this type is unranked. if (shape.empty()) - return builder.getTensorType(builder.getF64Type()); + return mlir::UnrankedTensorType::get(builder.getF64Type()); // Otherwise, we use the given shape. - return builder.getTensorType(shape, builder.getF64Type()); + return mlir::RankedTensorType::get(shape, builder.getF64Type()); } /// Build an MLIR type from a Toy AST variable type (forward to the generic diff --git a/mlir/examples/toy/Ch4/mlir/Dialect.cpp b/mlir/examples/toy/Ch4/mlir/Dialect.cpp index e31cb917d89..254f92f08fd 100644 --- a/mlir/examples/toy/Ch4/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch4/mlir/Dialect.cpp @@ -100,7 +100,7 @@ ToyDialect::ToyDialect(mlir::MLIRContext *ctx) : mlir::Dialect("toy", ctx) { /// expected to fill in order to build the operation. static void buildConstantOp(mlir::Builder *builder, mlir::OperationState &state, double value) { - auto dataType = builder->getTensorType({}, builder->getF64Type()); + auto dataType = RankedTensorType::get({}, builder->getF64Type()); auto dataAttribute = DenseElementsAttr::get(dataType, value); ConstantOp::build(builder, state, dataType, dataAttribute); } @@ -142,7 +142,7 @@ static mlir::LogicalResult verify(ConstantOp op) { static void buildAddOp(mlir::Builder *builder, mlir::OperationState &state, mlir::Value *lhs, mlir::Value *rhs) { - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -154,7 +154,7 @@ static void buildGenericCallOp(mlir::Builder *builder, mlir::OperationState &state, StringRef callee, ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(arguments); state.addAttribute("callee", builder->getSymbolRefAttr(callee)); } @@ -171,7 +171,7 @@ Operation::operand_range GenericCallOp::getArgOperands() { return inputs(); } static void buildMulOp(mlir::Builder *builder, mlir::OperationState &state, mlir::Value *lhs, mlir::Value *rhs) { - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -235,7 +235,7 @@ static mlir::LogicalResult verify(ReturnOp op) { static void buildTransposeOp(mlir::Builder *builder, mlir::OperationState &state, mlir::Value *value) { - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp index 5f12d0a8798..55391d72245 100644 --- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp @@ -282,7 +282,7 @@ private: // The type of this attribute is tensor of 64-bit floating-point with the // shape of the literal. mlir::Type elementType = builder.getF64Type(); - auto dataType = builder.getTensorType(lit.getDims(), elementType); + auto dataType = mlir::RankedTensorType::get(lit.getDims(), elementType); // This is the actual attribute that holds the list of values for this // tensor literal. @@ -443,10 +443,10 @@ private: mlir::Type getType(ArrayRef shape) { // If the shape is empty, then this type is unranked. if (shape.empty()) - return builder.getTensorType(builder.getF64Type()); + return mlir::UnrankedTensorType::get(builder.getF64Type()); // Otherwise, we use the given shape. - return builder.getTensorType(shape, builder.getF64Type()); + return mlir::RankedTensorType::get(shape, builder.getF64Type()); } /// Build an MLIR type from a Toy AST variable type (forward to the generic diff --git a/mlir/examples/toy/Ch5/mlir/Dialect.cpp b/mlir/examples/toy/Ch5/mlir/Dialect.cpp index e31cb917d89..254f92f08fd 100644 --- a/mlir/examples/toy/Ch5/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch5/mlir/Dialect.cpp @@ -100,7 +100,7 @@ ToyDialect::ToyDialect(mlir::MLIRContext *ctx) : mlir::Dialect("toy", ctx) { /// expected to fill in order to build the operation. static void buildConstantOp(mlir::Builder *builder, mlir::OperationState &state, double value) { - auto dataType = builder->getTensorType({}, builder->getF64Type()); + auto dataType = RankedTensorType::get({}, builder->getF64Type()); auto dataAttribute = DenseElementsAttr::get(dataType, value); ConstantOp::build(builder, state, dataType, dataAttribute); } @@ -142,7 +142,7 @@ static mlir::LogicalResult verify(ConstantOp op) { static void buildAddOp(mlir::Builder *builder, mlir::OperationState &state, mlir::Value *lhs, mlir::Value *rhs) { - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -154,7 +154,7 @@ static void buildGenericCallOp(mlir::Builder *builder, mlir::OperationState &state, StringRef callee, ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(arguments); state.addAttribute("callee", builder->getSymbolRefAttr(callee)); } @@ -171,7 +171,7 @@ Operation::operand_range GenericCallOp::getArgOperands() { return inputs(); } static void buildMulOp(mlir::Builder *builder, mlir::OperationState &state, mlir::Value *lhs, mlir::Value *rhs) { - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -235,7 +235,7 @@ static mlir::LogicalResult verify(ReturnOp op) { static void buildTransposeOp(mlir::Builder *builder, mlir::OperationState &state, mlir::Value *value) { - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp index 5f12d0a8798..55391d72245 100644 --- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp @@ -282,7 +282,7 @@ private: // The type of this attribute is tensor of 64-bit floating-point with the // shape of the literal. mlir::Type elementType = builder.getF64Type(); - auto dataType = builder.getTensorType(lit.getDims(), elementType); + auto dataType = mlir::RankedTensorType::get(lit.getDims(), elementType); // This is the actual attribute that holds the list of values for this // tensor literal. @@ -443,10 +443,10 @@ private: mlir::Type getType(ArrayRef shape) { // If the shape is empty, then this type is unranked. if (shape.empty()) - return builder.getTensorType(builder.getF64Type()); + return mlir::UnrankedTensorType::get(builder.getF64Type()); // Otherwise, we use the given shape. - return builder.getTensorType(shape, builder.getF64Type()); + return mlir::RankedTensorType::get(shape, builder.getF64Type()); } /// Build an MLIR type from a Toy AST variable type (forward to the generic diff --git a/mlir/examples/toy/Ch6/mlir/Dialect.cpp b/mlir/examples/toy/Ch6/mlir/Dialect.cpp index e31cb917d89..254f92f08fd 100644 --- a/mlir/examples/toy/Ch6/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch6/mlir/Dialect.cpp @@ -100,7 +100,7 @@ ToyDialect::ToyDialect(mlir::MLIRContext *ctx) : mlir::Dialect("toy", ctx) { /// expected to fill in order to build the operation. static void buildConstantOp(mlir::Builder *builder, mlir::OperationState &state, double value) { - auto dataType = builder->getTensorType({}, builder->getF64Type()); + auto dataType = RankedTensorType::get({}, builder->getF64Type()); auto dataAttribute = DenseElementsAttr::get(dataType, value); ConstantOp::build(builder, state, dataType, dataAttribute); } @@ -142,7 +142,7 @@ static mlir::LogicalResult verify(ConstantOp op) { static void buildAddOp(mlir::Builder *builder, mlir::OperationState &state, mlir::Value *lhs, mlir::Value *rhs) { - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -154,7 +154,7 @@ static void buildGenericCallOp(mlir::Builder *builder, mlir::OperationState &state, StringRef callee, ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(arguments); state.addAttribute("callee", builder->getSymbolRefAttr(callee)); } @@ -171,7 +171,7 @@ Operation::operand_range GenericCallOp::getArgOperands() { return inputs(); } static void buildMulOp(mlir::Builder *builder, mlir::OperationState &state, mlir::Value *lhs, mlir::Value *rhs) { - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -235,7 +235,7 @@ static mlir::LogicalResult verify(ReturnOp op) { static void buildTransposeOp(mlir::Builder *builder, mlir::OperationState &state, mlir::Value *value) { - state.addTypes(builder->getTensorType(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp index 5f12d0a8798..55391d72245 100644 --- a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp @@ -282,7 +282,7 @@ private: // The type of this attribute is tensor of 64-bit floating-point with the // shape of the literal. mlir::Type elementType = builder.getF64Type(); - auto dataType = builder.getTensorType(lit.getDims(), elementType); + auto dataType = mlir::RankedTensorType::get(lit.getDims(), elementType); // This is the actual attribute that holds the list of values for this // tensor literal. @@ -443,10 +443,10 @@ private: mlir::Type getType(ArrayRef shape) { // If the shape is empty, then this type is unranked. if (shape.empty()) - return builder.getTensorType(builder.getF64Type()); + return mlir::UnrankedTensorType::get(builder.getF64Type()); // Otherwise, we use the given shape. - return builder.getTensorType(shape, builder.getF64Type()); + return mlir::RankedTensorType::get(shape, builder.getF64Type()); } /// Build an MLIR type from a Toy AST variable type (forward to the generic diff --git a/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h b/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h index e92ad03d776..63e63cfebb9 100644 --- a/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h +++ b/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h @@ -135,11 +135,10 @@ private: case spirv::BuiltIn::LocalInvocationId: case spirv::BuiltIn::GlobalInvocationId: { auto ptrType = spirv::PointerType::get( - builder.getVectorType({3}, builder.getIntegerType(32)), + VectorType::get({3}, builder.getIntegerType(32)), spirv::StorageClass::Input); newVarOp = builder.create( - loc, builder.getTypeAttr(ptrType), builder.getStringAttr(name), - nullptr); + loc, TypeAttr::get(ptrType), builder.getStringAttr(name), nullptr); newVarOp.setAttr( convertToSnakeCase(stringifyDecoration(spirv::Decoration::BuiltIn)), builder.getStringAttr(stringifyBuiltIn(builtin))); diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOpsBase.td b/mlir/include/mlir/Dialect/AffineOps/AffineOpsBase.td index 2ac1d379c12..fb4439a43ac 100644 --- a/mlir/include/mlir/Dialect/AffineOps/AffineOpsBase.td +++ b/mlir/include/mlir/Dialect/AffineOps/AffineOpsBase.td @@ -33,7 +33,7 @@ def AffineMapAttr : Attr< CPred<"$_self.isa()">, "AffineMap attribute"> { let storageType = [{ AffineMapAttr }]; let returnType = [{ AffineMap }]; - let constBuilderCall = "$_builder.getAffineMapAttr($0)"; + let constBuilderCall = "AffineMapAttr::get($0)"; } def AffineMapArrayAttr : TypedArrayAttrBasegetType().cast(); - auto resultType = builder->getTensorType(memrefType.getShape(), - memrefType.getElementType()); + auto resultType = RankedTensorType::get(memrefType.getShape(), + memrefType.getElementType()); result.addOperands(memref); result.addTypes(resultType); }]>]; diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h index dcc5280f49e..0005a395e70 100644 --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -80,12 +80,6 @@ public: IntegerType getI1Type(); IntegerType getIntegerType(unsigned width); FunctionType getFunctionType(ArrayRef inputs, ArrayRef results); - MemRefType getMemRefType(ArrayRef shape, Type elementType, - ArrayRef affineMapComposition = {}, - unsigned memorySpace = 0); - VectorType getVectorType(ArrayRef shape, Type elementType); - RankedTensorType getTensorType(ArrayRef shape, Type elementType); - UnrankedTensorType getTensorType(Type elementType); TupleType getTupleType(ArrayRef elementTypes); NoneType getNoneType(); @@ -105,22 +99,10 @@ public: FloatAttr getFloatAttr(Type type, double value); FloatAttr getFloatAttr(Type type, const APFloat &value); StringAttr getStringAttr(StringRef bytes); - StringAttr getStringAttr(StringRef bytes, Type type); ArrayAttr getArrayAttr(ArrayRef value); - AffineMapAttr getAffineMapAttr(AffineMap map); - IntegerSetAttr getIntegerSetAttr(IntegerSet set); - TypeAttr getTypeAttr(Type type); SymbolRefAttr getSymbolRefAttr(Operation *value); SymbolRefAttr getSymbolRefAttr(StringRef value); - ElementsAttr getDenseElementsAttr(ShapedType type, - ArrayRef values); - ElementsAttr getDenseIntElementsAttr(ShapedType type, - ArrayRef values); - ElementsAttr getSparseElementsAttr(ShapedType type, - DenseIntElementsAttr indices, - DenseElementsAttr values); - ElementsAttr getOpaqueElementsAttr(Dialect *dialect, ShapedType type, - StringRef bytes); + // Returns a 0-valued attribute of the given `type`. This function only // supports boolean, integer, and 16-/32-/64-bit float types, and vector or // ranked tensor of them. Returns null attribute otherwise. @@ -149,9 +131,6 @@ public: AffineExpr getAffineSymbolExpr(unsigned position); AffineExpr getAffineConstantExpr(int64_t constant); - AffineMap getAffineMap(unsigned dimCount, unsigned symbolCount, - ArrayRef results); - // Special cases of affine maps and integer sets /// Returns a zero result affine map with no dimensions or symbols: () -> (). AffineMap getEmptyAffineMap(); @@ -175,11 +154,6 @@ public: /// returns: (d0, d1)[s0] -> (d0 + 2, d1 + s0 + 2) AffineMap getShiftedAffineMap(AffineMap map, int64_t shift); - // Integer set. - IntegerSet getIntegerSet(unsigned dimCount, unsigned symbolCount, - ArrayRef constraints, - ArrayRef isEq); - // TODO: Helpers for affine map/exprs, etc. protected: MLIRContext *context; }; diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index dbb1e7f0a73..c1bd04fea4e 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -970,7 +970,7 @@ class IntElementsAttr : ElementsAttrBase< // Note that this is only constructing scalar elements attribute. let constBuilderCall = "DenseElementsAttr::get(" - "$_builder.getTensorType({}, $_builder.getIntegerType(" # width # ")), " + "RankedTensorType::get({}, $_builder.getIntegerType(" # width # ")), " "llvm::makeArrayRef($0)).cast()"; let convertFromStorage = "$_self"; } @@ -989,7 +989,7 @@ class FloatElementsAttr : ElementsAttrBase< // Note that this is only constructing scalar elements attribute. let constBuilderCall = "DenseElementsAttr::get(" - "$_builder.getTensorType({}, $_builder.getF" # width # "Type())," + "RankedTensorType::get({}, $_builder.getF" # width # "Type())," "llvm::makeArrayRef($0))"; let convertFromStorage = "$_self"; } @@ -1013,7 +1013,7 @@ class RankedFloatElementsAttr dims> : ElementsAttrBase< let returnType = [{ DenseFPElementsAttr }]; let constBuilderCall = "DenseElementsAttr::get(" - "$_builder.getTensorType({" # StrJoinInt.result # + "RankedTensorType::get({" # StrJoinInt.result # "}, $_builder.getF" # width # "Type()), " "llvm::makeArrayRef($0)).cast()"; let convertFromStorage = "$_self"; diff --git a/mlir/lib/Analysis/LoopAnalysis.cpp b/mlir/lib/Analysis/LoopAnalysis.cpp index b1895d308ad..55a0ac6df84 100644 --- a/mlir/lib/Analysis/LoopAnalysis.cpp +++ b/mlir/lib/Analysis/LoopAnalysis.cpp @@ -77,7 +77,7 @@ void mlir::buildTripCountMapAndOperands( SmallVector lbSplatExpr(ubValueMap.getNumResults(), lbMap.getResult(0)); auto lbMapSplat = - b.getAffineMap(lbMap.getNumDims(), lbMap.getNumSymbols(), lbSplatExpr); + AffineMap::get(lbMap.getNumDims(), lbMap.getNumSymbols(), lbSplatExpr); AffineValueMap lbSplatValueMap(lbMapSplat, lbOperands); AffineValueMap tripCountValueMap; diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp index a0906b75950..718f8077981 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp @@ -132,7 +132,7 @@ static Value *createAndLoadGlobalVarForEntryFnArg(PatternRewriter &rewriter, funcOp.getName().str() + "_arg_" + std::to_string(origArgNum); var = rewriter.create( funcOp.getLoc(), - rewriter.getTypeAttr(getGlobalVarTypeForEntryFnArg(origArg->getType())), + TypeAttr::get(getGlobalVarTypeForEntryFnArg(origArg->getType())), rewriter.getStringAttr(varName), nullptr); var.setAttr( spirv::SPIRVDialect::getAttributeName(spirv::Decoration::DescriptorSet), diff --git a/mlir/lib/Dialect/AffineOps/AffineOps.cpp b/mlir/lib/Dialect/AffineOps/AffineOps.cpp index 38d4edb60f4..9980497640a 100644 --- a/mlir/lib/Dialect/AffineOps/AffineOps.cpp +++ b/mlir/lib/Dialect/AffineOps/AffineOps.cpp @@ -198,7 +198,7 @@ void AffineApplyOp::build(Builder *builder, OperationState &result, AffineMap map, ArrayRef operands) { result.addOperands(operands); result.types.append(map.getNumResults(), builder->getIndexType()); - result.addAttribute("map", builder->getAffineMapAttr(map)); + result.addAttribute("map", AffineMapAttr::get(map)); } ParseResult AffineApplyOp::parse(OpAsmParser &parser, OperationState &result) { @@ -817,13 +817,13 @@ void AffineDmaStartOp::build(Builder *builder, OperationState &result, ArrayRef tagIndices, Value *numElements, Value *stride, Value *elementsPerStride) { result.addOperands(srcMemRef); - result.addAttribute(getSrcMapAttrName(), builder->getAffineMapAttr(srcMap)); + result.addAttribute(getSrcMapAttrName(), AffineMapAttr::get(srcMap)); result.addOperands(srcIndices); result.addOperands(destMemRef); - result.addAttribute(getDstMapAttrName(), builder->getAffineMapAttr(dstMap)); + result.addAttribute(getDstMapAttrName(), AffineMapAttr::get(dstMap)); result.addOperands(destIndices); result.addOperands(tagMemRef); - result.addAttribute(getTagMapAttrName(), builder->getAffineMapAttr(tagMap)); + result.addAttribute(getTagMapAttrName(), AffineMapAttr::get(tagMap)); result.addOperands(tagIndices); result.addOperands(numElements); if (stride) { @@ -985,7 +985,7 @@ void AffineDmaWaitOp::build(Builder *builder, OperationState &result, Value *tagMemRef, AffineMap tagMap, ArrayRef tagIndices, Value *numElements) { result.addOperands(tagMemRef); - result.addAttribute(getTagMapAttrName(), builder->getAffineMapAttr(tagMap)); + result.addAttribute(getTagMapAttrName(), AffineMapAttr::get(tagMap)); result.addOperands(tagIndices); result.addOperands(numElements); } @@ -1073,13 +1073,11 @@ void AffineForOp::build(Builder *builder, OperationState &result, builder->getIntegerAttr(builder->getIndexType(), step)); // Add the lower bound. - result.addAttribute(getLowerBoundAttrName(), - builder->getAffineMapAttr(lbMap)); + result.addAttribute(getLowerBoundAttrName(), AffineMapAttr::get(lbMap)); result.addOperands(lbOperands); // Add the upper bound. - result.addAttribute(getUpperBoundAttrName(), - builder->getAffineMapAttr(ubMap)); + result.addAttribute(getUpperBoundAttrName(), AffineMapAttr::get(ubMap)); result.addOperands(ubOperands); // Create a region and a block for the body. The argument of the region is @@ -1164,7 +1162,7 @@ static ParseResult parseBound(bool isLower, OperationState &result, // for storage. Analysis passes may expand it into a multi-dimensional map // if desired. AffineMap map = builder.getSymbolIdentityMap(); - result.addAttribute(boundAttrName, builder.getAffineMapAttr(map)); + result.addAttribute(boundAttrName, AffineMapAttr::get(map)); return success(); } @@ -1213,8 +1211,8 @@ static ParseResult parseBound(bool isLower, OperationState &result, if (auto integerAttr = boundAttr.dyn_cast()) { result.attributes.pop_back(); result.addAttribute( - boundAttrName, builder.getAffineMapAttr( - builder.getConstantAffineMap(integerAttr.getInt()))); + boundAttrName, + AffineMapAttr::get(builder.getConstantAffineMap(integerAttr.getInt()))); return success(); } @@ -1752,7 +1750,7 @@ void AffineLoadOp::build(Builder *builder, OperationState &result, assert(operands.size() == 1 + map.getNumInputs() && "inconsistent operands"); result.addOperands(operands); if (map) - result.addAttribute(getMapAttrName(), builder->getAffineMapAttr(map)); + result.addAttribute(getMapAttrName(), AffineMapAttr::get(map)); auto memrefType = operands[0]->getType().cast(); result.types.push_back(memrefType.getElementType()); } @@ -1764,7 +1762,7 @@ void AffineLoadOp::build(Builder *builder, OperationState &result, result.addOperands(memref); result.addOperands(mapOperands); auto memrefType = memref->getType().cast(); - result.addAttribute(getMapAttrName(), builder->getAffineMapAttr(map)); + result.addAttribute(getMapAttrName(), AffineMapAttr::get(map)); result.types.push_back(memrefType.getElementType()); } @@ -1855,7 +1853,7 @@ void AffineStoreOp::build(Builder *builder, OperationState &result, result.addOperands(valueToStore); result.addOperands(memref); result.addOperands(mapOperands); - result.addAttribute(getMapAttrName(), builder->getAffineMapAttr(map)); + result.addAttribute(getMapAttrName(), AffineMapAttr::get(map)); } // Use identity map. diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index 5862efe71b5..23e3889c049 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -869,7 +869,7 @@ void GlobalOp::build(Builder *builder, OperationState &result, LLVMType type, ArrayRef attrs) { result.addAttribute(SymbolTable::getSymbolAttrName(), builder->getStringAttr(name)); - result.addAttribute("type", builder->getTypeAttr(type)); + result.addAttribute("type", TypeAttr::get(type)); if (isConstant) result.addAttribute("constant", builder->getUnitAttr()); if (value) @@ -939,7 +939,7 @@ static ParseResult parseGlobalOp(OpAsmParser &parser, OperationState &result) { } } - result.addAttribute("type", parser.getBuilder().getTypeAttr(types[0])); + result.addAttribute("type", TypeAttr::get(types[0])); return success(); } @@ -1026,7 +1026,7 @@ void LLVMFuncOp::build(Builder *builder, OperationState &result, StringRef name, result.addRegion(); result.addAttribute(SymbolTable::getSymbolAttrName(), builder->getStringAttr(name)); - result.addAttribute("type", builder->getTypeAttr(type)); + result.addAttribute("type", TypeAttr::get(type)); result.attributes.append(attrs.begin(), attrs.end()); if (argAttrs.empty()) return; diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp index 4b1c4e4089d..85d106ed33e 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp @@ -1244,7 +1244,7 @@ static ParseResult parseGlobalVariableOp(OpAsmParser &parser, if (!type.isa()) { return parser.emitError(loc, "expected spv.ptr type"); } - state.addAttribute(kTypeAttrName, parser.getBuilder().getTypeAttr(type)); + state.addAttribute(kTypeAttrName, TypeAttr::get(type)); return success(); } diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp index accee7c2214..6ba18d1f1d0 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp @@ -954,8 +954,8 @@ LogicalResult Deserializer::processGlobalVariable(ArrayRef operands) { << wordIndex << " of " << operands.size() << " processed"; } auto varOp = opBuilder.create( - unknownLoc, opBuilder.getTypeAttr(type), - opBuilder.getStringAttr(variableName), initializer); + unknownLoc, TypeAttr::get(type), opBuilder.getStringAttr(variableName), + initializer); // Decorations. if (decorations.count(variableID)) { @@ -1065,7 +1065,7 @@ LogicalResult Deserializer::processType(spirv::Opcode opcode, return emitError(unknownLoc, "OpTypeVector references undefined ") << operands[1]; } - typeMap[operands[0]] = opBuilder.getVectorType({operands[2]}, elementTy); + typeMap[operands[0]] = VectorType::get({operands[2]}, elementTy); } break; case spirv::Opcode::OpTypePointer: { if (operands.size() != 3) { @@ -1391,7 +1391,7 @@ Deserializer::processConstantComposite(ArrayRef operands) { auto resultID = operands[1]; if (auto vectorType = resultType.dyn_cast()) { - auto attr = opBuilder.getDenseElementsAttr(vectorType, elements); + auto attr = DenseElementsAttr::get(vectorType, elements); // For normal constants, we just record the attribute (and its type) for // later materialization at use sites. constantMap.try_emplace(resultID, attr, resultType); diff --git a/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp index a854a1d511c..1fd6274b16e 100644 --- a/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp @@ -58,7 +58,7 @@ public: } rewriter.replaceOpWithNewOp( - op, rewriter.getTypeAttr(decoratedType), globalVarAttrs); + op, TypeAttr::get(decoratedType), globalVarAttrs); return matchSuccess(); } }; diff --git a/mlir/lib/Dialect/StandardOps/Ops.cpp b/mlir/lib/Dialect/StandardOps/Ops.cpp index 7177cfe7dff..739def41f8e 100644 --- a/mlir/lib/Dialect/StandardOps/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/Ops.cpp @@ -653,11 +653,11 @@ static Type getCheckedI1SameShape(Builder *build, Type type) { if (type.isIntOrIndexOrFloat()) return i1Type; if (auto tensorType = type.dyn_cast()) - return build->getTensorType(tensorType.getShape(), i1Type); + return RankedTensorType::get(tensorType.getShape(), i1Type); if (type.isa()) - return build->getTensorType(i1Type); + return UnrankedTensorType::get(i1Type); if (auto vectorType = type.dyn_cast()) - return build->getVectorType(vectorType.getShape(), i1Type); + return VectorType::get(vectorType.getShape(), i1Type); return Type(); } @@ -2241,7 +2241,7 @@ OpFoldResult TensorCastOp::fold(ArrayRef operands) { static Type getTensorTypeFromMemRefType(Builder &b, Type type) { if (auto memref = type.dyn_cast()) - return b.getTensorType(memref.getShape(), memref.getElementType()); + return RankedTensorType::get(memref.getShape(), memref.getElementType()); return b.getNoneType(); } diff --git a/mlir/lib/Dialect/VectorOps/VectorOps.cpp b/mlir/lib/Dialect/VectorOps/VectorOps.cpp index 22f25683087..a7006f0f1a9 100644 --- a/mlir/lib/Dialect/VectorOps/VectorOps.cpp +++ b/mlir/lib/Dialect/VectorOps/VectorOps.cpp @@ -206,7 +206,7 @@ void VectorTransferReadOp::build(Builder *builder, OperationState &result, result.addOperands({*paddingValue}); } result.addAttribute(getPermutationMapAttrName(), - builder->getAffineMapAttr(permutationMap)); + AffineMapAttr::get(permutationMap)); result.addTypes(vectorType); } @@ -383,7 +383,7 @@ void VectorTransferWriteOp::build(Builder *builder, OperationState &result, result.addOperands({srcVector, dstMemRef}); result.addOperands(dstIndices); result.addAttribute(getPermutationMapAttrName(), - builder->getAffineMapAttr(permutationMap)); + AffineMapAttr::get(permutationMap)); } auto VectorTransferWriteOp::getIndices() -> operand_range { diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp index 0a9389768b9..7ec5c3b6a26 100644 --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -72,25 +72,6 @@ FunctionType Builder::getFunctionType(ArrayRef inputs, return FunctionType::get(inputs, results, context); } -MemRefType Builder::getMemRefType(ArrayRef shape, Type elementType, - ArrayRef affineMapComposition, - unsigned memorySpace) { - return MemRefType::get(shape, elementType, affineMapComposition, memorySpace); -} - -VectorType Builder::getVectorType(ArrayRef shape, Type elementType) { - return VectorType::get(shape, elementType); -} - -RankedTensorType Builder::getTensorType(ArrayRef shape, - Type elementType) { - return RankedTensorType::get(shape, elementType); -} - -UnrankedTensorType Builder::getTensorType(Type elementType) { - return UnrankedTensorType::get(elementType); -} - TupleType Builder::getTupleType(ArrayRef elementTypes) { return TupleType::get(elementTypes, context); } @@ -165,24 +146,10 @@ StringAttr Builder::getStringAttr(StringRef bytes) { return StringAttr::get(bytes, context); } -StringAttr Builder::getStringAttr(StringRef bytes, Type type) { - return StringAttr::get(bytes, type); -} - ArrayAttr Builder::getArrayAttr(ArrayRef value) { return ArrayAttr::get(value, context); } -AffineMapAttr Builder::getAffineMapAttr(AffineMap map) { - return AffineMapAttr::get(map); -} - -IntegerSetAttr Builder::getIntegerSetAttr(IntegerSet set) { - return IntegerSetAttr::get(set); -} - -TypeAttr Builder::getTypeAttr(Type type) { return TypeAttr::get(type); } - SymbolRefAttr Builder::getSymbolRefAttr(Operation *value) { auto symName = value->getAttrOfType(SymbolTable::getSymbolAttrName()); @@ -193,27 +160,6 @@ SymbolRefAttr Builder::getSymbolRefAttr(StringRef value) { return SymbolRefAttr::get(value, getContext()); } -ElementsAttr Builder::getDenseElementsAttr(ShapedType type, - ArrayRef values) { - return DenseElementsAttr::get(type, values); -} - -ElementsAttr Builder::getDenseIntElementsAttr(ShapedType type, - ArrayRef values) { - return DenseIntElementsAttr::get(type, values); -} - -ElementsAttr Builder::getSparseElementsAttr(ShapedType type, - DenseIntElementsAttr indices, - DenseElementsAttr values) { - return SparseElementsAttr::get(type, indices, values); -} - -ElementsAttr Builder::getOpaqueElementsAttr(Dialect *dialect, ShapedType type, - StringRef bytes) { - return OpaqueElementsAttr::get(dialect, type, bytes); -} - ArrayAttr Builder::getI32ArrayAttr(ArrayRef values) { auto attrs = functional::map( [this](int32_t v) -> Attribute { return getI32IntegerAttr(v); }, values); @@ -255,7 +201,7 @@ ArrayAttr Builder::getStrArrayAttr(ArrayRef values) { ArrayAttr Builder::getAffineMapArrayAttr(ArrayRef values) { auto attrs = functional::map( - [this](AffineMap v) -> Attribute { return getAffineMapAttr(v); }, values); + [](AffineMap v) -> Attribute { return AffineMapAttr::get(v); }, values); return getArrayAttr(attrs); } @@ -278,7 +224,7 @@ Attribute Builder::getZeroAttr(Type type) { auto element = getZeroAttr(vtType.getElementType()); if (!element) return {}; - return getDenseElementsAttr(vtType, element); + return DenseElementsAttr::get(vtType, element); } default: break; @@ -290,11 +236,6 @@ Attribute Builder::getZeroAttr(Type type) { // Affine Expressions, Affine Maps, and Integet Sets. //===----------------------------------------------------------------------===// -AffineMap Builder::getAffineMap(unsigned dimCount, unsigned symbolCount, - ArrayRef results) { - return AffineMap::get(dimCount, symbolCount, results); -} - AffineExpr Builder::getAffineDimExpr(unsigned position) { return mlir::getAffineDimExpr(position, context); } @@ -307,12 +248,6 @@ AffineExpr Builder::getAffineConstantExpr(int64_t constant) { return mlir::getAffineConstantExpr(constant, context); } -IntegerSet Builder::getIntegerSet(unsigned dimCount, unsigned symbolCount, - ArrayRef constraints, - ArrayRef isEq) { - return IntegerSet::get(dimCount, symbolCount, constraints, isEq); -} - AffineMap Builder::getEmptyAffineMap() { return AffineMap::get(context); } AffineMap Builder::getConstantAffineMap(int64_t val) { @@ -347,9 +282,8 @@ AffineMap Builder::getSingleDimShiftAffineMap(int64_t shift) { AffineMap Builder::getShiftedAffineMap(AffineMap map, int64_t shift) { SmallVector shiftedResults; shiftedResults.reserve(map.getNumResults()); - for (auto resultExpr : map.getResults()) { + for (auto resultExpr : map.getResults()) shiftedResults.push_back(resultExpr + shift); - } return AffineMap::get(map.getNumDims(), map.getNumSymbols(), shiftedResults); } diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp index 474dd1a5934..4f5a4737698 100644 --- a/mlir/lib/IR/Function.cpp +++ b/mlir/lib/IR/Function.cpp @@ -57,7 +57,7 @@ void FuncOp::build(Builder *builder, OperationState &result, StringRef name, FunctionType type, ArrayRef attrs) { result.addAttribute(SymbolTable::getSymbolAttrName(), builder->getStringAttr(name)); - result.addAttribute(getTypeAttrName(), builder->getTypeAttr(type)); + result.addAttribute(getTypeAttrName(), TypeAttr::get(type)); result.attributes.append(attrs.begin(), attrs.end()); result.addRegion(); } diff --git a/mlir/lib/IR/FunctionSupport.cpp b/mlir/lib/IR/FunctionSupport.cpp index b40eebb04b2..468301e9431 100644 --- a/mlir/lib/IR/FunctionSupport.cpp +++ b/mlir/lib/IR/FunctionSupport.cpp @@ -133,7 +133,7 @@ mlir::impl::parseFunctionLikeOp(OpAsmParser &parser, OperationState &result, std::string errorMessage; if (auto type = funcTypeBuilder(builder, argTypes, results, impl::VariadicFlag(isVariadic), errorMessage)) - result.addAttribute(getTypeAttrName(), builder.getTypeAttr(type)); + result.addAttribute(getTypeAttrName(), TypeAttr::get(type)); else return parser.emitError(signatureLocation) << "failed to construct function type" diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index 80d34ab76e5..873476ebffb 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -1063,9 +1063,9 @@ Attribute Parser::parseAttribute(Type type) { if (parseAffineMapOrIntegerSetReference(map, set)) return nullptr; if (map) - return builder.getAffineMapAttr(map); + return AffineMapAttr::get(map); assert(set); - return builder.getIntegerSetAttr(set); + return IntegerSetAttr::get(set); } // Parse an array attribute. @@ -1164,7 +1164,7 @@ Attribute Parser::parseAttribute(Type type) { default: // Parse a type attribute. if (Type type = parseType()) - return builder.getTypeAttr(type); + return TypeAttr::get(type); return nullptr; } } @@ -1381,7 +1381,7 @@ Attribute Parser::parseOpaqueElementsAttr() { if (!type) return nullptr; - return builder.getOpaqueElementsAttr(dialect, type, llvm::fromHex(val)); + return OpaqueElementsAttr::get(dialect, type, llvm::fromHex(val)); } namespace { @@ -2496,8 +2496,8 @@ ParseResult AffineParser::parseAffineMapOfSSAIds(AffineMap &map) { if (exprs.empty()) map = AffineMap(); else - map = builder.getAffineMap(numDimOperands, - dimsAndSymbols.size() - numDimOperands, exprs); + map = AffineMap::get(numDimOperands, dimsAndSymbols.size() - numDimOperands, + exprs); return success(); } @@ -2525,7 +2525,7 @@ AffineMap AffineParser::parseAffineMapRange(unsigned numDims, return AffineMap(); // Parsed a valid affine map. - return builder.getAffineMap(numDims, numSymbols, exprs); + return AffineMap::get(numDims, numSymbols, exprs); } /// Parse an affine constraint. @@ -2600,11 +2600,11 @@ IntegerSet AffineParser::parseIntegerSetConstraints(unsigned numDims, if (constraints.empty()) { /* 0 == 0 */ auto zero = getAffineConstantExpr(0, getContext()); - return builder.getIntegerSet(numDims, numSymbols, zero, true); + return IntegerSet::get(numDims, numSymbols, zero, true); } // Parsed a valid integer set. - return builder.getIntegerSet(numDims, numSymbols, constraints, isEqs); + return IntegerSet::get(numDims, numSymbols, constraints, isEqs); } /// Parse an ambiguous reference to either and affine map or an integer set. @@ -3715,7 +3715,7 @@ public: return failure(); // Add AffineMap attribute. if (map) { - mapAttr = parser.builder.getAffineMapAttr(map); + mapAttr = AffineMapAttr::get(map); attrs.push_back(parser.builder.getNamedAttr(attrName, mapAttr)); } diff --git a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp index a82a288caf3..a32bb2c9b3c 100644 --- a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp +++ b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp @@ -81,7 +81,7 @@ void AddDefaultStatsPass::runWithConfig(SolverContext &solverContext, APFloat minValue(-1.0f); APFloat maxValue(1.0f); ElementsAttr layerStats = DenseFPElementsAttr::get( - b.getTensorType({2}, b.getF32Type()), {minValue, maxValue}); + RankedTensorType::get({2}, b.getF32Type()), {minValue, maxValue}); auto statsOp = b.create(func.getLoc(), arg, layerStats, nullptr, nullptr); arg->replaceAllUsesWith(statsOp); @@ -107,7 +107,7 @@ void AddDefaultStatsPass::runWithConfig(SolverContext &solverContext, APFloat minValue(-1.0f); APFloat maxValue(1.0f); ElementsAttr layerStats = DenseFPElementsAttr::get( - b.getTensorType({2}, b.getF32Type()), {minValue, maxValue}); + RankedTensorType::get({2}, b.getF32Type()), {minValue, maxValue}); auto statsOp = b.create(op->getLoc(), op->getResult(0), layerStats, nullptr, nullptr); originalResult->replaceAllUsesWith(statsOp); diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index 15dc36c9c13..7e08c6bbc57 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -953,8 +953,8 @@ static Value *createPrivateMemRef(AffineForOp forOp, Operation *srcStoreOpInst, } else { newMemSpace = oldMemRefType.getMemorySpace(); } - auto newMemRefType = top.getMemRefType( - newShape, oldMemRefType.getElementType(), {}, newMemSpace); + auto newMemRefType = MemRefType::get(newShape, oldMemRefType.getElementType(), + {}, newMemSpace); // Gather alloc operands for the dynamic dimensions of the memref. SmallVector allocOperands; unsigned dynamicDimCount = 0; @@ -988,7 +988,7 @@ static Value *createPrivateMemRef(AffineForOp forOp, Operation *srcStoreOpInst, } auto indexRemap = zeroOffsetCount == rank ? AffineMap() - : b.getAffineMap(outerIVs.size() + rank, 0, remapExprs); + : AffineMap::get(outerIVs.size() + rank, 0, remapExprs); // Replace all users of 'oldMemRef' with 'newMemRef'. LogicalResult res = replaceAllMemRefUsesWith(oldMemRef, newMemRef, {}, indexRemap, diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp index af1ecd06ee6..4ee7197f2df 100644 --- a/mlir/lib/Transforms/LoopTiling.cpp +++ b/mlir/lib/Transforms/LoopTiling.cpp @@ -168,13 +168,13 @@ constructTiledIndexSetHyperRect(MutableArrayRef origLoops, boundExprs.push_back(dim + tileSizes[i]); boundExprs.append(origUbMap.getResults().begin(), origUbMap.getResults().end()); - auto ubMap = b.getAffineMap(origUbMap.getNumDims() + 1, + auto ubMap = AffineMap::get(origUbMap.getNumDims() + 1, origUbMap.getNumSymbols(), boundExprs); newLoops[width + i].setUpperBound(/*operands=*/ubOperands, ubMap); } else { // No need of the min expression. auto dim = b.getAffineDimExpr(0); - auto ubMap = b.getAffineMap(1, 0, dim + tileSizes[i]); + auto ubMap = AffineMap::get(1, 0, dim + tileSizes[i]); newLoops[width + i].setUpperBound(newLoops[i].getInductionVar(), ubMap); } } diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp index 2b7330f4175..230869abcd5 100644 --- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp +++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp @@ -223,7 +223,7 @@ LogicalResult mlir::loopUnrollJamByFactor(AffineForOp forOp, if (!forOpIV->use_empty()) { // iv' = iv + i, i = 1 to unrollJamFactor-1. auto d0 = builder.getAffineDimExpr(0); - auto bumpMap = builder.getAffineMap(1, 0, {d0 + i * step}); + auto bumpMap = AffineMap::get(1, 0, {d0 + i * step}); auto ivUnroll = builder.create(forInst->getLoc(), bumpMap, forOpIV); operandMapping.map(forOpIV, ivUnroll); diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp index bb9c39baf55..7e175fb22d2 100644 --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -82,8 +82,8 @@ static bool doubleBuffer(Value *oldMemRef, AffineForOp forOp) { newShape[0] = 2; std::copy(oldShape.begin(), oldShape.end(), newShape.begin() + 1); auto newMemRefType = - bInner.getMemRefType(newShape, oldMemRefType.getElementType(), {}, - oldMemRefType.getMemorySpace()); + MemRefType::get(newShape, oldMemRefType.getElementType(), {}, + oldMemRefType.getMemorySpace()); return newMemRefType; }; @@ -109,8 +109,8 @@ static bool doubleBuffer(Value *oldMemRef, AffineForOp forOp) { // Create 'iv mod 2' value to index the leading dimension. auto d0 = bInner.getAffineDimExpr(0); int64_t step = forOp.getStep(); - auto modTwoMap = bInner.getAffineMap(/*dimCount=*/1, /*symbolCount=*/0, - {d0.floorDiv(step) % 2}); + auto modTwoMap = AffineMap::get(/*dimCount=*/1, /*symbolCount=*/0, + {d0.floorDiv(step) % 2}); auto ivModTwoOp = bInner.create(forOp.getLoc(), modTwoMap, forOp.getInductionVar()); diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index 1872044b0fb..fb96772f053 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -87,7 +87,7 @@ void mlir::getCleanupLoopLowerBound(AffineForOp forOp, unsigned unrollFactor, for (unsigned i = 0, e = tripCountMap.getNumResults(); i < e; i++) { auto tripCountExpr = tripCountMap.getResult(i); bumpExprs[i] = (tripCountExpr - tripCountExpr % unrollFactor) * step; - auto bumpMap = b.getAffineMap(tripCountMap.getNumDims(), + auto bumpMap = AffineMap::get(tripCountMap.getNumDims(), tripCountMap.getNumSymbols(), bumpExprs[i]); bumpValues[i] = b.create(forOp.getLoc(), bumpMap, tripCountOperands); @@ -100,7 +100,7 @@ void mlir::getCleanupLoopLowerBound(AffineForOp forOp, unsigned unrollFactor, operands->clear(); operands->push_back(lb); operands->append(bumpValues.begin(), bumpValues.end()); - *map = b.getAffineMap(1 + tripCountMap.getNumResults(), 0, newUbExprs); + *map = AffineMap::get(1 + tripCountMap.getNumResults(), 0, newUbExprs); // Simplify the map + operands. fullyComposeAffineMapAndOperands(map, operands); *map = simplifyAffineMap(*map); @@ -487,7 +487,7 @@ LogicalResult mlir::loopUnrollByFactor(AffineForOp forOp, if (!forOpIV->use_empty()) { // iv' = iv + 1/2/3...unrollFactor-1; auto d0 = builder.getAffineDimExpr(0); - auto bumpMap = builder.getAffineMap(1, 0, {d0 + i * step}); + auto bumpMap = AffineMap::get(1, 0, {d0 + i * step}); auto ivUnroll = builder.create(forOp.getLoc(), bumpMap, forOpIV); operandMap.map(forOpIV, ivUnroll); @@ -676,7 +676,7 @@ static void augmentMapAndBounds(OpBuilder &b, Value *iv, AffineMap *map, auto bounds = llvm::to_vector<4>(map->getResults()); bounds.push_back(b.getAffineDimExpr(map->getNumDims()) + offset); operands->insert(operands->begin() + map->getNumDims(), iv); - *map = b.getAffineMap(map->getNumDims() + 1, map->getNumSymbols(), bounds); + *map = AffineMap::get(map->getNumDims() + 1, map->getNumSymbols(), bounds); canonicalizeMapAndOperands(map, operands); } @@ -1229,7 +1229,7 @@ static AffineForOp generatePointWiseCopy(Location loc, Value *memref, ? memIndicesStart[d] : b.create( loc, - b.getAffineMap(memAffineMap.getNumDims(), + AffineMap::get(memAffineMap.getNumDims(), memAffineMap.getNumSymbols(), memAffineMap.getResult(d)), memIndicesStart); @@ -1238,7 +1238,7 @@ static AffineForOp generatePointWiseCopy(Location loc, Value *memref, SmallVector operands = {memBase, forOp.getInductionVar()}; auto memIndex = b.create( loc, - b.getAffineMap(2, 0, b.getAffineDimExpr(0) + b.getAffineDimExpr(1)), + AffineMap::get(2, 0, b.getAffineDimExpr(0) + b.getAffineDimExpr(1)), operands); memIndices.push_back(memIndex); } @@ -1381,7 +1381,7 @@ static LogicalResult generateCopy( } else { // The coordinate for the start location is just the lower bound along the // corresponding dimension on the memory region (stored in 'offset'). - auto map = top.getAffineMap( + auto map = AffineMap::get( cst->getNumDimIds() + cst->getNumSymbolIds() - rank, 0, offset); memIndices.push_back(b.create(loc, map, regionSymbols)); } @@ -1401,8 +1401,8 @@ static LogicalResult generateCopy( if (!existingBuf) { AffineMap fastBufferLayout = b.getMultiDimIdentityMap(rank); auto fastMemRefType = - top.getMemRefType(fastBufferShape, memRefType.getElementType(), - fastBufferLayout, copyOptions.fastMemorySpace); + MemRefType::get(fastBufferShape, memRefType.getElementType(), + fastBufferLayout, copyOptions.fastMemorySpace); // Create the fast memory space buffer just before the 'affine.for' // operation. @@ -1470,8 +1470,8 @@ static LogicalResult generateCopy( } else { // DMA generation. // Create a tag (single element 1-d memref) for the DMA. - auto tagMemRefType = top.getMemRefType({1}, top.getIntegerType(32), {}, - copyOptions.tagMemorySpace); + auto tagMemRefType = MemRefType::get({1}, top.getIntegerType(32), {}, + copyOptions.tagMemorySpace); auto tagMemRef = prologue.create(loc, tagMemRefType); SmallVector tagIndices({zeroIndex}); @@ -1532,7 +1532,7 @@ static LogicalResult generateCopy( auto dimExpr = b.getAffineDimExpr(regionSymbols.size() + i); remapExprs.push_back(dimExpr - offsets[i]); } - auto indexRemap = b.getAffineMap(regionSymbols.size() + rank, 0, remapExprs); + auto indexRemap = AffineMap::get(regionSymbols.size() + rank, 0, remapExprs); // Record the begin since it may be invalidated by memref replacement. Block::iterator prevOfBegin; diff --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp index d6400ac50ed..35a5273a28f 100644 --- a/mlir/lib/Transforms/Utils/Utils.cpp +++ b/mlir/lib/Transforms/Utils/Utils.cpp @@ -119,8 +119,8 @@ LogicalResult mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, oldMemRefOperands.reserve(oldMemRefRank); if (oldMap != builder.getMultiDimIdentityMap(oldMap.getNumDims())) { for (auto resultExpr : oldMap.getResults()) { - auto singleResMap = builder.getAffineMap( - oldMap.getNumDims(), oldMap.getNumSymbols(), resultExpr); + auto singleResMap = AffineMap::get(oldMap.getNumDims(), + oldMap.getNumSymbols(), resultExpr); auto afOp = builder.create(op->getLoc(), singleResMap, oldMapOperands); oldMemRefOperands.push_back(afOp); @@ -147,7 +147,7 @@ LogicalResult mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, indexRemap != builder.getMultiDimIdentityMap(indexRemap.getNumDims())) { // Remapped indices. for (auto resultExpr : indexRemap.getResults()) { - auto singleResMap = builder.getAffineMap( + auto singleResMap = AffineMap::get( indexRemap.getNumDims(), indexRemap.getNumSymbols(), resultExpr); auto afOp = builder.create(op->getLoc(), singleResMap, remapOperands); @@ -210,7 +210,7 @@ LogicalResult mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, state.types.push_back(result->getType()); // Add attribute for 'newMap', other Attributes do not change. - auto newMapAttr = builder.getAffineMapAttr(newMap); + auto newMapAttr = AffineMapAttr::get(newMap); for (auto namedAttr : op->getAttrs()) { if (namedAttr.first == oldMapAttrPair.first) { state.attributes.push_back({namedAttr.first, newMapAttr}); @@ -371,8 +371,8 @@ void mlir::createAffineComputationSlice( // Create an affine.apply for each of the map results. sliceOps->reserve(composedMap.getNumResults()); for (auto resultExpr : composedMap.getResults()) { - auto singleResMap = builder.getAffineMap( - composedMap.getNumDims(), composedMap.getNumSymbols(), resultExpr); + auto singleResMap = AffineMap::get(composedMap.getNumDims(), + composedMap.getNumSymbols(), resultExpr); sliceOps->push_back(builder.create( opInst->getLoc(), singleResMap, composedOpOperands)); } @@ -457,7 +457,7 @@ LogicalResult mlir::normalizeMemRef(AllocOp allocOp) { auto *oldMemRef = allocOp.getResult(); SmallVector symbolOperands(allocOp.getSymbolicOperands()); - auto newMemRefType = b.getMemRefType(newShape, memrefType.getElementType(), + auto newMemRefType = MemRefType::get(newShape, memrefType.getElementType(), b.getMultiDimIdentityMap(newRank)); auto newAlloc = b.create(allocOp.getLoc(), newMemRefType); diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp index a54b05e980a..1e10f372b5f 100644 --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -772,7 +772,7 @@ static void computeMemoryOpIndices(Operation *op, AffineMap map, OpBuilder builder(op); for (auto resultExpr : map.getResults()) { auto singleResMap = - builder.getAffineMap(map.getNumDims(), map.getNumSymbols(), resultExpr); + AffineMap::get(map.getNumDims(), map.getNumSymbols(), resultExpr); auto afOp = builder.create(op->getLoc(), singleResMap, mapOperands); results.push_back(afOp); diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp index 73b2141970a..73a7366b5e8 100644 --- a/mlir/test/EDSC/builder-api-test.cpp +++ b/mlir/test/EDSC/builder-api-test.cpp @@ -772,7 +772,7 @@ TEST_FUNC(affine_if_op) { builder.getAffineSymbolExpr(0), // s0 >= 0 builder.getAffineSymbolExpr(1) // s1 >= 0 }; - auto intSet = builder.getIntegerSet(2, 2, affineExprs, isEq); + auto intSet = IntegerSet::get(2, 2, affineExprs, isEq); SmallVector affineIfArgs = {zero, zero, ten, ten}; intrinsics::affine_if(intSet, affineIfArgs, /*withElseRegion=*/false); diff --git a/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp b/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp index ad9d6b21c95..ecf37139ac3 100644 --- a/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp +++ b/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp @@ -71,7 +71,7 @@ protected: OpBuilder opBuilder(module.body()); auto ptrType = spirv::PointerType::get(type, spirv::StorageClass::Uniform); opBuilder.create( - UnknownLoc::get(&context), opBuilder.getTypeAttr(ptrType), + UnknownLoc::get(&context), TypeAttr::get(ptrType), opBuilder.getStringAttr(name), nullptr); } -- cgit v1.2.3 From 35807bc4c5c9d8abc31ba0b2f955a82abf276e12 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Sun, 22 Dec 2019 21:59:55 -0800 Subject: NFC: Introduce new ValuePtr/ValueRef typedefs to simplify the transition to Value being value-typed. This is an initial step to refactoring the representation of OpResult as proposed in: https://groups.google.com/a/tensorflow.org/g/mlir/c/XXzzKhqqF_0/m/v6bKb08WCgAJ This change will make it much simpler to incrementally transition all of the existing code to use value-typed semantics. PiperOrigin-RevId: 286844725 --- mlir/bindings/python/pybind.cpp | 2 +- mlir/examples/toy/Ch2/include/toy/Ops.td | 8 +- mlir/examples/toy/Ch2/mlir/Dialect.cpp | 9 +- mlir/examples/toy/Ch2/mlir/MLIRGen.cpp | 41 +-- mlir/examples/toy/Ch3/include/toy/Ops.td | 8 +- mlir/examples/toy/Ch3/mlir/Dialect.cpp | 9 +- mlir/examples/toy/Ch3/mlir/MLIRGen.cpp | 41 +-- mlir/examples/toy/Ch3/mlir/ToyCombine.cpp | 2 +- mlir/examples/toy/Ch4/include/toy/Ops.td | 8 +- mlir/examples/toy/Ch4/mlir/Dialect.cpp | 13 +- mlir/examples/toy/Ch4/mlir/MLIRGen.cpp | 41 +-- mlir/examples/toy/Ch4/mlir/ToyCombine.cpp | 2 +- mlir/examples/toy/Ch5/include/toy/Ops.td | 8 +- mlir/examples/toy/Ch5/mlir/Dialect.cpp | 13 +- mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp | 36 +-- mlir/examples/toy/Ch5/mlir/MLIRGen.cpp | 41 +-- mlir/examples/toy/Ch5/mlir/ToyCombine.cpp | 2 +- mlir/examples/toy/Ch6/include/toy/Ops.td | 8 +- mlir/examples/toy/Ch6/mlir/Dialect.cpp | 13 +- mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp | 36 +-- mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp | 24 +- mlir/examples/toy/Ch6/mlir/MLIRGen.cpp | 41 +-- mlir/examples/toy/Ch6/mlir/ToyCombine.cpp | 2 +- mlir/examples/toy/Ch7/include/toy/Ops.td | 10 +- mlir/examples/toy/Ch7/mlir/Dialect.cpp | 15 +- mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp | 36 +-- mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp | 24 +- mlir/examples/toy/Ch7/mlir/MLIRGen.cpp | 40 +-- mlir/examples/toy/Ch7/mlir/ToyCombine.cpp | 2 +- mlir/g3doc/DeclarativeRewrites.md | 6 +- mlir/g3doc/DialectConversion.md | 6 +- mlir/g3doc/EDSC.md | 8 +- mlir/g3doc/GenericDAGRewriter.md | 2 +- mlir/g3doc/OpDefinitions.md | 14 +- mlir/g3doc/QuickstartRewrites.md | 4 +- mlir/g3doc/Rationale.md | 2 +- mlir/g3doc/Tutorials/Toy/Ch-3.md | 2 +- mlir/g3doc/Tutorials/Toy/Ch-4.md | 4 +- mlir/g3doc/Tutorials/Toy/Ch-5.md | 10 +- mlir/g3doc/UsageOfConst.md | 8 +- mlir/include/mlir/Analysis/AffineAnalysis.h | 9 +- mlir/include/mlir/Analysis/AffineStructures.h | 72 ++--- mlir/include/mlir/Analysis/CallInterfaces.h | 4 +- mlir/include/mlir/Analysis/Dominance.h | 4 +- mlir/include/mlir/Analysis/Liveness.h | 17 +- mlir/include/mlir/Analysis/LoopAnalysis.h | 9 +- mlir/include/mlir/Analysis/Utils.h | 10 +- .../Conversion/AffineToStandard/AffineToStandard.h | 13 +- .../mlir/Conversion/LoopsToGPU/LoopsToGPU.h | 7 +- .../StandardToLLVM/ConvertStandardToLLVM.h | 57 ++-- mlir/include/mlir/Dialect/AffineOps/AffineOps.h | 105 +++---- mlir/include/mlir/Dialect/AffineOps/AffineOps.td | 8 +- mlir/include/mlir/Dialect/GPU/GPUDialect.h | 6 +- mlir/include/mlir/Dialect/GPU/GPUOps.td | 16 +- mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h | 6 +- mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | 22 +- .../Dialect/Linalg/Analysis/DependenceAnalysis.h | 16 +- mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h | 20 +- .../mlir/Dialect/Linalg/IR/LinalgLibraryOps.td | 10 +- mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td | 16 +- .../mlir/Dialect/Linalg/IR/LinalgStructuredOps.td | 10 +- mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h | 8 +- .../Linalg/Transforms/LinalgTransformPatterns.td | 2 +- .../Dialect/Linalg/Transforms/LinalgTransforms.h | 4 +- mlir/include/mlir/Dialect/Linalg/Utils/Utils.h | 36 +-- mlir/include/mlir/Dialect/LoopOps/LoopOps.h | 2 +- mlir/include/mlir/Dialect/LoopOps/LoopOps.td | 12 +- .../mlir/Dialect/SPIRV/SPIRVCompositeOps.td | 2 +- .../mlir/Dialect/SPIRV/SPIRVControlFlowOps.td | 2 +- mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td | 4 +- mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h | 4 +- mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td | 6 +- mlir/include/mlir/Dialect/StandardOps/Ops.h | 35 +-- mlir/include/mlir/Dialect/StandardOps/Ops.td | 78 +++--- mlir/include/mlir/Dialect/VectorOps/Utils.h | 5 +- mlir/include/mlir/Dialect/VectorOps/VectorOps.td | 22 +- .../mlir/Dialect/VectorOps/VectorTransforms.h | 5 +- mlir/include/mlir/EDSC/Builders.h | 32 +-- mlir/include/mlir/EDSC/Helpers.h | 10 +- mlir/include/mlir/EDSC/Intrinsics.h | 26 +- mlir/include/mlir/IR/Block.h | 8 +- mlir/include/mlir/IR/BlockAndValueMapping.h | 8 +- mlir/include/mlir/IR/Builders.h | 10 +- mlir/include/mlir/IR/FunctionSupport.h | 2 +- mlir/include/mlir/IR/Matchers.h | 14 +- mlir/include/mlir/IR/OpDefinition.h | 40 +-- mlir/include/mlir/IR/OpImplementation.h | 30 +- mlir/include/mlir/IR/Operation.h | 22 +- mlir/include/mlir/IR/OperationSupport.h | 45 +-- mlir/include/mlir/IR/TypeUtilities.h | 12 +- mlir/include/mlir/IR/Value.h | 22 +- .../Quantizer/Support/ConstraintAnalysisGraph.h | 10 +- .../include/mlir/Target/LLVMIR/ModuleTranslation.h | 2 +- mlir/include/mlir/Transforms/DialectConversion.h | 46 ++-- mlir/include/mlir/Transforms/FoldUtils.h | 10 +- mlir/include/mlir/Transforms/InliningUtils.h | 14 +- mlir/include/mlir/Transforms/LoopLikeInterface.td | 2 +- mlir/include/mlir/Transforms/LoopUtils.h | 12 +- mlir/include/mlir/Transforms/RegionUtils.h | 8 +- mlir/include/mlir/Transforms/Utils.h | 20 +- mlir/lib/Analysis/AffineAnalysis.cpp | 60 ++-- mlir/lib/Analysis/AffineStructures.cpp | 94 +++---- mlir/lib/Analysis/CallGraph.cpp | 2 +- mlir/lib/Analysis/Dominance.cpp | 2 +- mlir/lib/Analysis/Liveness.cpp | 34 +-- mlir/lib/Analysis/LoopAnalysis.cpp | 30 +- mlir/lib/Analysis/SliceAnalysis.cpp | 4 +- mlir/lib/Analysis/Utils.cpp | 42 +-- mlir/lib/Analysis/VectorAnalysis.cpp | 4 +- mlir/lib/Analysis/Verifier.cpp | 6 +- .../AffineToStandard/AffineToStandard.cpp | 139 +++++----- .../GPUCommon/IndexIntrinsicsOpLowering.h | 4 +- .../Conversion/GPUCommon/OpToFuncCallLowering.h | 6 +- .../GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp | 46 ++-- .../Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp | 217 +++++++-------- .../Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp | 30 +- mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp | 68 ++--- .../LoopToStandard/ConvertLoopToStandard.cpp | 18 +- mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp | 111 ++++---- mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp | 2 +- .../StandardToLLVM/ConvertStandardToLLVM.cpp | 301 +++++++++++---------- .../StandardToSPIRV/ConvertStandardToSPIRV.cpp | 37 +-- .../StandardToSPIRV/ConvertStandardToSPIRVPass.cpp | 4 +- .../StandardToSPIRV/LegalizeStandardForSPIRV.cpp | 8 +- .../VectorToLLVM/ConvertVectorToLLVM.cpp | 108 ++++---- mlir/lib/Dialect/AffineOps/AffineOps.cpp | 147 +++++----- .../FxpMathOps/Transforms/LowerUniformRealMath.cpp | 64 ++--- .../FxpMathOps/Transforms/UniformKernelUtils.h | 6 +- mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | 47 ++-- .../lib/Dialect/GPU/Transforms/KernelOutlining.cpp | 12 +- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 26 +- .../Dialect/Linalg/Analysis/DependenceAnalysis.cpp | 20 +- mlir/lib/Dialect/Linalg/EDSC/Builders.cpp | 18 +- mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | 4 +- mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp | 32 +-- .../Dialect/Linalg/Transforms/LinalgToLoops.cpp | 44 +-- .../Dialect/Linalg/Transforms/LinalgTransforms.cpp | 6 +- mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp | 35 +-- mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp | 53 ++-- mlir/lib/Dialect/Linalg/Utils/Utils.cpp | 24 +- mlir/lib/Dialect/LoopOps/LoopOps.cpp | 12 +- mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp | 2 +- mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp | 8 +- mlir/lib/Dialect/SPIRV/SPIRVOps.cpp | 39 +-- .../Dialect/SPIRV/Serialization/Deserializer.cpp | 38 +-- .../lib/Dialect/SPIRV/Serialization/Serializer.cpp | 18 +- .../SPIRV/Transforms/LowerABIAttributesPass.cpp | 6 +- mlir/lib/Dialect/StandardOps/Ops.cpp | 66 ++--- mlir/lib/Dialect/VectorOps/VectorOps.cpp | 30 +- mlir/lib/Dialect/VectorOps/VectorTransforms.cpp | 76 +++--- mlir/lib/EDSC/Builders.cpp | 23 +- mlir/lib/EDSC/Helpers.cpp | 6 +- mlir/lib/EDSC/Intrinsics.cpp | 12 +- mlir/lib/IR/AsmPrinter.cpp | 50 ++-- mlir/lib/IR/Block.cpp | 4 +- mlir/lib/IR/Builders.cpp | 4 +- mlir/lib/IR/Operation.cpp | 26 +- mlir/lib/IR/OperationSupport.cpp | 13 +- mlir/lib/IR/Region.cpp | 6 +- mlir/lib/IR/TypeUtilities.cpp | 12 +- mlir/lib/IR/Value.cpp | 4 +- mlir/lib/Parser/Parser.cpp | 65 ++--- mlir/lib/Pass/IRPrinting.cpp | 4 +- .../Quantizer/Support/ConstraintAnalysisGraph.cpp | 2 +- .../Transforms/AddDefaultStatsTestPass.cpp | 2 +- .../Transforms/InferQuantizedTypesPass.cpp | 14 +- mlir/lib/TableGen/Pattern.cpp | 2 +- mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp | 38 +-- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 10 +- mlir/lib/Transforms/AffineDataCopyGeneration.cpp | 2 +- .../Transforms/AffineLoopInvariantCodeMotion.cpp | 21 +- mlir/lib/Transforms/DialectConversion.cpp | 58 ++-- mlir/lib/Transforms/LoopFusion.cpp | 93 +++---- mlir/lib/Transforms/LoopInvariantCodeMotion.cpp | 4 +- mlir/lib/Transforms/LoopTiling.cpp | 11 +- mlir/lib/Transforms/LoopUnrollAndJam.cpp | 4 +- mlir/lib/Transforms/MemRefDataFlowOpt.cpp | 6 +- mlir/lib/Transforms/PipelineDataTransfer.cpp | 14 +- mlir/lib/Transforms/Utils/FoldUtils.cpp | 8 +- .../Utils/GreedyPatternRewriteDriver.cpp | 8 +- mlir/lib/Transforms/Utils/InliningUtils.cpp | 36 +-- mlir/lib/Transforms/Utils/LoopFusionUtils.cpp | 16 +- mlir/lib/Transforms/Utils/LoopUtils.cpp | 169 ++++++------ mlir/lib/Transforms/Utils/RegionUtils.cpp | 24 +- mlir/lib/Transforms/Utils/Utils.cpp | 57 ++-- mlir/lib/Transforms/Vectorize.cpp | 40 +-- mlir/test/EDSC/builder-api-test.cpp | 4 +- mlir/test/lib/TestDialect/TestDialect.cpp | 8 +- mlir/test/lib/TestDialect/TestOps.td | 2 +- mlir/test/lib/TestDialect/TestPatterns.cpp | 33 +-- mlir/test/lib/Transforms/TestLoopMapping.cpp | 2 +- .../test/lib/Transforms/TestVectorizationUtils.cpp | 2 +- mlir/test/mlir-tblgen/op-attribute.td | 6 +- mlir/test/mlir-tblgen/op-decl.td | 24 +- mlir/test/mlir-tblgen/op-operand.td | 10 +- mlir/test/mlir-tblgen/op-result.td | 6 +- mlir/test/mlir-tblgen/predicate.td | 4 +- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 27 +- mlir/tools/mlir-tblgen/RewriterGen.cpp | 20 +- mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp | 2 +- mlir/unittests/IR/OperationSupportTest.cpp | 8 +- 201 files changed, 2493 insertions(+), 2413 deletions(-) (limited to 'mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp') diff --git a/mlir/bindings/python/pybind.cpp b/mlir/bindings/python/pybind.cpp index 825f800c0bd..54646cbe800 100644 --- a/mlir/bindings/python/pybind.cpp +++ b/mlir/bindings/python/pybind.cpp @@ -103,7 +103,7 @@ struct PythonValueHandle { assert(value.hasType() && value.getType().isa() && "can only call function-typed values"); - std::vector argValues; + std::vector argValues; argValues.reserve(args.size()); for (auto arg : args) argValues.push_back(arg.value.getValue()); diff --git a/mlir/examples/toy/Ch2/include/toy/Ops.td b/mlir/examples/toy/Ch2/include/toy/Ops.td index f7c011915ff..dd88b097ab1 100644 --- a/mlir/examples/toy/Ch2/include/toy/Ops.td +++ b/mlir/examples/toy/Ch2/include/toy/Ops.td @@ -98,7 +98,7 @@ def AddOp : Toy_Op<"add"> { // Allow building an AddOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *lhs, Value *rhs"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr lhs, ValuePtr rhs"> ]; } @@ -129,7 +129,7 @@ def GenericCallOp : Toy_Op<"generic_call"> { // Add custom build methods for the generic call operation. let builders = [ OpBuilder<"Builder *builder, OperationState &state, " - "StringRef callee, ArrayRef arguments"> + "StringRef callee, ArrayRef arguments"> ]; } @@ -145,7 +145,7 @@ def MulOp : Toy_Op<"mul"> { // Allow building a MulOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *lhs, Value *rhs"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr lhs, ValuePtr rhs"> ]; } @@ -219,7 +219,7 @@ def TransposeOp : Toy_Op<"transpose"> { // Allow building a TransposeOp with from the input operand. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *input"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr input"> ]; // Invoke a static verify method to verify this transpose operation. diff --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp index 86f648dbe0e..4a3232dabe3 100644 --- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp @@ -94,7 +94,7 @@ static mlir::LogicalResult verify(ConstantOp op) { // AddOp void AddOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *lhs, mlir::Value *rhs) { + mlir::ValuePtr lhs, mlir::ValuePtr rhs) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -103,7 +103,8 @@ void AddOp::build(mlir::Builder *builder, mlir::OperationState &state, // GenericCallOp void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state, - StringRef callee, ArrayRef arguments) { + StringRef callee, + ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(arguments); @@ -114,7 +115,7 @@ void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state, // MulOp void MulOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *lhs, mlir::Value *rhs) { + mlir::ValuePtr lhs, mlir::ValuePtr rhs) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -161,7 +162,7 @@ static mlir::LogicalResult verify(ReturnOp op) { // TransposeOp void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *value) { + mlir::ValuePtr value) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp index da474e809b3..902c634a954 100644 --- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp @@ -99,7 +99,7 @@ private: /// Entering a function creates a new scope, and the function arguments are /// added to the mapping. When the processing of a function is terminated, the /// scope is destroyed and the mappings created in this scope are dropped. - llvm::ScopedHashTable symbolTable; + llvm::ScopedHashTable symbolTable; /// Helper conversion for a Toy AST location to an MLIR location. mlir::Location loc(Location loc) { @@ -109,7 +109,7 @@ private: /// Declare a variable in the current scope, return success if the variable /// wasn't declared yet. - mlir::LogicalResult declare(llvm::StringRef var, mlir::Value *value) { + mlir::LogicalResult declare(llvm::StringRef var, mlir::ValuePtr value) { if (symbolTable.count(var)) return mlir::failure(); symbolTable.insert(var, value); @@ -132,7 +132,8 @@ private: /// Emit a new function and add it to the MLIR module. mlir::FuncOp mlirGen(FunctionAST &funcAST) { // Create a scope in the symbol table to hold variable declarations. - ScopedHashTableScope var_scope(symbolTable); + ScopedHashTableScope var_scope( + symbolTable); // Create an MLIR function for the given prototype. mlir::FuncOp function(mlirGen(*funcAST.getProto())); @@ -183,7 +184,7 @@ private: } /// Emit a binary operation - mlir::Value *mlirGen(BinaryExprAST &binop) { + mlir::ValuePtr mlirGen(BinaryExprAST &binop) { // First emit the operations for each side of the operation before emitting // the operation itself. For example if the expression is `a + foo(a)` // 1) First it will visiting the LHS, which will return a reference to the @@ -195,10 +196,10 @@ private: // and the result value is returned. If an error occurs we get a nullptr // and propagate. // - mlir::Value *lhs = mlirGen(*binop.getLHS()); + mlir::ValuePtr lhs = mlirGen(*binop.getLHS()); if (!lhs) return nullptr; - mlir::Value *rhs = mlirGen(*binop.getRHS()); + mlir::ValuePtr rhs = mlirGen(*binop.getRHS()); if (!rhs) return nullptr; auto location = loc(binop.loc()); @@ -219,8 +220,8 @@ private: /// This is a reference to a variable in an expression. The variable is /// expected to have been declared and so should have a value in the symbol /// table, otherwise emit an error and return nullptr. - mlir::Value *mlirGen(VariableExprAST &expr) { - if (auto *variable = symbolTable.lookup(expr.getName())) + mlir::ValuePtr mlirGen(VariableExprAST &expr) { + if (auto variable = symbolTable.lookup(expr.getName())) return variable; emitError(loc(expr.loc()), "error: unknown variable '") @@ -233,7 +234,7 @@ private: auto location = loc(ret.loc()); // 'return' takes an optional expression, handle that case here. - mlir::Value *expr = nullptr; + mlir::ValuePtr expr = nullptr; if (ret.getExpr().hasValue()) { if (!(expr = mlirGen(*ret.getExpr().getValue()))) return mlir::failure(); @@ -241,7 +242,7 @@ private: // Otherwise, this return operation has zero operands. builder.create(location, expr ? makeArrayRef(expr) - : ArrayRef()); + : ArrayRef()); return mlir::success(); } @@ -263,7 +264,7 @@ private: /// [[1.000000e+00, 2.000000e+00, 3.000000e+00], /// [4.000000e+00, 5.000000e+00, 6.000000e+00]]>} : () -> tensor<2x3xf64> /// - mlir::Value *mlirGen(LiteralExprAST &lit) { + mlir::ValuePtr mlirGen(LiteralExprAST &lit) { auto type = getType(lit.getDims()); // The attribute is a vector with a floating point value per element @@ -309,14 +310,14 @@ private: /// Emit a call expression. It emits specific operations for the `transpose` /// builtin. Other identifiers are assumed to be user-defined functions. - mlir::Value *mlirGen(CallExprAST &call) { + mlir::ValuePtr mlirGen(CallExprAST &call) { llvm::StringRef callee = call.getCallee(); auto location = loc(call.loc()); // Codegen the operands first. - SmallVector operands; + SmallVector operands; for (auto &expr : call.getArgs()) { - auto *arg = mlirGen(*expr); + auto arg = mlirGen(*expr); if (!arg) return nullptr; operands.push_back(arg); @@ -342,7 +343,7 @@ private: /// Emit a print expression. It emits specific operations for two builtins: /// transpose(x) and print(x). mlir::LogicalResult mlirGen(PrintExprAST &call) { - auto *arg = mlirGen(*call.getArg()); + auto arg = mlirGen(*call.getArg()); if (!arg) return mlir::failure(); @@ -351,12 +352,12 @@ private: } /// Emit a constant for a single number (FIXME: semantic? broadcast?) - mlir::Value *mlirGen(NumberExprAST &num) { + mlir::ValuePtr mlirGen(NumberExprAST &num) { return builder.create(loc(num.loc()), num.getValue()); } /// Dispatch codegen for the right expression subclass using RTTI. - mlir::Value *mlirGen(ExprAST &expr) { + mlir::ValuePtr mlirGen(ExprAST &expr) { switch (expr.getKind()) { case toy::ExprAST::Expr_BinOp: return mlirGen(cast(expr)); @@ -380,7 +381,7 @@ private: /// initializer and record the value in the symbol table before returning it. /// Future expressions will be able to reference this variable through symbol /// table lookup. - mlir::Value *mlirGen(VarDeclExprAST &vardecl) { + mlir::ValuePtr mlirGen(VarDeclExprAST &vardecl) { auto init = vardecl.getInitVal(); if (!init) { emitError(loc(vardecl.loc()), @@ -388,7 +389,7 @@ private: return nullptr; } - mlir::Value *value = mlirGen(*init); + mlir::ValuePtr value = mlirGen(*init); if (!value) return nullptr; @@ -408,7 +409,7 @@ private: /// Codegen a list of expression, return failure if one of them hit an error. mlir::LogicalResult mlirGen(ExprASTList &blockAST) { - ScopedHashTableScope var_scope(symbolTable); + ScopedHashTableScope var_scope(symbolTable); for (auto &expr : blockAST) { // Specific handling for variable declarations, return statement, and // print. These can only appear in block list and not in nested diff --git a/mlir/examples/toy/Ch3/include/toy/Ops.td b/mlir/examples/toy/Ch3/include/toy/Ops.td index 921e503e416..6c400169da2 100644 --- a/mlir/examples/toy/Ch3/include/toy/Ops.td +++ b/mlir/examples/toy/Ch3/include/toy/Ops.td @@ -98,7 +98,7 @@ def AddOp : Toy_Op<"add", [NoSideEffect]> { // Allow building an AddOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *lhs, Value *rhs"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr lhs, ValuePtr rhs"> ]; } @@ -129,7 +129,7 @@ def GenericCallOp : Toy_Op<"generic_call"> { // Add custom build methods for the generic call operation. let builders = [ OpBuilder<"Builder *builder, OperationState &state, " - "StringRef callee, ArrayRef arguments"> + "StringRef callee, ArrayRef arguments"> ]; } @@ -145,7 +145,7 @@ def MulOp : Toy_Op<"mul", [NoSideEffect]> { // Allow building a MulOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *lhs, Value *rhs"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr lhs, ValuePtr rhs"> ]; } @@ -225,7 +225,7 @@ def TransposeOp : Toy_Op<"transpose", [NoSideEffect]> { // Allow building a TransposeOp with from the input operand. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *input"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr input"> ]; // Invoke a static verify method to verify this transpose operation. diff --git a/mlir/examples/toy/Ch3/mlir/Dialect.cpp b/mlir/examples/toy/Ch3/mlir/Dialect.cpp index 86f648dbe0e..4a3232dabe3 100644 --- a/mlir/examples/toy/Ch3/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch3/mlir/Dialect.cpp @@ -94,7 +94,7 @@ static mlir::LogicalResult verify(ConstantOp op) { // AddOp void AddOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *lhs, mlir::Value *rhs) { + mlir::ValuePtr lhs, mlir::ValuePtr rhs) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -103,7 +103,8 @@ void AddOp::build(mlir::Builder *builder, mlir::OperationState &state, // GenericCallOp void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state, - StringRef callee, ArrayRef arguments) { + StringRef callee, + ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(arguments); @@ -114,7 +115,7 @@ void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state, // MulOp void MulOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *lhs, mlir::Value *rhs) { + mlir::ValuePtr lhs, mlir::ValuePtr rhs) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -161,7 +162,7 @@ static mlir::LogicalResult verify(ReturnOp op) { // TransposeOp void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *value) { + mlir::ValuePtr value) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp index da474e809b3..902c634a954 100644 --- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp @@ -99,7 +99,7 @@ private: /// Entering a function creates a new scope, and the function arguments are /// added to the mapping. When the processing of a function is terminated, the /// scope is destroyed and the mappings created in this scope are dropped. - llvm::ScopedHashTable symbolTable; + llvm::ScopedHashTable symbolTable; /// Helper conversion for a Toy AST location to an MLIR location. mlir::Location loc(Location loc) { @@ -109,7 +109,7 @@ private: /// Declare a variable in the current scope, return success if the variable /// wasn't declared yet. - mlir::LogicalResult declare(llvm::StringRef var, mlir::Value *value) { + mlir::LogicalResult declare(llvm::StringRef var, mlir::ValuePtr value) { if (symbolTable.count(var)) return mlir::failure(); symbolTable.insert(var, value); @@ -132,7 +132,8 @@ private: /// Emit a new function and add it to the MLIR module. mlir::FuncOp mlirGen(FunctionAST &funcAST) { // Create a scope in the symbol table to hold variable declarations. - ScopedHashTableScope var_scope(symbolTable); + ScopedHashTableScope var_scope( + symbolTable); // Create an MLIR function for the given prototype. mlir::FuncOp function(mlirGen(*funcAST.getProto())); @@ -183,7 +184,7 @@ private: } /// Emit a binary operation - mlir::Value *mlirGen(BinaryExprAST &binop) { + mlir::ValuePtr mlirGen(BinaryExprAST &binop) { // First emit the operations for each side of the operation before emitting // the operation itself. For example if the expression is `a + foo(a)` // 1) First it will visiting the LHS, which will return a reference to the @@ -195,10 +196,10 @@ private: // and the result value is returned. If an error occurs we get a nullptr // and propagate. // - mlir::Value *lhs = mlirGen(*binop.getLHS()); + mlir::ValuePtr lhs = mlirGen(*binop.getLHS()); if (!lhs) return nullptr; - mlir::Value *rhs = mlirGen(*binop.getRHS()); + mlir::ValuePtr rhs = mlirGen(*binop.getRHS()); if (!rhs) return nullptr; auto location = loc(binop.loc()); @@ -219,8 +220,8 @@ private: /// This is a reference to a variable in an expression. The variable is /// expected to have been declared and so should have a value in the symbol /// table, otherwise emit an error and return nullptr. - mlir::Value *mlirGen(VariableExprAST &expr) { - if (auto *variable = symbolTable.lookup(expr.getName())) + mlir::ValuePtr mlirGen(VariableExprAST &expr) { + if (auto variable = symbolTable.lookup(expr.getName())) return variable; emitError(loc(expr.loc()), "error: unknown variable '") @@ -233,7 +234,7 @@ private: auto location = loc(ret.loc()); // 'return' takes an optional expression, handle that case here. - mlir::Value *expr = nullptr; + mlir::ValuePtr expr = nullptr; if (ret.getExpr().hasValue()) { if (!(expr = mlirGen(*ret.getExpr().getValue()))) return mlir::failure(); @@ -241,7 +242,7 @@ private: // Otherwise, this return operation has zero operands. builder.create(location, expr ? makeArrayRef(expr) - : ArrayRef()); + : ArrayRef()); return mlir::success(); } @@ -263,7 +264,7 @@ private: /// [[1.000000e+00, 2.000000e+00, 3.000000e+00], /// [4.000000e+00, 5.000000e+00, 6.000000e+00]]>} : () -> tensor<2x3xf64> /// - mlir::Value *mlirGen(LiteralExprAST &lit) { + mlir::ValuePtr mlirGen(LiteralExprAST &lit) { auto type = getType(lit.getDims()); // The attribute is a vector with a floating point value per element @@ -309,14 +310,14 @@ private: /// Emit a call expression. It emits specific operations for the `transpose` /// builtin. Other identifiers are assumed to be user-defined functions. - mlir::Value *mlirGen(CallExprAST &call) { + mlir::ValuePtr mlirGen(CallExprAST &call) { llvm::StringRef callee = call.getCallee(); auto location = loc(call.loc()); // Codegen the operands first. - SmallVector operands; + SmallVector operands; for (auto &expr : call.getArgs()) { - auto *arg = mlirGen(*expr); + auto arg = mlirGen(*expr); if (!arg) return nullptr; operands.push_back(arg); @@ -342,7 +343,7 @@ private: /// Emit a print expression. It emits specific operations for two builtins: /// transpose(x) and print(x). mlir::LogicalResult mlirGen(PrintExprAST &call) { - auto *arg = mlirGen(*call.getArg()); + auto arg = mlirGen(*call.getArg()); if (!arg) return mlir::failure(); @@ -351,12 +352,12 @@ private: } /// Emit a constant for a single number (FIXME: semantic? broadcast?) - mlir::Value *mlirGen(NumberExprAST &num) { + mlir::ValuePtr mlirGen(NumberExprAST &num) { return builder.create(loc(num.loc()), num.getValue()); } /// Dispatch codegen for the right expression subclass using RTTI. - mlir::Value *mlirGen(ExprAST &expr) { + mlir::ValuePtr mlirGen(ExprAST &expr) { switch (expr.getKind()) { case toy::ExprAST::Expr_BinOp: return mlirGen(cast(expr)); @@ -380,7 +381,7 @@ private: /// initializer and record the value in the symbol table before returning it. /// Future expressions will be able to reference this variable through symbol /// table lookup. - mlir::Value *mlirGen(VarDeclExprAST &vardecl) { + mlir::ValuePtr mlirGen(VarDeclExprAST &vardecl) { auto init = vardecl.getInitVal(); if (!init) { emitError(loc(vardecl.loc()), @@ -388,7 +389,7 @@ private: return nullptr; } - mlir::Value *value = mlirGen(*init); + mlir::ValuePtr value = mlirGen(*init); if (!value) return nullptr; @@ -408,7 +409,7 @@ private: /// Codegen a list of expression, return failure if one of them hit an error. mlir::LogicalResult mlirGen(ExprASTList &blockAST) { - ScopedHashTableScope var_scope(symbolTable); + ScopedHashTableScope var_scope(symbolTable); for (auto &expr : blockAST) { // Specific handling for variable declarations, return statement, and // print. These can only appear in block list and not in nested diff --git a/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp index 1b9dcd20291..42a10397513 100644 --- a/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp @@ -48,7 +48,7 @@ struct SimplifyRedundantTranspose : public mlir::OpRewritePattern { matchAndRewrite(TransposeOp op, mlir::PatternRewriter &rewriter) const override { // Look through the input of the current transpose. - mlir::Value *transposeInput = op.getOperand(); + mlir::ValuePtr transposeInput = op.getOperand(); TransposeOp transposeInputOp = llvm::dyn_cast_or_null(transposeInput->getDefiningOp()); diff --git a/mlir/examples/toy/Ch4/include/toy/Ops.td b/mlir/examples/toy/Ch4/include/toy/Ops.td index aec1cc3cfc9..ef5b30a862b 100644 --- a/mlir/examples/toy/Ch4/include/toy/Ops.td +++ b/mlir/examples/toy/Ch4/include/toy/Ops.td @@ -100,7 +100,7 @@ def AddOp : Toy_Op<"add", // Allow building an AddOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *lhs, Value *rhs"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr lhs, ValuePtr rhs"> ]; } @@ -151,7 +151,7 @@ def GenericCallOp : Toy_Op<"generic_call", // Add custom build methods for the generic call operation. let builders = [ OpBuilder<"Builder *builder, OperationState &state, " - "StringRef callee, ArrayRef arguments"> + "StringRef callee, ArrayRef arguments"> ]; } @@ -168,7 +168,7 @@ def MulOp : Toy_Op<"mul", // Allow building a MulOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *lhs, Value *rhs"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr lhs, ValuePtr rhs"> ]; } @@ -245,7 +245,7 @@ def TransposeOp : Toy_Op<"transpose", // Allow building a TransposeOp with from the input operand. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *input"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr input"> ]; // Invoke a static verify method to verify this transpose operation. diff --git a/mlir/examples/toy/Ch4/mlir/Dialect.cpp b/mlir/examples/toy/Ch4/mlir/Dialect.cpp index 7003cbdcc81..8be1094cf15 100644 --- a/mlir/examples/toy/Ch4/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch4/mlir/Dialect.cpp @@ -55,7 +55,7 @@ struct ToyInlinerInterface : public DialectInlinerInterface { /// Handle the given inlined terminator(toy.return) by replacing it with a new /// operation as necessary. void handleTerminator(Operation *op, - ArrayRef valuesToRepl) const final { + ArrayRef valuesToRepl) const final { // Only "toy.return" needs to be handled here. auto returnOp = cast(op); @@ -70,7 +70,7 @@ struct ToyInlinerInterface : public DialectInlinerInterface { /// operation that takes 'input' as the only operand, and produces a single /// result of 'resultType'. If a conversion can not be generated, nullptr /// should be returned. - Operation *materializeCallConversion(OpBuilder &builder, Value *input, + Operation *materializeCallConversion(OpBuilder &builder, ValuePtr input, Type resultType, Location conversionLoc) const final { return builder.create(conversionLoc, resultType, input); @@ -144,7 +144,7 @@ static mlir::LogicalResult verify(ConstantOp op) { // AddOp void AddOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *lhs, mlir::Value *rhs) { + mlir::ValuePtr lhs, mlir::ValuePtr rhs) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -164,7 +164,8 @@ void CastOp::inferShapes() { getResult()->setType(getOperand()->getType()); } // GenericCallOp void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state, - StringRef callee, ArrayRef arguments) { + StringRef callee, + ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(arguments); @@ -185,7 +186,7 @@ Operation::operand_range GenericCallOp::getArgOperands() { return inputs(); } // MulOp void MulOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *lhs, mlir::Value *rhs) { + mlir::ValuePtr lhs, mlir::ValuePtr rhs) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -236,7 +237,7 @@ static mlir::LogicalResult verify(ReturnOp op) { // TransposeOp void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *value) { + mlir::ValuePtr value) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp index da474e809b3..902c634a954 100644 --- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp @@ -99,7 +99,7 @@ private: /// Entering a function creates a new scope, and the function arguments are /// added to the mapping. When the processing of a function is terminated, the /// scope is destroyed and the mappings created in this scope are dropped. - llvm::ScopedHashTable symbolTable; + llvm::ScopedHashTable symbolTable; /// Helper conversion for a Toy AST location to an MLIR location. mlir::Location loc(Location loc) { @@ -109,7 +109,7 @@ private: /// Declare a variable in the current scope, return success if the variable /// wasn't declared yet. - mlir::LogicalResult declare(llvm::StringRef var, mlir::Value *value) { + mlir::LogicalResult declare(llvm::StringRef var, mlir::ValuePtr value) { if (symbolTable.count(var)) return mlir::failure(); symbolTable.insert(var, value); @@ -132,7 +132,8 @@ private: /// Emit a new function and add it to the MLIR module. mlir::FuncOp mlirGen(FunctionAST &funcAST) { // Create a scope in the symbol table to hold variable declarations. - ScopedHashTableScope var_scope(symbolTable); + ScopedHashTableScope var_scope( + symbolTable); // Create an MLIR function for the given prototype. mlir::FuncOp function(mlirGen(*funcAST.getProto())); @@ -183,7 +184,7 @@ private: } /// Emit a binary operation - mlir::Value *mlirGen(BinaryExprAST &binop) { + mlir::ValuePtr mlirGen(BinaryExprAST &binop) { // First emit the operations for each side of the operation before emitting // the operation itself. For example if the expression is `a + foo(a)` // 1) First it will visiting the LHS, which will return a reference to the @@ -195,10 +196,10 @@ private: // and the result value is returned. If an error occurs we get a nullptr // and propagate. // - mlir::Value *lhs = mlirGen(*binop.getLHS()); + mlir::ValuePtr lhs = mlirGen(*binop.getLHS()); if (!lhs) return nullptr; - mlir::Value *rhs = mlirGen(*binop.getRHS()); + mlir::ValuePtr rhs = mlirGen(*binop.getRHS()); if (!rhs) return nullptr; auto location = loc(binop.loc()); @@ -219,8 +220,8 @@ private: /// This is a reference to a variable in an expression. The variable is /// expected to have been declared and so should have a value in the symbol /// table, otherwise emit an error and return nullptr. - mlir::Value *mlirGen(VariableExprAST &expr) { - if (auto *variable = symbolTable.lookup(expr.getName())) + mlir::ValuePtr mlirGen(VariableExprAST &expr) { + if (auto variable = symbolTable.lookup(expr.getName())) return variable; emitError(loc(expr.loc()), "error: unknown variable '") @@ -233,7 +234,7 @@ private: auto location = loc(ret.loc()); // 'return' takes an optional expression, handle that case here. - mlir::Value *expr = nullptr; + mlir::ValuePtr expr = nullptr; if (ret.getExpr().hasValue()) { if (!(expr = mlirGen(*ret.getExpr().getValue()))) return mlir::failure(); @@ -241,7 +242,7 @@ private: // Otherwise, this return operation has zero operands. builder.create(location, expr ? makeArrayRef(expr) - : ArrayRef()); + : ArrayRef()); return mlir::success(); } @@ -263,7 +264,7 @@ private: /// [[1.000000e+00, 2.000000e+00, 3.000000e+00], /// [4.000000e+00, 5.000000e+00, 6.000000e+00]]>} : () -> tensor<2x3xf64> /// - mlir::Value *mlirGen(LiteralExprAST &lit) { + mlir::ValuePtr mlirGen(LiteralExprAST &lit) { auto type = getType(lit.getDims()); // The attribute is a vector with a floating point value per element @@ -309,14 +310,14 @@ private: /// Emit a call expression. It emits specific operations for the `transpose` /// builtin. Other identifiers are assumed to be user-defined functions. - mlir::Value *mlirGen(CallExprAST &call) { + mlir::ValuePtr mlirGen(CallExprAST &call) { llvm::StringRef callee = call.getCallee(); auto location = loc(call.loc()); // Codegen the operands first. - SmallVector operands; + SmallVector operands; for (auto &expr : call.getArgs()) { - auto *arg = mlirGen(*expr); + auto arg = mlirGen(*expr); if (!arg) return nullptr; operands.push_back(arg); @@ -342,7 +343,7 @@ private: /// Emit a print expression. It emits specific operations for two builtins: /// transpose(x) and print(x). mlir::LogicalResult mlirGen(PrintExprAST &call) { - auto *arg = mlirGen(*call.getArg()); + auto arg = mlirGen(*call.getArg()); if (!arg) return mlir::failure(); @@ -351,12 +352,12 @@ private: } /// Emit a constant for a single number (FIXME: semantic? broadcast?) - mlir::Value *mlirGen(NumberExprAST &num) { + mlir::ValuePtr mlirGen(NumberExprAST &num) { return builder.create(loc(num.loc()), num.getValue()); } /// Dispatch codegen for the right expression subclass using RTTI. - mlir::Value *mlirGen(ExprAST &expr) { + mlir::ValuePtr mlirGen(ExprAST &expr) { switch (expr.getKind()) { case toy::ExprAST::Expr_BinOp: return mlirGen(cast(expr)); @@ -380,7 +381,7 @@ private: /// initializer and record the value in the symbol table before returning it. /// Future expressions will be able to reference this variable through symbol /// table lookup. - mlir::Value *mlirGen(VarDeclExprAST &vardecl) { + mlir::ValuePtr mlirGen(VarDeclExprAST &vardecl) { auto init = vardecl.getInitVal(); if (!init) { emitError(loc(vardecl.loc()), @@ -388,7 +389,7 @@ private: return nullptr; } - mlir::Value *value = mlirGen(*init); + mlir::ValuePtr value = mlirGen(*init); if (!value) return nullptr; @@ -408,7 +409,7 @@ private: /// Codegen a list of expression, return failure if one of them hit an error. mlir::LogicalResult mlirGen(ExprASTList &blockAST) { - ScopedHashTableScope var_scope(symbolTable); + ScopedHashTableScope var_scope(symbolTable); for (auto &expr : blockAST) { // Specific handling for variable declarations, return statement, and // print. These can only appear in block list and not in nested diff --git a/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp index 47e1abc6c74..604e9fa6c83 100644 --- a/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp @@ -53,7 +53,7 @@ struct SimplifyRedundantTranspose : public mlir::OpRewritePattern { matchAndRewrite(TransposeOp op, mlir::PatternRewriter &rewriter) const override { // Look through the input of the current transpose. - mlir::Value *transposeInput = op.getOperand(); + mlir::ValuePtr transposeInput = op.getOperand(); TransposeOp transposeInputOp = llvm::dyn_cast_or_null(transposeInput->getDefiningOp()); diff --git a/mlir/examples/toy/Ch5/include/toy/Ops.td b/mlir/examples/toy/Ch5/include/toy/Ops.td index e40b661fd34..b3bda1d647b 100644 --- a/mlir/examples/toy/Ch5/include/toy/Ops.td +++ b/mlir/examples/toy/Ch5/include/toy/Ops.td @@ -100,7 +100,7 @@ def AddOp : Toy_Op<"add", // Allow building an AddOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *lhs, Value *rhs"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr lhs, ValuePtr rhs"> ]; } @@ -151,7 +151,7 @@ def GenericCallOp : Toy_Op<"generic_call", // Add custom build methods for the generic call operation. let builders = [ OpBuilder<"Builder *builder, OperationState &state, " - "StringRef callee, ArrayRef arguments"> + "StringRef callee, ArrayRef arguments"> ]; } @@ -168,7 +168,7 @@ def MulOp : Toy_Op<"mul", // Allow building a MulOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *lhs, Value *rhs"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr lhs, ValuePtr rhs"> ]; } @@ -246,7 +246,7 @@ def TransposeOp : Toy_Op<"transpose", // Allow building a TransposeOp with from the input operand. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *input"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr input"> ]; // Invoke a static verify method to verify this transpose operation. diff --git a/mlir/examples/toy/Ch5/mlir/Dialect.cpp b/mlir/examples/toy/Ch5/mlir/Dialect.cpp index 7003cbdcc81..8be1094cf15 100644 --- a/mlir/examples/toy/Ch5/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch5/mlir/Dialect.cpp @@ -55,7 +55,7 @@ struct ToyInlinerInterface : public DialectInlinerInterface { /// Handle the given inlined terminator(toy.return) by replacing it with a new /// operation as necessary. void handleTerminator(Operation *op, - ArrayRef valuesToRepl) const final { + ArrayRef valuesToRepl) const final { // Only "toy.return" needs to be handled here. auto returnOp = cast(op); @@ -70,7 +70,7 @@ struct ToyInlinerInterface : public DialectInlinerInterface { /// operation that takes 'input' as the only operand, and produces a single /// result of 'resultType'. If a conversion can not be generated, nullptr /// should be returned. - Operation *materializeCallConversion(OpBuilder &builder, Value *input, + Operation *materializeCallConversion(OpBuilder &builder, ValuePtr input, Type resultType, Location conversionLoc) const final { return builder.create(conversionLoc, resultType, input); @@ -144,7 +144,7 @@ static mlir::LogicalResult verify(ConstantOp op) { // AddOp void AddOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *lhs, mlir::Value *rhs) { + mlir::ValuePtr lhs, mlir::ValuePtr rhs) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -164,7 +164,8 @@ void CastOp::inferShapes() { getResult()->setType(getOperand()->getType()); } // GenericCallOp void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state, - StringRef callee, ArrayRef arguments) { + StringRef callee, + ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(arguments); @@ -185,7 +186,7 @@ Operation::operand_range GenericCallOp::getArgOperands() { return inputs(); } // MulOp void MulOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *lhs, mlir::Value *rhs) { + mlir::ValuePtr lhs, mlir::ValuePtr rhs) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -236,7 +237,7 @@ static mlir::LogicalResult verify(ReturnOp op) { // TransposeOp void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *value) { + mlir::ValuePtr value) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp index 4ab8c5b501c..3fa761c7404 100644 --- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp @@ -43,8 +43,8 @@ static MemRefType convertTensorToMemRef(TensorType type) { } /// Insert an allocation and deallocation for the given MemRefType. -static Value *insertAllocAndDealloc(MemRefType type, Location loc, - PatternRewriter &rewriter) { +static ValuePtr insertAllocAndDealloc(MemRefType type, Location loc, + PatternRewriter &rewriter) { auto alloc = rewriter.create(loc, type); // Make sure to allocate at the beginning of the block. @@ -63,11 +63,11 @@ static Value *insertAllocAndDealloc(MemRefType type, Location loc, /// to the operands of the input operation, and the set of loop induction /// variables for the iteration. It returns a value to store at the current /// index of the iteration. -using LoopIterationFn = function_ref memRefOperands, - ArrayRef loopIvs)>; +using LoopIterationFn = function_ref memRefOperands, + ArrayRef loopIvs)>; -static void lowerOpToLoops(Operation *op, ArrayRef operands, +static void lowerOpToLoops(Operation *op, ArrayRef operands, PatternRewriter &rewriter, LoopIterationFn processIteration) { auto tensorType = (*op->result_type_begin()).cast(); @@ -78,7 +78,7 @@ static void lowerOpToLoops(Operation *op, ArrayRef operands, auto alloc = insertAllocAndDealloc(memRefType, loc, rewriter); // Create an empty affine loop for each of the dimensions within the shape. - SmallVector loopIvs; + SmallVector loopIvs; for (auto dim : tensorType.getShape()) { auto loop = rewriter.create(loc, /*lb=*/0, dim, /*step=*/1); loop.getBody()->clear(); @@ -94,7 +94,7 @@ static void lowerOpToLoops(Operation *op, ArrayRef operands, // Generate a call to the processing function with the rewriter, the memref // operands, and the loop induction variables. This function will return the // value to store at the current index. - Value *valueToStore = processIteration(rewriter, operands, loopIvs); + ValuePtr valueToStore = processIteration(rewriter, operands, loopIvs); rewriter.create(loc, valueToStore, alloc, llvm::makeArrayRef(loopIvs)); @@ -113,13 +113,13 @@ struct BinaryOpLowering : public ConversionPattern { : ConversionPattern(BinaryOp::getOperationName(), 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { auto loc = op->getLoc(); lowerOpToLoops( op, operands, rewriter, - [loc](PatternRewriter &rewriter, ArrayRef memRefOperands, - ArrayRef loopIvs) { + [loc](PatternRewriter &rewriter, ArrayRef memRefOperands, + ArrayRef loopIvs) { // Generate an adaptor for the remapped operands of the BinaryOp. This // allows for using the nice named accessors that are generated by the // ODS. @@ -163,7 +163,7 @@ struct ConstantOpLowering : public OpRewritePattern { // Create these constants up-front to avoid large amounts of redundant // operations. auto valueShape = memRefType.getShape(); - SmallVector constantIndices; + SmallVector constantIndices; for (auto i : llvm::seq( 0, *std::max_element(valueShape.begin(), valueShape.end()))) constantIndices.push_back(rewriter.create(loc, i)); @@ -172,7 +172,7 @@ struct ConstantOpLowering : public OpRewritePattern { // will need to generate a store for each of the elements. The following // functor recursively walks the dimensions of the constant shape, // generating a store when the recursion hits the base case. - SmallVector indices; + SmallVector indices; auto valueIt = constantValue.getValues().begin(); std::function storeElements = [&](uint64_t dimension) { // The last dimension is the base case of the recursion, at this point @@ -231,22 +231,22 @@ struct TransposeOpLowering : public ConversionPattern { : ConversionPattern(toy::TransposeOp::getOperationName(), 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { auto loc = op->getLoc(); lowerOpToLoops( op, operands, rewriter, - [loc](PatternRewriter &rewriter, ArrayRef memRefOperands, - ArrayRef loopIvs) { + [loc](PatternRewriter &rewriter, ArrayRef memRefOperands, + ArrayRef loopIvs) { // Generate an adaptor for the remapped operands of the TransposeOp. // This allows for using the nice named accessors that are generated // by the ODS. toy::TransposeOpOperandAdaptor transposeAdaptor(memRefOperands); - Value *input = transposeAdaptor.input(); + ValuePtr input = transposeAdaptor.input(); // Transpose the elements by generating a load from the reverse // indices. - SmallVector reverseIvs(llvm::reverse(loopIvs)); + SmallVector reverseIvs(llvm::reverse(loopIvs)); return rewriter.create(loc, input, reverseIvs); }); return matchSuccess(); diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp index da474e809b3..902c634a954 100644 --- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp @@ -99,7 +99,7 @@ private: /// Entering a function creates a new scope, and the function arguments are /// added to the mapping. When the processing of a function is terminated, the /// scope is destroyed and the mappings created in this scope are dropped. - llvm::ScopedHashTable symbolTable; + llvm::ScopedHashTable symbolTable; /// Helper conversion for a Toy AST location to an MLIR location. mlir::Location loc(Location loc) { @@ -109,7 +109,7 @@ private: /// Declare a variable in the current scope, return success if the variable /// wasn't declared yet. - mlir::LogicalResult declare(llvm::StringRef var, mlir::Value *value) { + mlir::LogicalResult declare(llvm::StringRef var, mlir::ValuePtr value) { if (symbolTable.count(var)) return mlir::failure(); symbolTable.insert(var, value); @@ -132,7 +132,8 @@ private: /// Emit a new function and add it to the MLIR module. mlir::FuncOp mlirGen(FunctionAST &funcAST) { // Create a scope in the symbol table to hold variable declarations. - ScopedHashTableScope var_scope(symbolTable); + ScopedHashTableScope var_scope( + symbolTable); // Create an MLIR function for the given prototype. mlir::FuncOp function(mlirGen(*funcAST.getProto())); @@ -183,7 +184,7 @@ private: } /// Emit a binary operation - mlir::Value *mlirGen(BinaryExprAST &binop) { + mlir::ValuePtr mlirGen(BinaryExprAST &binop) { // First emit the operations for each side of the operation before emitting // the operation itself. For example if the expression is `a + foo(a)` // 1) First it will visiting the LHS, which will return a reference to the @@ -195,10 +196,10 @@ private: // and the result value is returned. If an error occurs we get a nullptr // and propagate. // - mlir::Value *lhs = mlirGen(*binop.getLHS()); + mlir::ValuePtr lhs = mlirGen(*binop.getLHS()); if (!lhs) return nullptr; - mlir::Value *rhs = mlirGen(*binop.getRHS()); + mlir::ValuePtr rhs = mlirGen(*binop.getRHS()); if (!rhs) return nullptr; auto location = loc(binop.loc()); @@ -219,8 +220,8 @@ private: /// This is a reference to a variable in an expression. The variable is /// expected to have been declared and so should have a value in the symbol /// table, otherwise emit an error and return nullptr. - mlir::Value *mlirGen(VariableExprAST &expr) { - if (auto *variable = symbolTable.lookup(expr.getName())) + mlir::ValuePtr mlirGen(VariableExprAST &expr) { + if (auto variable = symbolTable.lookup(expr.getName())) return variable; emitError(loc(expr.loc()), "error: unknown variable '") @@ -233,7 +234,7 @@ private: auto location = loc(ret.loc()); // 'return' takes an optional expression, handle that case here. - mlir::Value *expr = nullptr; + mlir::ValuePtr expr = nullptr; if (ret.getExpr().hasValue()) { if (!(expr = mlirGen(*ret.getExpr().getValue()))) return mlir::failure(); @@ -241,7 +242,7 @@ private: // Otherwise, this return operation has zero operands. builder.create(location, expr ? makeArrayRef(expr) - : ArrayRef()); + : ArrayRef()); return mlir::success(); } @@ -263,7 +264,7 @@ private: /// [[1.000000e+00, 2.000000e+00, 3.000000e+00], /// [4.000000e+00, 5.000000e+00, 6.000000e+00]]>} : () -> tensor<2x3xf64> /// - mlir::Value *mlirGen(LiteralExprAST &lit) { + mlir::ValuePtr mlirGen(LiteralExprAST &lit) { auto type = getType(lit.getDims()); // The attribute is a vector with a floating point value per element @@ -309,14 +310,14 @@ private: /// Emit a call expression. It emits specific operations for the `transpose` /// builtin. Other identifiers are assumed to be user-defined functions. - mlir::Value *mlirGen(CallExprAST &call) { + mlir::ValuePtr mlirGen(CallExprAST &call) { llvm::StringRef callee = call.getCallee(); auto location = loc(call.loc()); // Codegen the operands first. - SmallVector operands; + SmallVector operands; for (auto &expr : call.getArgs()) { - auto *arg = mlirGen(*expr); + auto arg = mlirGen(*expr); if (!arg) return nullptr; operands.push_back(arg); @@ -342,7 +343,7 @@ private: /// Emit a print expression. It emits specific operations for two builtins: /// transpose(x) and print(x). mlir::LogicalResult mlirGen(PrintExprAST &call) { - auto *arg = mlirGen(*call.getArg()); + auto arg = mlirGen(*call.getArg()); if (!arg) return mlir::failure(); @@ -351,12 +352,12 @@ private: } /// Emit a constant for a single number (FIXME: semantic? broadcast?) - mlir::Value *mlirGen(NumberExprAST &num) { + mlir::ValuePtr mlirGen(NumberExprAST &num) { return builder.create(loc(num.loc()), num.getValue()); } /// Dispatch codegen for the right expression subclass using RTTI. - mlir::Value *mlirGen(ExprAST &expr) { + mlir::ValuePtr mlirGen(ExprAST &expr) { switch (expr.getKind()) { case toy::ExprAST::Expr_BinOp: return mlirGen(cast(expr)); @@ -380,7 +381,7 @@ private: /// initializer and record the value in the symbol table before returning it. /// Future expressions will be able to reference this variable through symbol /// table lookup. - mlir::Value *mlirGen(VarDeclExprAST &vardecl) { + mlir::ValuePtr mlirGen(VarDeclExprAST &vardecl) { auto init = vardecl.getInitVal(); if (!init) { emitError(loc(vardecl.loc()), @@ -388,7 +389,7 @@ private: return nullptr; } - mlir::Value *value = mlirGen(*init); + mlir::ValuePtr value = mlirGen(*init); if (!value) return nullptr; @@ -408,7 +409,7 @@ private: /// Codegen a list of expression, return failure if one of them hit an error. mlir::LogicalResult mlirGen(ExprASTList &blockAST) { - ScopedHashTableScope var_scope(symbolTable); + ScopedHashTableScope var_scope(symbolTable); for (auto &expr : blockAST) { // Specific handling for variable declarations, return statement, and // print. These can only appear in block list and not in nested diff --git a/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp index 47e1abc6c74..604e9fa6c83 100644 --- a/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp @@ -53,7 +53,7 @@ struct SimplifyRedundantTranspose : public mlir::OpRewritePattern { matchAndRewrite(TransposeOp op, mlir::PatternRewriter &rewriter) const override { // Look through the input of the current transpose. - mlir::Value *transposeInput = op.getOperand(); + mlir::ValuePtr transposeInput = op.getOperand(); TransposeOp transposeInputOp = llvm::dyn_cast_or_null(transposeInput->getDefiningOp()); diff --git a/mlir/examples/toy/Ch6/include/toy/Ops.td b/mlir/examples/toy/Ch6/include/toy/Ops.td index e40b661fd34..b3bda1d647b 100644 --- a/mlir/examples/toy/Ch6/include/toy/Ops.td +++ b/mlir/examples/toy/Ch6/include/toy/Ops.td @@ -100,7 +100,7 @@ def AddOp : Toy_Op<"add", // Allow building an AddOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *lhs, Value *rhs"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr lhs, ValuePtr rhs"> ]; } @@ -151,7 +151,7 @@ def GenericCallOp : Toy_Op<"generic_call", // Add custom build methods for the generic call operation. let builders = [ OpBuilder<"Builder *builder, OperationState &state, " - "StringRef callee, ArrayRef arguments"> + "StringRef callee, ArrayRef arguments"> ]; } @@ -168,7 +168,7 @@ def MulOp : Toy_Op<"mul", // Allow building a MulOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *lhs, Value *rhs"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr lhs, ValuePtr rhs"> ]; } @@ -246,7 +246,7 @@ def TransposeOp : Toy_Op<"transpose", // Allow building a TransposeOp with from the input operand. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *input"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr input"> ]; // Invoke a static verify method to verify this transpose operation. diff --git a/mlir/examples/toy/Ch6/mlir/Dialect.cpp b/mlir/examples/toy/Ch6/mlir/Dialect.cpp index 7003cbdcc81..8be1094cf15 100644 --- a/mlir/examples/toy/Ch6/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch6/mlir/Dialect.cpp @@ -55,7 +55,7 @@ struct ToyInlinerInterface : public DialectInlinerInterface { /// Handle the given inlined terminator(toy.return) by replacing it with a new /// operation as necessary. void handleTerminator(Operation *op, - ArrayRef valuesToRepl) const final { + ArrayRef valuesToRepl) const final { // Only "toy.return" needs to be handled here. auto returnOp = cast(op); @@ -70,7 +70,7 @@ struct ToyInlinerInterface : public DialectInlinerInterface { /// operation that takes 'input' as the only operand, and produces a single /// result of 'resultType'. If a conversion can not be generated, nullptr /// should be returned. - Operation *materializeCallConversion(OpBuilder &builder, Value *input, + Operation *materializeCallConversion(OpBuilder &builder, ValuePtr input, Type resultType, Location conversionLoc) const final { return builder.create(conversionLoc, resultType, input); @@ -144,7 +144,7 @@ static mlir::LogicalResult verify(ConstantOp op) { // AddOp void AddOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *lhs, mlir::Value *rhs) { + mlir::ValuePtr lhs, mlir::ValuePtr rhs) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -164,7 +164,8 @@ void CastOp::inferShapes() { getResult()->setType(getOperand()->getType()); } // GenericCallOp void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state, - StringRef callee, ArrayRef arguments) { + StringRef callee, + ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(arguments); @@ -185,7 +186,7 @@ Operation::operand_range GenericCallOp::getArgOperands() { return inputs(); } // MulOp void MulOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *lhs, mlir::Value *rhs) { + mlir::ValuePtr lhs, mlir::ValuePtr rhs) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -236,7 +237,7 @@ static mlir::LogicalResult verify(ReturnOp op) { // TransposeOp void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *value) { + mlir::ValuePtr value) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp index 4ab8c5b501c..3fa761c7404 100644 --- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp @@ -43,8 +43,8 @@ static MemRefType convertTensorToMemRef(TensorType type) { } /// Insert an allocation and deallocation for the given MemRefType. -static Value *insertAllocAndDealloc(MemRefType type, Location loc, - PatternRewriter &rewriter) { +static ValuePtr insertAllocAndDealloc(MemRefType type, Location loc, + PatternRewriter &rewriter) { auto alloc = rewriter.create(loc, type); // Make sure to allocate at the beginning of the block. @@ -63,11 +63,11 @@ static Value *insertAllocAndDealloc(MemRefType type, Location loc, /// to the operands of the input operation, and the set of loop induction /// variables for the iteration. It returns a value to store at the current /// index of the iteration. -using LoopIterationFn = function_ref memRefOperands, - ArrayRef loopIvs)>; +using LoopIterationFn = function_ref memRefOperands, + ArrayRef loopIvs)>; -static void lowerOpToLoops(Operation *op, ArrayRef operands, +static void lowerOpToLoops(Operation *op, ArrayRef operands, PatternRewriter &rewriter, LoopIterationFn processIteration) { auto tensorType = (*op->result_type_begin()).cast(); @@ -78,7 +78,7 @@ static void lowerOpToLoops(Operation *op, ArrayRef operands, auto alloc = insertAllocAndDealloc(memRefType, loc, rewriter); // Create an empty affine loop for each of the dimensions within the shape. - SmallVector loopIvs; + SmallVector loopIvs; for (auto dim : tensorType.getShape()) { auto loop = rewriter.create(loc, /*lb=*/0, dim, /*step=*/1); loop.getBody()->clear(); @@ -94,7 +94,7 @@ static void lowerOpToLoops(Operation *op, ArrayRef operands, // Generate a call to the processing function with the rewriter, the memref // operands, and the loop induction variables. This function will return the // value to store at the current index. - Value *valueToStore = processIteration(rewriter, operands, loopIvs); + ValuePtr valueToStore = processIteration(rewriter, operands, loopIvs); rewriter.create(loc, valueToStore, alloc, llvm::makeArrayRef(loopIvs)); @@ -113,13 +113,13 @@ struct BinaryOpLowering : public ConversionPattern { : ConversionPattern(BinaryOp::getOperationName(), 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { auto loc = op->getLoc(); lowerOpToLoops( op, operands, rewriter, - [loc](PatternRewriter &rewriter, ArrayRef memRefOperands, - ArrayRef loopIvs) { + [loc](PatternRewriter &rewriter, ArrayRef memRefOperands, + ArrayRef loopIvs) { // Generate an adaptor for the remapped operands of the BinaryOp. This // allows for using the nice named accessors that are generated by the // ODS. @@ -163,7 +163,7 @@ struct ConstantOpLowering : public OpRewritePattern { // Create these constants up-front to avoid large amounts of redundant // operations. auto valueShape = memRefType.getShape(); - SmallVector constantIndices; + SmallVector constantIndices; for (auto i : llvm::seq( 0, *std::max_element(valueShape.begin(), valueShape.end()))) constantIndices.push_back(rewriter.create(loc, i)); @@ -172,7 +172,7 @@ struct ConstantOpLowering : public OpRewritePattern { // will need to generate a store for each of the elements. The following // functor recursively walks the dimensions of the constant shape, // generating a store when the recursion hits the base case. - SmallVector indices; + SmallVector indices; auto valueIt = constantValue.getValues().begin(); std::function storeElements = [&](uint64_t dimension) { // The last dimension is the base case of the recursion, at this point @@ -231,22 +231,22 @@ struct TransposeOpLowering : public ConversionPattern { : ConversionPattern(toy::TransposeOp::getOperationName(), 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { auto loc = op->getLoc(); lowerOpToLoops( op, operands, rewriter, - [loc](PatternRewriter &rewriter, ArrayRef memRefOperands, - ArrayRef loopIvs) { + [loc](PatternRewriter &rewriter, ArrayRef memRefOperands, + ArrayRef loopIvs) { // Generate an adaptor for the remapped operands of the TransposeOp. // This allows for using the nice named accessors that are generated // by the ODS. toy::TransposeOpOperandAdaptor transposeAdaptor(memRefOperands); - Value *input = transposeAdaptor.input(); + ValuePtr input = transposeAdaptor.input(); // Transpose the elements by generating a load from the reverse // indices. - SmallVector reverseIvs(llvm::reverse(loopIvs)); + SmallVector reverseIvs(llvm::reverse(loopIvs)); return rewriter.create(loc, input, reverseIvs); }); return matchSuccess(); diff --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp index d35cc5c576a..c3180b4a92d 100644 --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -51,7 +51,7 @@ public: : ConversionPattern(toy::PrintOp::getOperationName(), 1, context) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto memRefType = (*op->operand_type_begin()).cast(); auto memRefShape = memRefType.getShape(); @@ -64,14 +64,14 @@ public: // Get a symbol reference to the printf function, inserting it if necessary. auto printfRef = getOrInsertPrintf(rewriter, parentModule, llvmDialect); - Value *formatSpecifierCst = getOrCreateGlobalString( + ValuePtr formatSpecifierCst = getOrCreateGlobalString( loc, rewriter, "frmt_spec", StringRef("%f \0", 4), parentModule, llvmDialect); - Value *newLineCst = getOrCreateGlobalString( + ValuePtr newLineCst = getOrCreateGlobalString( loc, rewriter, "nl", StringRef("\n\0", 2), parentModule, llvmDialect); // Create a loop for each of the dimensions within the shape. - SmallVector loopIvs; + SmallVector loopIvs; for (unsigned i = 0, e = memRefShape.size(); i != e; ++i) { auto lowerBound = rewriter.create(loc, 0); auto upperBound = rewriter.create(loc, memRefShape[i]); @@ -97,7 +97,7 @@ public: auto elementLoad = rewriter.create(loc, printOp.input(), loopIvs); rewriter.create( loc, printfRef, rewriter.getIntegerType(32), - ArrayRef({formatSpecifierCst, elementLoad})); + ArrayRef({formatSpecifierCst, elementLoad})); // Notify the rewriter that this operation has been removed. rewriter.eraseOp(op); @@ -130,10 +130,10 @@ private: /// Return a value representing an access into a global string with the given /// name, creating the string if necessary. - static Value *getOrCreateGlobalString(Location loc, OpBuilder &builder, - StringRef name, StringRef value, - ModuleOp module, - LLVM::LLVMDialect *llvmDialect) { + static ValuePtr getOrCreateGlobalString(Location loc, OpBuilder &builder, + StringRef name, StringRef value, + ModuleOp module, + LLVM::LLVMDialect *llvmDialect) { // Create the global at the entry of the module. LLVM::GlobalOp global; if (!(global = module.lookupSymbol(name))) { @@ -147,13 +147,13 @@ private: } // Get the pointer to the first character in the global string. - Value *globalPtr = builder.create(loc, global); - Value *cst0 = builder.create( + ValuePtr globalPtr = builder.create(loc, global); + ValuePtr cst0 = builder.create( loc, LLVM::LLVMType::getInt64Ty(llvmDialect), builder.getIntegerAttr(builder.getIndexType(), 0)); return builder.create( loc, LLVM::LLVMType::getInt8PtrTy(llvmDialect), globalPtr, - ArrayRef({cst0, cst0})); + ArrayRef({cst0, cst0})); } }; } // end anonymous namespace diff --git a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp index da474e809b3..902c634a954 100644 --- a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp @@ -99,7 +99,7 @@ private: /// Entering a function creates a new scope, and the function arguments are /// added to the mapping. When the processing of a function is terminated, the /// scope is destroyed and the mappings created in this scope are dropped. - llvm::ScopedHashTable symbolTable; + llvm::ScopedHashTable symbolTable; /// Helper conversion for a Toy AST location to an MLIR location. mlir::Location loc(Location loc) { @@ -109,7 +109,7 @@ private: /// Declare a variable in the current scope, return success if the variable /// wasn't declared yet. - mlir::LogicalResult declare(llvm::StringRef var, mlir::Value *value) { + mlir::LogicalResult declare(llvm::StringRef var, mlir::ValuePtr value) { if (symbolTable.count(var)) return mlir::failure(); symbolTable.insert(var, value); @@ -132,7 +132,8 @@ private: /// Emit a new function and add it to the MLIR module. mlir::FuncOp mlirGen(FunctionAST &funcAST) { // Create a scope in the symbol table to hold variable declarations. - ScopedHashTableScope var_scope(symbolTable); + ScopedHashTableScope var_scope( + symbolTable); // Create an MLIR function for the given prototype. mlir::FuncOp function(mlirGen(*funcAST.getProto())); @@ -183,7 +184,7 @@ private: } /// Emit a binary operation - mlir::Value *mlirGen(BinaryExprAST &binop) { + mlir::ValuePtr mlirGen(BinaryExprAST &binop) { // First emit the operations for each side of the operation before emitting // the operation itself. For example if the expression is `a + foo(a)` // 1) First it will visiting the LHS, which will return a reference to the @@ -195,10 +196,10 @@ private: // and the result value is returned. If an error occurs we get a nullptr // and propagate. // - mlir::Value *lhs = mlirGen(*binop.getLHS()); + mlir::ValuePtr lhs = mlirGen(*binop.getLHS()); if (!lhs) return nullptr; - mlir::Value *rhs = mlirGen(*binop.getRHS()); + mlir::ValuePtr rhs = mlirGen(*binop.getRHS()); if (!rhs) return nullptr; auto location = loc(binop.loc()); @@ -219,8 +220,8 @@ private: /// This is a reference to a variable in an expression. The variable is /// expected to have been declared and so should have a value in the symbol /// table, otherwise emit an error and return nullptr. - mlir::Value *mlirGen(VariableExprAST &expr) { - if (auto *variable = symbolTable.lookup(expr.getName())) + mlir::ValuePtr mlirGen(VariableExprAST &expr) { + if (auto variable = symbolTable.lookup(expr.getName())) return variable; emitError(loc(expr.loc()), "error: unknown variable '") @@ -233,7 +234,7 @@ private: auto location = loc(ret.loc()); // 'return' takes an optional expression, handle that case here. - mlir::Value *expr = nullptr; + mlir::ValuePtr expr = nullptr; if (ret.getExpr().hasValue()) { if (!(expr = mlirGen(*ret.getExpr().getValue()))) return mlir::failure(); @@ -241,7 +242,7 @@ private: // Otherwise, this return operation has zero operands. builder.create(location, expr ? makeArrayRef(expr) - : ArrayRef()); + : ArrayRef()); return mlir::success(); } @@ -263,7 +264,7 @@ private: /// [[1.000000e+00, 2.000000e+00, 3.000000e+00], /// [4.000000e+00, 5.000000e+00, 6.000000e+00]]>} : () -> tensor<2x3xf64> /// - mlir::Value *mlirGen(LiteralExprAST &lit) { + mlir::ValuePtr mlirGen(LiteralExprAST &lit) { auto type = getType(lit.getDims()); // The attribute is a vector with a floating point value per element @@ -309,14 +310,14 @@ private: /// Emit a call expression. It emits specific operations for the `transpose` /// builtin. Other identifiers are assumed to be user-defined functions. - mlir::Value *mlirGen(CallExprAST &call) { + mlir::ValuePtr mlirGen(CallExprAST &call) { llvm::StringRef callee = call.getCallee(); auto location = loc(call.loc()); // Codegen the operands first. - SmallVector operands; + SmallVector operands; for (auto &expr : call.getArgs()) { - auto *arg = mlirGen(*expr); + auto arg = mlirGen(*expr); if (!arg) return nullptr; operands.push_back(arg); @@ -342,7 +343,7 @@ private: /// Emit a print expression. It emits specific operations for two builtins: /// transpose(x) and print(x). mlir::LogicalResult mlirGen(PrintExprAST &call) { - auto *arg = mlirGen(*call.getArg()); + auto arg = mlirGen(*call.getArg()); if (!arg) return mlir::failure(); @@ -351,12 +352,12 @@ private: } /// Emit a constant for a single number (FIXME: semantic? broadcast?) - mlir::Value *mlirGen(NumberExprAST &num) { + mlir::ValuePtr mlirGen(NumberExprAST &num) { return builder.create(loc(num.loc()), num.getValue()); } /// Dispatch codegen for the right expression subclass using RTTI. - mlir::Value *mlirGen(ExprAST &expr) { + mlir::ValuePtr mlirGen(ExprAST &expr) { switch (expr.getKind()) { case toy::ExprAST::Expr_BinOp: return mlirGen(cast(expr)); @@ -380,7 +381,7 @@ private: /// initializer and record the value in the symbol table before returning it. /// Future expressions will be able to reference this variable through symbol /// table lookup. - mlir::Value *mlirGen(VarDeclExprAST &vardecl) { + mlir::ValuePtr mlirGen(VarDeclExprAST &vardecl) { auto init = vardecl.getInitVal(); if (!init) { emitError(loc(vardecl.loc()), @@ -388,7 +389,7 @@ private: return nullptr; } - mlir::Value *value = mlirGen(*init); + mlir::ValuePtr value = mlirGen(*init); if (!value) return nullptr; @@ -408,7 +409,7 @@ private: /// Codegen a list of expression, return failure if one of them hit an error. mlir::LogicalResult mlirGen(ExprASTList &blockAST) { - ScopedHashTableScope var_scope(symbolTable); + ScopedHashTableScope var_scope(symbolTable); for (auto &expr : blockAST) { // Specific handling for variable declarations, return statement, and // print. These can only appear in block list and not in nested diff --git a/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp index 47e1abc6c74..604e9fa6c83 100644 --- a/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp @@ -53,7 +53,7 @@ struct SimplifyRedundantTranspose : public mlir::OpRewritePattern { matchAndRewrite(TransposeOp op, mlir::PatternRewriter &rewriter) const override { // Look through the input of the current transpose. - mlir::Value *transposeInput = op.getOperand(); + mlir::ValuePtr transposeInput = op.getOperand(); TransposeOp transposeInputOp = llvm::dyn_cast_or_null(transposeInput->getDefiningOp()); diff --git a/mlir/examples/toy/Ch7/include/toy/Ops.td b/mlir/examples/toy/Ch7/include/toy/Ops.td index 0d48f74e9fe..94f1bcf3e82 100644 --- a/mlir/examples/toy/Ch7/include/toy/Ops.td +++ b/mlir/examples/toy/Ch7/include/toy/Ops.td @@ -112,7 +112,7 @@ def AddOp : Toy_Op<"add", // Allow building an AddOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *lhs, Value *rhs"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr lhs, ValuePtr rhs"> ]; } @@ -164,7 +164,7 @@ def GenericCallOp : Toy_Op<"generic_call", // Add custom build methods for the generic call operation. let builders = [ OpBuilder<"Builder *builder, OperationState &state, " - "StringRef callee, ArrayRef arguments"> + "StringRef callee, ArrayRef arguments"> ]; } @@ -181,7 +181,7 @@ def MulOp : Toy_Op<"mul", // Allow building a MulOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *lhs, Value *rhs"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr lhs, ValuePtr rhs"> ]; } @@ -260,7 +260,7 @@ def StructAccessOp : Toy_Op<"struct_access", [NoSideEffect]> { // Allow building a StructAccessOp with just a struct value and an index. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *input, size_t index"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr input, size_t index"> ]; let verifier = [{ return ::verify(*this); }]; @@ -299,7 +299,7 @@ def TransposeOp : Toy_Op<"transpose", // Allow building a TransposeOp with from the input operand. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value *input"> + OpBuilder<"Builder *b, OperationState &state, ValuePtr input"> ]; // Invoke a static verify method to verify this transpose operation. diff --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp index 2beaa870a89..0ce896db5de 100644 --- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp @@ -56,7 +56,7 @@ struct ToyInlinerInterface : public DialectInlinerInterface { /// Handle the given inlined terminator(toy.return) by replacing it with a new /// operation as necessary. void handleTerminator(Operation *op, - ArrayRef valuesToRepl) const final { + ArrayRef valuesToRepl) const final { // Only "toy.return" needs to be handled here. auto returnOp = cast(op); @@ -71,7 +71,7 @@ struct ToyInlinerInterface : public DialectInlinerInterface { /// operation that takes 'input' as the only operand, and produces a single /// result of 'resultType'. If a conversion can not be generated, nullptr /// should be returned. - Operation *materializeCallConversion(OpBuilder &builder, Value *input, + Operation *materializeCallConversion(OpBuilder &builder, ValuePtr input, Type resultType, Location conversionLoc) const final { return builder.create(conversionLoc, resultType, input); @@ -195,7 +195,7 @@ void ConstantOp::inferShapes() { getResult()->setType(value().getType()); } // AddOp void AddOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *lhs, mlir::Value *rhs) { + mlir::ValuePtr lhs, mlir::ValuePtr rhs) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -215,7 +215,8 @@ void CastOp::inferShapes() { getResult()->setType(getOperand()->getType()); } // GenericCallOp void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state, - StringRef callee, ArrayRef arguments) { + StringRef callee, + ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(arguments); @@ -236,7 +237,7 @@ Operation::operand_range GenericCallOp::getArgOperands() { return inputs(); } // MulOp void MulOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *lhs, mlir::Value *rhs) { + mlir::ValuePtr lhs, mlir::ValuePtr rhs) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands({lhs, rhs}); } @@ -287,7 +288,7 @@ static mlir::LogicalResult verify(ReturnOp op) { // StructAccessOp void StructAccessOp::build(mlir::Builder *b, mlir::OperationState &state, - mlir::Value *input, size_t index) { + mlir::ValuePtr input, size_t index) { // Extract the result type from the input type. StructType structTy = input->getType().cast(); assert(index < structTy.getNumElementTypes()); @@ -314,7 +315,7 @@ static mlir::LogicalResult verify(StructAccessOp op) { // TransposeOp void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state, - mlir::Value *value) { + mlir::ValuePtr value) { state.addTypes(UnrankedTensorType::get(builder->getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp index 4ab8c5b501c..3fa761c7404 100644 --- a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp @@ -43,8 +43,8 @@ static MemRefType convertTensorToMemRef(TensorType type) { } /// Insert an allocation and deallocation for the given MemRefType. -static Value *insertAllocAndDealloc(MemRefType type, Location loc, - PatternRewriter &rewriter) { +static ValuePtr insertAllocAndDealloc(MemRefType type, Location loc, + PatternRewriter &rewriter) { auto alloc = rewriter.create(loc, type); // Make sure to allocate at the beginning of the block. @@ -63,11 +63,11 @@ static Value *insertAllocAndDealloc(MemRefType type, Location loc, /// to the operands of the input operation, and the set of loop induction /// variables for the iteration. It returns a value to store at the current /// index of the iteration. -using LoopIterationFn = function_ref memRefOperands, - ArrayRef loopIvs)>; +using LoopIterationFn = function_ref memRefOperands, + ArrayRef loopIvs)>; -static void lowerOpToLoops(Operation *op, ArrayRef operands, +static void lowerOpToLoops(Operation *op, ArrayRef operands, PatternRewriter &rewriter, LoopIterationFn processIteration) { auto tensorType = (*op->result_type_begin()).cast(); @@ -78,7 +78,7 @@ static void lowerOpToLoops(Operation *op, ArrayRef operands, auto alloc = insertAllocAndDealloc(memRefType, loc, rewriter); // Create an empty affine loop for each of the dimensions within the shape. - SmallVector loopIvs; + SmallVector loopIvs; for (auto dim : tensorType.getShape()) { auto loop = rewriter.create(loc, /*lb=*/0, dim, /*step=*/1); loop.getBody()->clear(); @@ -94,7 +94,7 @@ static void lowerOpToLoops(Operation *op, ArrayRef operands, // Generate a call to the processing function with the rewriter, the memref // operands, and the loop induction variables. This function will return the // value to store at the current index. - Value *valueToStore = processIteration(rewriter, operands, loopIvs); + ValuePtr valueToStore = processIteration(rewriter, operands, loopIvs); rewriter.create(loc, valueToStore, alloc, llvm::makeArrayRef(loopIvs)); @@ -113,13 +113,13 @@ struct BinaryOpLowering : public ConversionPattern { : ConversionPattern(BinaryOp::getOperationName(), 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { auto loc = op->getLoc(); lowerOpToLoops( op, operands, rewriter, - [loc](PatternRewriter &rewriter, ArrayRef memRefOperands, - ArrayRef loopIvs) { + [loc](PatternRewriter &rewriter, ArrayRef memRefOperands, + ArrayRef loopIvs) { // Generate an adaptor for the remapped operands of the BinaryOp. This // allows for using the nice named accessors that are generated by the // ODS. @@ -163,7 +163,7 @@ struct ConstantOpLowering : public OpRewritePattern { // Create these constants up-front to avoid large amounts of redundant // operations. auto valueShape = memRefType.getShape(); - SmallVector constantIndices; + SmallVector constantIndices; for (auto i : llvm::seq( 0, *std::max_element(valueShape.begin(), valueShape.end()))) constantIndices.push_back(rewriter.create(loc, i)); @@ -172,7 +172,7 @@ struct ConstantOpLowering : public OpRewritePattern { // will need to generate a store for each of the elements. The following // functor recursively walks the dimensions of the constant shape, // generating a store when the recursion hits the base case. - SmallVector indices; + SmallVector indices; auto valueIt = constantValue.getValues().begin(); std::function storeElements = [&](uint64_t dimension) { // The last dimension is the base case of the recursion, at this point @@ -231,22 +231,22 @@ struct TransposeOpLowering : public ConversionPattern { : ConversionPattern(toy::TransposeOp::getOperationName(), 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { auto loc = op->getLoc(); lowerOpToLoops( op, operands, rewriter, - [loc](PatternRewriter &rewriter, ArrayRef memRefOperands, - ArrayRef loopIvs) { + [loc](PatternRewriter &rewriter, ArrayRef memRefOperands, + ArrayRef loopIvs) { // Generate an adaptor for the remapped operands of the TransposeOp. // This allows for using the nice named accessors that are generated // by the ODS. toy::TransposeOpOperandAdaptor transposeAdaptor(memRefOperands); - Value *input = transposeAdaptor.input(); + ValuePtr input = transposeAdaptor.input(); // Transpose the elements by generating a load from the reverse // indices. - SmallVector reverseIvs(llvm::reverse(loopIvs)); + SmallVector reverseIvs(llvm::reverse(loopIvs)); return rewriter.create(loc, input, reverseIvs); }); return matchSuccess(); diff --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp index d35cc5c576a..c3180b4a92d 100644 --- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp @@ -51,7 +51,7 @@ public: : ConversionPattern(toy::PrintOp::getOperationName(), 1, context) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto memRefType = (*op->operand_type_begin()).cast(); auto memRefShape = memRefType.getShape(); @@ -64,14 +64,14 @@ public: // Get a symbol reference to the printf function, inserting it if necessary. auto printfRef = getOrInsertPrintf(rewriter, parentModule, llvmDialect); - Value *formatSpecifierCst = getOrCreateGlobalString( + ValuePtr formatSpecifierCst = getOrCreateGlobalString( loc, rewriter, "frmt_spec", StringRef("%f \0", 4), parentModule, llvmDialect); - Value *newLineCst = getOrCreateGlobalString( + ValuePtr newLineCst = getOrCreateGlobalString( loc, rewriter, "nl", StringRef("\n\0", 2), parentModule, llvmDialect); // Create a loop for each of the dimensions within the shape. - SmallVector loopIvs; + SmallVector loopIvs; for (unsigned i = 0, e = memRefShape.size(); i != e; ++i) { auto lowerBound = rewriter.create(loc, 0); auto upperBound = rewriter.create(loc, memRefShape[i]); @@ -97,7 +97,7 @@ public: auto elementLoad = rewriter.create(loc, printOp.input(), loopIvs); rewriter.create( loc, printfRef, rewriter.getIntegerType(32), - ArrayRef({formatSpecifierCst, elementLoad})); + ArrayRef({formatSpecifierCst, elementLoad})); // Notify the rewriter that this operation has been removed. rewriter.eraseOp(op); @@ -130,10 +130,10 @@ private: /// Return a value representing an access into a global string with the given /// name, creating the string if necessary. - static Value *getOrCreateGlobalString(Location loc, OpBuilder &builder, - StringRef name, StringRef value, - ModuleOp module, - LLVM::LLVMDialect *llvmDialect) { + static ValuePtr getOrCreateGlobalString(Location loc, OpBuilder &builder, + StringRef name, StringRef value, + ModuleOp module, + LLVM::LLVMDialect *llvmDialect) { // Create the global at the entry of the module. LLVM::GlobalOp global; if (!(global = module.lookupSymbol(name))) { @@ -147,13 +147,13 @@ private: } // Get the pointer to the first character in the global string. - Value *globalPtr = builder.create(loc, global); - Value *cst0 = builder.create( + ValuePtr globalPtr = builder.create(loc, global); + ValuePtr cst0 = builder.create( loc, LLVM::LLVMType::getInt64Ty(llvmDialect), builder.getIntegerAttr(builder.getIndexType(), 0)); return builder.create( loc, LLVM::LLVMType::getInt8PtrTy(llvmDialect), globalPtr, - ArrayRef({cst0, cst0})); + ArrayRef({cst0, cst0})); } }; } // end anonymous namespace diff --git a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp index b33137a1066..590b21e53a1 100644 --- a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp @@ -108,11 +108,11 @@ private: /// Entering a function creates a new scope, and the function arguments are /// added to the mapping. When the processing of a function is terminated, the /// scope is destroyed and the mappings created in this scope are dropped. - llvm::ScopedHashTable> + llvm::ScopedHashTable> symbolTable; using SymbolTableScopeT = llvm::ScopedHashTableScope>; + std::pair>; /// A mapping for the functions that have been code generated to MLIR. llvm::StringMap functionMap; @@ -129,7 +129,7 @@ private: /// Declare a variable in the current scope, return success if the variable /// wasn't declared yet. - mlir::LogicalResult declare(VarDeclExprAST &var, mlir::Value *value) { + mlir::LogicalResult declare(VarDeclExprAST &var, mlir::ValuePtr value) { if (symbolTable.count(var.getName())) return mlir::failure(); symbolTable.insert(var.getName(), {value, &var}); @@ -301,7 +301,7 @@ private: } /// Emit a binary operation - mlir::Value *mlirGen(BinaryExprAST &binop) { + mlir::ValuePtr mlirGen(BinaryExprAST &binop) { // First emit the operations for each side of the operation before emitting // the operation itself. For example if the expression is `a + foo(a)` // 1) First it will visiting the LHS, which will return a reference to the @@ -313,7 +313,7 @@ private: // and the result value is returned. If an error occurs we get a nullptr // and propagate. // - mlir::Value *lhs = mlirGen(*binop.getLHS()); + mlir::ValuePtr lhs = mlirGen(*binop.getLHS()); if (!lhs) return nullptr; auto location = loc(binop.loc()); @@ -329,7 +329,7 @@ private: } // Otherwise, this is a normal binary op. - mlir::Value *rhs = mlirGen(*binop.getRHS()); + mlir::ValuePtr rhs = mlirGen(*binop.getRHS()); if (!rhs) return nullptr; @@ -349,8 +349,8 @@ private: /// This is a reference to a variable in an expression. The variable is /// expected to have been declared and so should have a value in the symbol /// table, otherwise emit an error and return nullptr. - mlir::Value *mlirGen(VariableExprAST &expr) { - if (auto *variable = symbolTable.lookup(expr.getName()).first) + mlir::ValuePtr mlirGen(VariableExprAST &expr) { + if (auto variable = symbolTable.lookup(expr.getName()).first) return variable; emitError(loc(expr.loc()), "error: unknown variable '") @@ -363,7 +363,7 @@ private: auto location = loc(ret.loc()); // 'return' takes an optional expression, handle that case here. - mlir::Value *expr = nullptr; + mlir::ValuePtr expr = nullptr; if (ret.getExpr().hasValue()) { if (!(expr = mlirGen(*ret.getExpr().getValue()))) return mlir::failure(); @@ -371,7 +371,7 @@ private: // Otherwise, this return operation has zero operands. builder.create(location, expr ? makeArrayRef(expr) - : ArrayRef()); + : ArrayRef()); return mlir::success(); } @@ -450,7 +450,7 @@ private: } /// Emit an array literal. - mlir::Value *mlirGen(LiteralExprAST &lit) { + mlir::ValuePtr mlirGen(LiteralExprAST &lit) { mlir::Type type = getType(lit.getDims()); mlir::DenseElementsAttr dataAttribute = getConstantAttr(lit); @@ -462,7 +462,7 @@ private: /// Emit a struct literal. It will be emitted as an array of /// other literals in an Attribute attached to a `toy.struct_constant` /// operation. - mlir::Value *mlirGen(StructLiteralExprAST &lit) { + mlir::ValuePtr mlirGen(StructLiteralExprAST &lit) { mlir::ArrayAttr dataAttr; mlir::Type dataType; std::tie(dataAttr, dataType) = getConstantAttr(lit); @@ -493,14 +493,14 @@ private: /// Emit a call expression. It emits specific operations for the `transpose` /// builtin. Other identifiers are assumed to be user-defined functions. - mlir::Value *mlirGen(CallExprAST &call) { + mlir::ValuePtr mlirGen(CallExprAST &call) { llvm::StringRef callee = call.getCallee(); auto location = loc(call.loc()); // Codegen the operands first. - SmallVector operands; + SmallVector operands; for (auto &expr : call.getArgs()) { - auto *arg = mlirGen(*expr); + auto arg = mlirGen(*expr); if (!arg) return nullptr; operands.push_back(arg); @@ -534,7 +534,7 @@ private: /// Emit a print expression. It emits specific operations for two builtins: /// transpose(x) and print(x). mlir::LogicalResult mlirGen(PrintExprAST &call) { - auto *arg = mlirGen(*call.getArg()); + auto arg = mlirGen(*call.getArg()); if (!arg) return mlir::failure(); @@ -543,12 +543,12 @@ private: } /// Emit a constant for a single number (FIXME: semantic? broadcast?) - mlir::Value *mlirGen(NumberExprAST &num) { + mlir::ValuePtr mlirGen(NumberExprAST &num) { return builder.create(loc(num.loc()), num.getValue()); } /// Dispatch codegen for the right expression subclass using RTTI. - mlir::Value *mlirGen(ExprAST &expr) { + mlir::ValuePtr mlirGen(ExprAST &expr) { switch (expr.getKind()) { case toy::ExprAST::Expr_BinOp: return mlirGen(cast(expr)); @@ -574,7 +574,7 @@ private: /// initializer and record the value in the symbol table before returning it. /// Future expressions will be able to reference this variable through symbol /// table lookup. - mlir::Value *mlirGen(VarDeclExprAST &vardecl) { + mlir::ValuePtr mlirGen(VarDeclExprAST &vardecl) { auto init = vardecl.getInitVal(); if (!init) { emitError(loc(vardecl.loc()), @@ -582,7 +582,7 @@ private: return nullptr; } - mlir::Value *value = mlirGen(*init); + mlir::ValuePtr value = mlirGen(*init); if (!value) return nullptr; diff --git a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp index ebd4f5d1103..d18396c63bb 100644 --- a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp @@ -71,7 +71,7 @@ struct SimplifyRedundantTranspose : public mlir::OpRewritePattern { matchAndRewrite(TransposeOp op, mlir::PatternRewriter &rewriter) const override { // Look through the input of the current transpose. - mlir::Value *transposeInput = op.getOperand(); + mlir::ValuePtr transposeInput = op.getOperand(); TransposeOp transposeInputOp = llvm::dyn_cast_or_null(transposeInput->getDefiningOp()); diff --git a/mlir/g3doc/DeclarativeRewrites.md b/mlir/g3doc/DeclarativeRewrites.md index 5adcb320983..9fcd4341611 100644 --- a/mlir/g3doc/DeclarativeRewrites.md +++ b/mlir/g3doc/DeclarativeRewrites.md @@ -233,7 +233,7 @@ In the above, we are using `BOp`'s result for building `COp`. Given that `COp` was specified with table-driven op definition, there will be several `build()` methods generated for it. One of them has aggregated parameters for result types, operands, and attributes in the signature: `void -COp::build(..., ArrayRef resultTypes, Array operands, +COp::build(..., ArrayRef resultTypes, Array operands, ArrayRef attr)`. The pattern in the above calls this `build()` method for constructing the `COp`. @@ -266,7 +266,7 @@ For example, for the above `AOp`, a possible builder is: ```c++ void AOp::build(Builder *builder, OperationState &state, - Value *input, Attribute attr) { + ValuePtr input, Attribute attr) { state.addOperands({input}); state.addAttribute("a_attr", attr); Type type = ...; // Deduce result type here @@ -422,7 +422,7 @@ op; it can be also used to specify how to build an op entirely. An example: If we have a C++ function for building an op: ```c++ -Operation *createMyOp(OpBuilder builder, Value *input, Attribute attr); +Operation *createMyOp(OpBuilder builder, ValuePtr input, Attribute attr); ``` We can wrap it up and invoke it like: diff --git a/mlir/g3doc/DialectConversion.md b/mlir/g3doc/DialectConversion.md index b4e309daf1f..6771860366c 100644 --- a/mlir/g3doc/DialectConversion.md +++ b/mlir/g3doc/DialectConversion.md @@ -209,7 +209,7 @@ class TypeConverter { /// the conversion has finished. virtual Operation *materializeConversion(PatternRewriter &rewriter, Type resultType, - ArrayRef inputs, + ArrayRef inputs, Location loc); }; ``` @@ -232,7 +232,7 @@ struct MyConversionPattern : public ConversionPattern { /// `operands` parameter, containing the remapped operands of the original /// operation. virtual PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const; }; ``` @@ -269,7 +269,7 @@ public: /// Remap an input of the original signature to another `replacement` /// value. This drops the original argument. - void remapInput(unsigned origInputNo, Value *replacement); + void remapInput(unsigned origInputNo, ValuePtr replacement); }; ``` diff --git a/mlir/g3doc/EDSC.md b/mlir/g3doc/EDSC.md index afceac2dfc1..eaaeb6c7009 100644 --- a/mlir/g3doc/EDSC.md +++ b/mlir/g3doc/EDSC.md @@ -15,10 +15,10 @@ declarative builders are available within the lifetime of a `ScopedContext`. ## ValueHandle and IndexHandle `mlir::edsc::ValueHandle` and `mlir::edsc::IndexHandle` provide typed -abstractions around an `mlir::Value*`. These abstractions are "delayed", in the -sense that they allow separating declaration from definition. They may -capture IR snippets, as they are built, for programmatic manipulation. -Intuitive operators are provided to allow concise and idiomatic expressions. +abstractions around an `mlir::Value`. These abstractions are "delayed", in the +sense that they allow separating declaration from definition. They may capture +IR snippets, as they are built, for programmatic manipulation. Intuitive +operators are provided to allow concise and idiomatic expressions. ```c++ ValueHandle zero = constant_index(0); diff --git a/mlir/g3doc/GenericDAGRewriter.md b/mlir/g3doc/GenericDAGRewriter.md index 3b26c22eb37..64b8f4f7ade 100644 --- a/mlir/g3doc/GenericDAGRewriter.md +++ b/mlir/g3doc/GenericDAGRewriter.md @@ -128,7 +128,7 @@ complicated :) if (match(LHS, m_Xor(m_Value(Y), m_APInt(C1)))) if (C1->countTrailingZeros() == 0) if (match(Y, m_And(m_Value(Z), m_APInt(C2))) && *C1 == (*C2 + 1)) { - Value *NewOr = Builder.CreateOr(Z, ~(*C2)); + ValuePtr NewOr = Builder.CreateOr(Z, ~(*C2)); return Builder.CreateSub(RHS, NewOr, "sub"); } ``` diff --git a/mlir/g3doc/OpDefinitions.md b/mlir/g3doc/OpDefinitions.md index 1f98671d59a..1db18266ee0 100644 --- a/mlir/g3doc/OpDefinitions.md +++ b/mlir/g3doc/OpDefinitions.md @@ -360,7 +360,7 @@ def MyInterface : OpInterface<"MyInterface"> { // A new non-static method accepting an input argument. InterfaceMethod<"/*insert doc here*/", - "Value *", "bar", (ins "unsigned":$i) + "ValuePtr ", "bar", (ins "unsigned":$i) >, // Query a static property of the derived operation. @@ -438,7 +438,7 @@ static void build(Builder *tblgen_builder, OperationState &tblgen_state, // for attributes are of mlir::Attribute types. static void build(Builder *tblgen_builder, OperationState &tblgen_state, Type i32_result, Type f32_result, ..., - Value *i32_operand, Value *f32_operand, ..., + ValuePtr i32_operand, ValuePtr f32_operand, ..., IntegerAttr i32_attr, FloatAttr f32_attr, ...); // Each result-type/operand/attribute has a separate parameter. The parameters @@ -447,13 +447,13 @@ static void build(Builder *tblgen_builder, OperationState &tblgen_state, // explanation for more details.) static void build(Builder *tblgen_builder, OperationState &tblgen_state, Type i32_result, Type f32_result, ..., - Value *i32_operand, Value *f32_operand, ..., + ValuePtr i32_operand, ValuePtr f32_operand, ..., APInt i32_attr, StringRef f32_attr, ...); // Each operand/attribute has a separate parameter but result type is aggregate. static void build(Builder *tblgen_builder, OperationState &tblgen_state, ArrayRef resultTypes, - Value *i32_operand, Value *f32_operand, ..., + ValuePtr i32_operand, ValuePtr f32_operand, ..., IntegerAttr i32_attr, FloatAttr f32_attr, ...); // All operands/attributes have aggregate parameters. @@ -615,7 +615,7 @@ coding style requirements. For each operation, we automatically generate an _operand adaptor_. This class solves the problem of accessing operands provided as a list of `Value`s without using "magic" constants. The operand adaptor takes a reference to an array of -`Value *` and provides methods with the same names as those in the operation +`ValuePtr` and provides methods with the same names as those in the operation class to access them. For example, for a binary arithmetic operation, it may provide `.lhs()` to access the first operand and `.rhs()` to access the second operand. @@ -629,11 +629,11 @@ Operand adaptors can be used in function templates that also process operations: ```c++ template -std::pair zip(BinaryOpTy &&op) { +std::pair zip(BinaryOpTy &&op) { return std::make_pair(op.lhs(), op.rhs());; } -void process(AddOp op, ArrayRef newOperands) { +void process(AddOp op, ArrayRef newOperands) { zip(op); zip(OperandAdaptor(newOperands)); /*...*/ diff --git a/mlir/g3doc/QuickstartRewrites.md b/mlir/g3doc/QuickstartRewrites.md index d7bf9a54370..6a4a7cca8b8 100644 --- a/mlir/g3doc/QuickstartRewrites.md +++ b/mlir/g3doc/QuickstartRewrites.md @@ -128,8 +128,8 @@ def : Pat<(TF_LeakyReluOp:$old_value, $arg, F32Attr:$a), ``` ```c++ -static Value* createTFLLeakyRelu(PatternRewriter &rewriter, Operation *op, - Value* operand, Attribute attr) { +static Value createTFLLeakyRelu(PatternRewriter &rewriter, Operation *op, + Value operand, Attribute attr) { return rewriter.create( op->getLoc(), operands[0]->getType(), /*arg=*/operands[0], /*alpha=*/attrs[0].cast()); diff --git a/mlir/g3doc/Rationale.md b/mlir/g3doc/Rationale.md index 66cf800621d..763442dce06 100644 --- a/mlir/g3doc/Rationale.md +++ b/mlir/g3doc/Rationale.md @@ -1099,7 +1099,7 @@ those chunks independently. The problem is that LLVM has several objects in its IR that are globally uniqued and also mutable: notably constants like `i32 0`. In LLVM, these constants are -`Value*r`'s, which allow them to be used as operands to instructions, and that +`Value`'s, which allow them to be used as operands to instructions, and that they also have SSA use lists. Because these things are uniqued, every `i32 0` in any function shares a use list. This means that optimizing multiple functions in parallel won't work (at least without some sort of synchronization on the use diff --git a/mlir/g3doc/Tutorials/Toy/Ch-3.md b/mlir/g3doc/Tutorials/Toy/Ch-3.md index 07ead64d455..fb470434d6f 100644 --- a/mlir/g3doc/Tutorials/Toy/Ch-3.md +++ b/mlir/g3doc/Tutorials/Toy/Ch-3.md @@ -90,7 +90,7 @@ struct SimplifyRedundantTranspose : public mlir::OpRewritePattern { matchAndRewrite(TransposeOp op, mlir::PatternRewriter &rewriter) const override { // Look through the input of the current transpose. - mlir::Value *transposeInput = op.getOperand(); + mlir::ValuePtr transposeInput = op.getOperand(); TransposeOp transposeInputOp = llvm::dyn_cast_or_null(transposeInput->getDefiningOp()); // If the input is defined by another Transpose, bingo! diff --git a/mlir/g3doc/Tutorials/Toy/Ch-4.md b/mlir/g3doc/Tutorials/Toy/Ch-4.md index ac124699c2f..921e5cdc52a 100644 --- a/mlir/g3doc/Tutorials/Toy/Ch-4.md +++ b/mlir/g3doc/Tutorials/Toy/Ch-4.md @@ -75,7 +75,7 @@ struct ToyInlinerInterface : public DialectInlinerInterface { /// previously returned by the call operation with the operands of the /// return. void handleTerminator(Operation *op, - ArrayRef valuesToRepl) const final { + ArrayRef valuesToRepl) const final { // Only "toy.return" needs to be handled here. auto returnOp = cast(op); @@ -207,7 +207,7 @@ struct ToyInlinerInterface : public DialectInlinerInterface { /// operation that takes 'input' as the only operand, and produces a single /// result of 'resultType'. If a conversion can not be generated, nullptr /// should be returned. - Operation *materializeCallConversion(OpBuilder &builder, Value *input, + Operation *materializeCallConversion(OpBuilder &builder, ValuePtr input, Type resultType, Location conversionLoc) const final { return builder.create(conversionLoc, resultType, input); diff --git a/mlir/g3doc/Tutorials/Toy/Ch-5.md b/mlir/g3doc/Tutorials/Toy/Ch-5.md index 1124cf14a43..ed62f8954b7 100644 --- a/mlir/g3doc/Tutorials/Toy/Ch-5.md +++ b/mlir/g3doc/Tutorials/Toy/Ch-5.md @@ -101,7 +101,7 @@ struct TransposeOpLowering : public mlir::ConversionPattern { /// Match and rewrite the given `toy.transpose` operation, with the given /// operands that have been remapped from `tensor<...>` to `memref<...>`. mlir::PatternMatchResult - matchAndRewrite(mlir::Operation *op, ArrayRef operands, + matchAndRewrite(mlir::Operation *op, ArrayRef operands, mlir::ConversionPatternRewriter &rewriter) const final { auto loc = op->getLoc(); @@ -112,18 +112,18 @@ struct TransposeOpLowering : public mlir::ConversionPattern { lowerOpToLoops( op, operands, rewriter, [loc](mlir::PatternRewriter &rewriter, - ArrayRef memRefOperands, - ArrayRef loopIvs) { + ArrayRef memRefOperands, + ArrayRef loopIvs) { // Generate an adaptor for the remapped operands of the TransposeOp. // This allows for using the nice named accessors that are generated // by the ODS. This adaptor is automatically provided by the ODS // framework. TransposeOpOperandAdaptor transposeAdaptor(memRefOperands); - mlir::Value *input = transposeAdaptor.input(); + mlir::ValuePtr input = transposeAdaptor.input(); // Transpose the elements by generating a load from the reverse // indices. - SmallVector reverseIvs(llvm::reverse(loopIvs)); + SmallVector reverseIvs(llvm::reverse(loopIvs)); return rewriter.create(loc, input, reverseIvs); }); return matchSuccess(); diff --git a/mlir/g3doc/UsageOfConst.md b/mlir/g3doc/UsageOfConst.md index 052f14ddf01..5f6d3793164 100644 --- a/mlir/g3doc/UsageOfConst.md +++ b/mlir/g3doc/UsageOfConst.md @@ -10,7 +10,7 @@ understood (even though the LLVM implementation is flawed in many ways). The design team since decided to change to a different module, which eschews `const` entirely for the core IR types: you should never see a `const` method on -`Operation`, should never see the type `const Value *`, and you shouldn't feel +`Operation`, should never see the type `const ValuePtr`, and you shouldn't feel bad about this. That said, you *should* use `const` for non-IR types, like `SmallVector`'s and many other things. @@ -39,7 +39,7 @@ into the MLIR codebase, argues that the cost/benefit tradeoff of this design is a poor tradeoff, and proposes switching to a much simpler approach - eliminating the use of const of these IR types entirely. -**Note:** **This document is only discussing things like `const Value*` and +**Note:** **This document is only discussing things like `const Value` and `const Operation*`. There is no proposed change for other types, e.g. `SmallVector` references, the immutable types like `Attribute`, etc.** @@ -130,7 +130,7 @@ const. operand_iterator operand_begin(); operand_iterator operand_end(); - /// Returns an iterator on the underlying Value's (Value *). + /// Returns an iterator on the underlying Value's (ValuePtr ). operand_range getOperands(); // Support const operand iteration. @@ -141,7 +141,7 @@ const. const_operand_iterator operand_begin() const; const_operand_iterator operand_end() const; - /// Returns a const iterator on the underlying Value's (Value *). + /// Returns a const iterator on the underlying Value's (ValuePtr ). llvm::iterator_range getOperands() const; ArrayRef getOpOperands() const { diff --git a/mlir/include/mlir/Analysis/AffineAnalysis.h b/mlir/include/mlir/Analysis/AffineAnalysis.h index 8243d1f6f63..f506470f36a 100644 --- a/mlir/include/mlir/Analysis/AffineAnalysis.h +++ b/mlir/include/mlir/Analysis/AffineAnalysis.h @@ -39,10 +39,13 @@ class FlatAffineConstraints; class Operation; class Value; +// TODO(riverriddle) Remove this after Value is value-typed. +using ValuePtr = Value *; + /// Returns in `affineApplyOps`, the sequence of those AffineApplyOp /// Operations that are reachable via a search starting from `operands` and /// ending at those operands that are not the result of an AffineApplyOp. -void getReachableAffineApplyOps(ArrayRef operands, +void getReachableAffineApplyOps(ArrayRef operands, SmallVectorImpl &affineApplyOps); /// Builds a system of constraints with dimensional identifiers corresponding to @@ -56,9 +59,9 @@ LogicalResult getIndexSet(MutableArrayRef forOps, /// Encapsulates a memref load or store access information. struct MemRefAccess { - Value *memref; + ValuePtr memref; Operation *opInst; - SmallVector indices; + SmallVector indices; /// Constructs a MemRefAccess from a load or store operation. // TODO(b/119949820): add accessors to standard op's load, store, DMA op's to diff --git a/mlir/include/mlir/Analysis/AffineStructures.h b/mlir/include/mlir/Analysis/AffineStructures.h index e53af5024da..65cf13a0ce6 100644 --- a/mlir/include/mlir/Analysis/AffineStructures.h +++ b/mlir/include/mlir/Analysis/AffineStructures.h @@ -123,8 +123,8 @@ public: // Creates an empty AffineValueMap (users should call 'reset' to reset map // and operands). AffineValueMap() {} - AffineValueMap(AffineMap map, ArrayRef operands, - ArrayRef results = llvm::None); + AffineValueMap(AffineMap map, ArrayRef operands, + ArrayRef results = llvm::None); explicit AffineValueMap(AffineApplyOp applyOp); explicit AffineValueMap(AffineBound bound); @@ -132,8 +132,8 @@ public: ~AffineValueMap(); // Resets this AffineValueMap with 'map', 'operands', and 'results'. - void reset(AffineMap map, ArrayRef operands, - ArrayRef results = llvm::None); + void reset(AffineMap map, ArrayRef operands, + ArrayRef results = llvm::None); /// Return the value map that is the difference of value maps 'a' and 'b', /// represented as an affine map and its operands. The output map + operands @@ -146,7 +146,7 @@ public: inline bool isMultipleOf(unsigned idx, int64_t factor) const; /// Return true if the idx^th result depends on 'value', false otherwise. - bool isFunctionOf(unsigned idx, Value *value) const; + bool isFunctionOf(unsigned idx, ValuePtr value) const; /// Return true if the result at 'idx' is a constant, false /// otherwise. @@ -162,8 +162,8 @@ public: inline unsigned getNumSymbols() const { return map.getNumSymbols(); } inline unsigned getNumResults() const { return map.getNumResults(); } - Value *getOperand(unsigned i) const; - ArrayRef getOperands() const; + ValuePtr getOperand(unsigned i) const; + ArrayRef getOperands() const; AffineMap getAffineMap() const; private: @@ -172,9 +172,9 @@ private: // TODO: make these trailing objects? /// The SSA operands binding to the dim's and symbols of 'map'. - SmallVector operands; + SmallVector operands; /// The SSA results binding to the results of 'map'. - SmallVector results; + SmallVector results; }; /// An IntegerValueSet is an integer set plus its operands. @@ -207,7 +207,7 @@ private: // 'AffineCondition'. MutableIntegerSet set; /// The SSA operands binding to the dim's and symbols of 'set'. - SmallVector operands; + SmallVector operands; }; /// A flat list of affine equalities and inequalities in the form. @@ -245,7 +245,7 @@ public: unsigned numReservedEqualities, unsigned numReservedCols, unsigned numDims = 0, unsigned numSymbols = 0, unsigned numLocals = 0, - ArrayRef> idArgs = {}) + ArrayRef> idArgs = {}) : numReservedCols(numReservedCols), numDims(numDims), numSymbols(numSymbols) { assert(numReservedCols >= numDims + numSymbols + 1); @@ -264,7 +264,7 @@ public: /// dimensions and symbols. FlatAffineConstraints(unsigned numDims = 0, unsigned numSymbols = 0, unsigned numLocals = 0, - ArrayRef> idArgs = {}) + ArrayRef> idArgs = {}) : numReservedCols(numDims + numSymbols + numLocals + 1), numDims(numDims), numSymbols(numSymbols) { assert(numReservedCols >= numDims + numSymbols + 1); @@ -304,10 +304,10 @@ public: // Clears any existing data and reserves memory for the specified constraints. void reset(unsigned numReservedInequalities, unsigned numReservedEqualities, unsigned numReservedCols, unsigned numDims, unsigned numSymbols, - unsigned numLocals = 0, ArrayRef idArgs = {}); + unsigned numLocals = 0, ArrayRef idArgs = {}); void reset(unsigned numDims = 0, unsigned numSymbols = 0, - unsigned numLocals = 0, ArrayRef idArgs = {}); + unsigned numLocals = 0, ArrayRef idArgs = {}); /// Appends constraints from 'other' into this. This is equivalent to an /// intersection with no simplification of any sort attempted. @@ -396,7 +396,7 @@ public: /// operands. If `eq` is true, add a single equality equal to the bound map's /// first result expr. LogicalResult addLowerOrUpperBound(unsigned pos, AffineMap boundMap, - ArrayRef operands, bool eq, + ArrayRef operands, bool eq, bool lower = true); /// Computes the lower and upper bounds of the first 'num' dimensional @@ -415,10 +415,10 @@ public: /// operand list 'operands'. /// This function assumes 'values.size' == 'lbMaps.size' == 'ubMaps.size'. /// Note that both lower/upper bounds use operands from 'operands'. - LogicalResult addSliceBounds(ArrayRef values, + LogicalResult addSliceBounds(ArrayRef values, ArrayRef lbMaps, ArrayRef ubMaps, - ArrayRef operands); + ArrayRef operands); // Adds an inequality (>= 0) from the coefficients specified in inEq. void addInequality(ArrayRef inEq); @@ -447,25 +447,25 @@ public: /// Sets the identifier corresponding to the specified Value id to a /// constant. Asserts if the 'id' is not found. - void setIdToConstant(Value &id, int64_t val); + void setIdToConstant(ValueRef id, int64_t val); /// Looks up the position of the identifier with the specified Value. Returns /// true if found (false otherwise). `pos' is set to the (column) position of /// the identifier. - bool findId(Value &id, unsigned *pos) const; + bool findId(ValueRef id, unsigned *pos) const; /// Returns true if an identifier with the specified Value exists, false /// otherwise. - bool containsId(Value &id) const; + bool containsId(ValueRef id) const; // Add identifiers of the specified kind - specified positions are relative to // the kind of identifier. The coefficient column corresponding to the added // identifier is initialized to zero. 'id' is the Value corresponding to the // identifier that can optionally be provided. - void addDimId(unsigned pos, Value *id = nullptr); - void addSymbolId(unsigned pos, Value *id = nullptr); + void addDimId(unsigned pos, ValuePtr id = nullptr); + void addSymbolId(unsigned pos, ValuePtr id = nullptr); void addLocalId(unsigned pos); - void addId(IdKind kind, unsigned pos, Value *id = nullptr); + void addId(IdKind kind, unsigned pos, ValuePtr id = nullptr); /// Add the specified values as a dim or symbol id depending on its nature, if /// it already doesn't exist in the system. `id' has to be either a terminal @@ -473,7 +473,7 @@ public: /// symbols or loop IVs. The identifier is added to the end of the existing /// dims or symbols. Additional information on the identifier is extracted /// from the IR and added to the constraint system. - void addInductionVarOrTerminalSymbol(Value *id); + void addInductionVarOrTerminalSymbol(ValuePtr id); /// Composes the affine value map with this FlatAffineConstrains, adding the /// results of the map as dimensions at the front [0, vMap->getNumResults()) @@ -500,8 +500,8 @@ public: void projectOut(unsigned pos, unsigned num); inline void projectOut(unsigned pos) { return projectOut(pos, 1); } - /// Projects out the identifier that is associate with Value *. - void projectOut(Value *id); + /// Projects out the identifier that is associate with ValuePtr . + void projectOut(ValuePtr id); void removeId(IdKind idKind, unsigned pos); void removeId(unsigned pos); @@ -577,20 +577,20 @@ public: return numIds - numDims - numSymbols; } - inline ArrayRef> getIds() const { + inline ArrayRef> getIds() const { return {ids.data(), ids.size()}; } - inline MutableArrayRef> getIds() { + inline MutableArrayRef> getIds() { return {ids.data(), ids.size()}; } /// Returns the optional Value corresponding to the pos^th identifier. - inline Optional getId(unsigned pos) const { return ids[pos]; } - inline Optional &getId(unsigned pos) { return ids[pos]; } + inline Optional getId(unsigned pos) const { return ids[pos]; } + inline Optional &getId(unsigned pos) { return ids[pos]; } /// Returns the Value associated with the pos^th identifier. Asserts if /// no Value identifier was associated. - inline Value *getIdValue(unsigned pos) const { + inline ValuePtr getIdValue(unsigned pos) const { assert(ids[pos].hasValue() && "identifier's Value not set"); return ids[pos].getValue(); } @@ -598,7 +598,7 @@ public: /// Returns the Values associated with identifiers in range [start, end). /// Asserts if no Value was associated with one of these identifiers. void getIdValues(unsigned start, unsigned end, - SmallVectorImpl *values) const { + SmallVectorImpl *values) const { assert((start < numIds || start == end) && "invalid start position"); assert(end <= numIds && "invalid end position"); values->clear(); @@ -607,17 +607,17 @@ public: values->push_back(getIdValue(i)); } } - inline void getAllIdValues(SmallVectorImpl *values) const { + inline void getAllIdValues(SmallVectorImpl *values) const { getIdValues(0, numIds, values); } /// Sets Value associated with the pos^th identifier. - inline void setIdValue(unsigned pos, Value *val) { + inline void setIdValue(unsigned pos, ValuePtr val) { assert(pos < numIds && "invalid id position"); ids[pos] = val; } /// Sets Values associated with identifiers in the range [start, end). - void setIdValues(unsigned start, unsigned end, ArrayRef values) { + void setIdValues(unsigned start, unsigned end, ArrayRef values) { assert((start < numIds || end == start) && "invalid start position"); assert(end <= numIds && "invalid end position"); assert(values.size() == end - start); @@ -766,7 +766,7 @@ private: /// system appearing in the order the identifiers correspond to columns. /// Temporary ones or those that aren't associated to any Value are set to /// None. - SmallVector, 8> ids; + SmallVector, 8> ids; /// A parameter that controls detection of an unrealistic number of /// constraints. If the number of constraints is this many times the number of diff --git a/mlir/include/mlir/Analysis/CallInterfaces.h b/mlir/include/mlir/Analysis/CallInterfaces.h index dd23d77889f..a18cfa7aba4 100644 --- a/mlir/include/mlir/Analysis/CallInterfaces.h +++ b/mlir/include/mlir/Analysis/CallInterfaces.h @@ -30,8 +30,8 @@ namespace mlir { /// A callable is either a symbol, or an SSA value, that is referenced by a /// call-like operation. This represents the destination of the call. -struct CallInterfaceCallable : public PointerUnion { - using PointerUnion::PointerUnion; +struct CallInterfaceCallable : public PointerUnion { + using PointerUnion::PointerUnion; }; #include "mlir/Analysis/CallInterfaces.h.inc" diff --git a/mlir/include/mlir/Analysis/Dominance.h b/mlir/include/mlir/Analysis/Dominance.h index 09114eafbb1..f46241e2af0 100644 --- a/mlir/include/mlir/Analysis/Dominance.h +++ b/mlir/include/mlir/Analysis/Dominance.h @@ -74,10 +74,10 @@ public: } /// Return true if value A properly dominates operation B. - bool properlyDominates(Value *a, Operation *b); + bool properlyDominates(ValuePtr a, Operation *b); /// Return true if operation A dominates operation B. - bool dominates(Value *a, Operation *b) { + bool dominates(ValuePtr a, Operation *b) { return (Operation *)a->getDefiningOp() == b || properlyDominates(a, b); } diff --git a/mlir/include/mlir/Analysis/Liveness.h b/mlir/include/mlir/Analysis/Liveness.h index 0bdb474fd92..0aa9d9693e4 100644 --- a/mlir/include/mlir/Analysis/Liveness.h +++ b/mlir/include/mlir/Analysis/Liveness.h @@ -41,6 +41,9 @@ class Operation; class Region; class Value; +// TODO(riverriddle) Remove this after Value is value-typed. +using ValuePtr = Value *; + /// Represents an analysis for computing liveness information from a /// given top-level operation. The analysis iterates over all associated /// regions that are attached to the given top-level operation. It @@ -57,7 +60,7 @@ class Liveness { public: using OperationListT = std::vector; using BlockMapT = DenseMap; - using ValueSetT = SmallPtrSet; + using ValueSetT = SmallPtrSet; public: /// Creates a new Liveness analysis that computes liveness @@ -72,7 +75,7 @@ public: /// Note that the operations in this list are not ordered and the current /// implementation is computationally expensive (as it iterates over all /// blocks in which the given value is live). - OperationListT resolveLiveness(Value *value) const; + OperationListT resolveLiveness(ValuePtr value) const; /// Gets liveness info (if any) for the block. const LivenessBlockInfo *getLiveness(Block *block) const; @@ -85,7 +88,7 @@ public: /// Returns true if the given operation represent the last use of the /// given value. - bool isLastUse(Value *value, Operation *operation) const; + bool isLastUse(ValuePtr value, Operation *operation) const; /// Dumps the liveness information in a human readable format. void dump() const; @@ -124,20 +127,20 @@ public: const ValueSetT &out() const { return outValues; } /// Returns true if the given value is in the live-in set. - bool isLiveIn(Value *value) const; + bool isLiveIn(ValuePtr value) const; /// Returns true if the given value is in the live-out set. - bool isLiveOut(Value *value) const; + bool isLiveOut(ValuePtr value) const; /// Gets the start operation for the given value. This is the first operation /// the given value is considered to be live. This could either be the start /// operation of the current block (in case the value is live-in) or the /// operation that defines the given value (must be referenced in this block). - Operation *getStartOperation(Value *value) const; + Operation *getStartOperation(ValuePtr value) const; /// Gets the end operation for the given value using the start operation /// provided (must be referenced in this block). - Operation *getEndOperation(Value *value, Operation *startOperation) const; + Operation *getEndOperation(ValuePtr value, Operation *startOperation) const; private: /// The underlying block. diff --git a/mlir/include/mlir/Analysis/LoopAnalysis.h b/mlir/include/mlir/Analysis/LoopAnalysis.h index 47cc22a4923..ad7dc6d6092 100644 --- a/mlir/include/mlir/Analysis/LoopAnalysis.h +++ b/mlir/include/mlir/Analysis/LoopAnalysis.h @@ -36,6 +36,9 @@ class NestedPattern; class Operation; class Value; +// TODO(riverriddle) Remove this after Value is value-typed. +using ValuePtr = Value *; + /// Returns the trip count of the loop as an affine map with its corresponding /// operands if the latter is expressible as an affine expression, and nullptr /// otherwise. This method always succeeds as long as the lower bound is not a @@ -45,7 +48,7 @@ class Value; // TODO(mlir-team): this should be moved into 'Transforms/' and be replaced by a // pure analysis method relying on FlatAffineConstraints void buildTripCountMapAndOperands(AffineForOp forOp, AffineMap *map, - SmallVectorImpl *operands); + SmallVectorImpl *operands); /// Returns the trip count of the loop if it's a constant, None otherwise. This /// uses affine expression analysis and is able to determine constant trip count @@ -66,8 +69,8 @@ uint64_t getLargestDivisorOfTripCount(AffineForOp forOp); /// /// Emits a note if it encounters a chain of affine.apply and conservatively /// those cases. -DenseSet> -getInvariantAccesses(Value *iv, ArrayRef indices); +DenseSet> +getInvariantAccesses(ValuePtr iv, ArrayRef indices); using VectorizableLoopFun = std::function; diff --git a/mlir/include/mlir/Analysis/Utils.h b/mlir/include/mlir/Analysis/Utils.h index cffa222154f..ea0987df3fe 100644 --- a/mlir/include/mlir/Analysis/Utils.h +++ b/mlir/include/mlir/Analysis/Utils.h @@ -55,7 +55,7 @@ unsigned getNestingDepth(Operation &op); /// Returns in 'sequentialLoops' all sequential loops in loop nest rooted /// at 'forOp'. void getSequentialLoops(AffineForOp forOp, - llvm::SmallDenseSet *sequentialLoops); + llvm::SmallDenseSet *sequentialLoops); /// ComputationSliceState aggregates loop IVs, loop bound AffineMaps and their /// associated operands for a set of loops within a loop nest (typically the @@ -64,15 +64,15 @@ void getSequentialLoops(AffineForOp forOp, struct ComputationSliceState { // List of sliced loop IVs (ordered from outermost to innermost). // EX: 'ivs[i]' has lower bound 'lbs[i]' and upper bound 'ubs[i]'. - SmallVector ivs; + SmallVector ivs; // List of lower bound AffineMaps. SmallVector lbs; // List of upper bound AffineMaps. SmallVector ubs; // List of lower bound operands (lbOperands[i] are used by 'lbs[i]'). - std::vector> lbOperands; + std::vector> lbOperands; // List of upper bound operands (ubOperands[i] are used by 'ubs[i]'). - std::vector> ubOperands; + std::vector> ubOperands; // Slice loop nest insertion point in target loop nest. Block::iterator insertPoint; // Adds to 'cst' with constraints which represent the slice bounds on 'ivs' @@ -257,7 +257,7 @@ struct MemRefRegion { unsigned getRank() const; /// Memref that this region corresponds to. - Value *memref; + ValuePtr memref; /// Read or write. bool write; diff --git a/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h b/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h index b5c51ad4b4c..4bbe6610e31 100644 --- a/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h +++ b/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h @@ -30,14 +30,17 @@ class OpBuilder; class RewritePattern; class Value; +// TODO(riverriddle) Remove this after Value is value-typed. +using ValuePtr = Value *; + // Owning list of rewriting patterns. class OwningRewritePatternList; /// Emit code that computes the given affine expression using standard /// arithmetic operations applied to the provided dimension and symbol values. -Value *expandAffineExpr(OpBuilder &builder, Location loc, AffineExpr expr, - ArrayRef dimValues, - ArrayRef symbolValues); +ValuePtr expandAffineExpr(OpBuilder &builder, Location loc, AffineExpr expr, + ArrayRef dimValues, + ArrayRef symbolValues); /// Collect a set of patterns to convert from the Affine dialect to the Standard /// dialect, in particular convert structured affine control flow into CFG @@ -47,11 +50,11 @@ void populateAffineToStdConversionPatterns(OwningRewritePatternList &patterns, /// Emit code that computes the lower bound of the given affine loop using /// standard arithmetic operations. -Value *lowerAffineLowerBound(AffineForOp op, OpBuilder &builder); +ValuePtr lowerAffineLowerBound(AffineForOp op, OpBuilder &builder); /// Emit code that computes the upper bound of the given affine loop using /// standard arithmetic operations. -Value *lowerAffineUpperBound(AffineForOp op, OpBuilder &builder); +ValuePtr lowerAffineUpperBound(AffineForOp op, OpBuilder &builder); } // namespace mlir #endif // MLIR_CONVERSION_AFFINETOSTANDARD_AFFINETOSTANDARD_H diff --git a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h index 0aab8723eab..58d49a13391 100644 --- a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h +++ b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h @@ -24,6 +24,9 @@ class AffineForOp; struct LogicalResult; class Value; +// TODO(riverriddle) Remove this after Value is value-typed. +using ValuePtr = Value *; + namespace loop { class ForOp; } // end namespace loop @@ -78,8 +81,8 @@ LogicalResult convertLoopNestToGPULaunch(loop::ForOp forOp, /// The above conditions are assumed to be satisfied by the computation rooted /// at `forOp`. LogicalResult convertLoopToGPULaunch(loop::ForOp forOp, - ArrayRef numWorkGroups, - ArrayRef workGroupSizes); + ArrayRef numWorkGroups, + ArrayRef workGroupSizes); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h index e8d16f064a8..6f41fb68633 100644 --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h @@ -74,16 +74,16 @@ public: /// Promote the LLVM struct representation of all MemRef descriptors to stack /// and use pointers to struct to avoid the complexity of the /// platform-specific C/C++ ABI lowering related to struct argument passing. - SmallVector promoteMemRefDescriptors(Location loc, - ValueRange opOperands, - ValueRange operands, - OpBuilder &builder); + SmallVector promoteMemRefDescriptors(Location loc, + ValueRange opOperands, + ValueRange operands, + OpBuilder &builder); /// Promote the LLVM struct representation of one MemRef descriptor to stack /// and use pointer to struct to avoid the complexity of the platform-specific /// C/C++ ABI lowering related to struct argument passing. - Value *promoteOneMemRefDescriptor(Location loc, Value *operand, - OpBuilder &builder); + ValuePtr promoteOneMemRefDescriptor(Location loc, ValuePtr operand, + OpBuilder &builder); protected: /// LLVM IR module used to parse/create types. @@ -139,24 +139,24 @@ private: class StructBuilder { public: /// Construct a helper for the given value. - explicit StructBuilder(Value *v); + explicit StructBuilder(ValuePtr v); /// Builds IR creating an `undef` value of the descriptor type. static StructBuilder undef(OpBuilder &builder, Location loc, Type descriptorType); - /*implicit*/ operator Value *() { return value; } + /*implicit*/ operator ValuePtr() { return value; } protected: // LLVM value - Value *value; + ValuePtr value; // Cached struct type. Type structType; protected: /// Builds IR to extract a value from the struct at position pos - Value *extractPtr(OpBuilder &builder, Location loc, unsigned pos); + ValuePtr extractPtr(OpBuilder &builder, Location loc, unsigned pos); /// Builds IR to set a value in the struct at position pos - void setPtr(OpBuilder &builder, Location loc, unsigned pos, Value *ptr); + void setPtr(OpBuilder &builder, Location loc, unsigned pos, ValuePtr ptr); }; /// Helper class to produce LLVM dialect operations extracting or inserting /// elements of a MemRef descriptor. Wraps a Value pointing to the descriptor. @@ -164,7 +164,7 @@ protected: class MemRefDescriptor : public StructBuilder { public: /// Construct a helper for the given descriptor value. - explicit MemRefDescriptor(Value *descriptor); + explicit MemRefDescriptor(ValuePtr descriptor); /// Builds IR creating an `undef` value of the descriptor type. static MemRefDescriptor undef(OpBuilder &builder, Location loc, Type descriptorType); @@ -173,39 +173,40 @@ public: /// type. static MemRefDescriptor fromStaticShape(OpBuilder &builder, Location loc, LLVMTypeConverter &typeConverter, - MemRefType type, Value *memory); + MemRefType type, ValuePtr memory); /// Builds IR extracting the allocated pointer from the descriptor. - Value *allocatedPtr(OpBuilder &builder, Location loc); + ValuePtr allocatedPtr(OpBuilder &builder, Location loc); /// Builds IR inserting the allocated pointer into the descriptor. - void setAllocatedPtr(OpBuilder &builder, Location loc, Value *ptr); + void setAllocatedPtr(OpBuilder &builder, Location loc, ValuePtr ptr); /// Builds IR extracting the aligned pointer from the descriptor. - Value *alignedPtr(OpBuilder &builder, Location loc); + ValuePtr alignedPtr(OpBuilder &builder, Location loc); /// Builds IR inserting the aligned pointer into the descriptor. - void setAlignedPtr(OpBuilder &builder, Location loc, Value *ptr); + void setAlignedPtr(OpBuilder &builder, Location loc, ValuePtr ptr); /// Builds IR extracting the offset from the descriptor. - Value *offset(OpBuilder &builder, Location loc); + ValuePtr offset(OpBuilder &builder, Location loc); /// Builds IR inserting the offset into the descriptor. - void setOffset(OpBuilder &builder, Location loc, Value *offset); + void setOffset(OpBuilder &builder, Location loc, ValuePtr offset); void setConstantOffset(OpBuilder &builder, Location loc, uint64_t offset); /// Builds IR extracting the pos-th size from the descriptor. - Value *size(OpBuilder &builder, Location loc, unsigned pos); + ValuePtr size(OpBuilder &builder, Location loc, unsigned pos); /// Builds IR inserting the pos-th size into the descriptor - void setSize(OpBuilder &builder, Location loc, unsigned pos, Value *size); + void setSize(OpBuilder &builder, Location loc, unsigned pos, ValuePtr size); void setConstantSize(OpBuilder &builder, Location loc, unsigned pos, uint64_t size); /// Builds IR extracting the pos-th size from the descriptor. - Value *stride(OpBuilder &builder, Location loc, unsigned pos); + ValuePtr stride(OpBuilder &builder, Location loc, unsigned pos); /// Builds IR inserting the pos-th stride into the descriptor - void setStride(OpBuilder &builder, Location loc, unsigned pos, Value *stride); + void setStride(OpBuilder &builder, Location loc, unsigned pos, + ValuePtr stride); void setConstantStride(OpBuilder &builder, Location loc, unsigned pos, uint64_t stride); @@ -220,19 +221,19 @@ private: class UnrankedMemRefDescriptor : public StructBuilder { public: /// Construct a helper for the given descriptor value. - explicit UnrankedMemRefDescriptor(Value *descriptor); + explicit UnrankedMemRefDescriptor(ValuePtr descriptor); /// Builds IR creating an `undef` value of the descriptor type. static UnrankedMemRefDescriptor undef(OpBuilder &builder, Location loc, Type descriptorType); /// Builds IR extracting the rank from the descriptor - Value *rank(OpBuilder &builder, Location loc); + ValuePtr rank(OpBuilder &builder, Location loc); /// Builds IR setting the rank in the descriptor - void setRank(OpBuilder &builder, Location loc, Value *value); + void setRank(OpBuilder &builder, Location loc, ValuePtr value); /// Builds IR extracting ranked memref descriptor ptr - Value *memRefDescPtr(OpBuilder &builder, Location loc); + ValuePtr memRefDescPtr(OpBuilder &builder, Location loc); /// Builds IR setting ranked memref descriptor ptr - void setMemRefDescPtr(OpBuilder &builder, Location loc, Value *value); + void setMemRefDescPtr(OpBuilder &builder, Location loc, ValuePtr value); }; /// Base class for operation conversions targeting the LLVM IR dialect. Provides /// conversion patterns with an access to the containing LLVMLowering for the diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOps.h b/mlir/include/mlir/Dialect/AffineOps/AffineOps.h index 36b4e55e77c..764f439e020 100644 --- a/mlir/include/mlir/Dialect/AffineOps/AffineOps.h +++ b/mlir/include/mlir/Dialect/AffineOps/AffineOps.h @@ -41,7 +41,7 @@ class OpBuilder; /// A utility function to check if a value is defined at the top level of a /// function. A value of index type defined at the top level is always a valid /// symbol. -bool isTopLevelValue(Value *value); +bool isTopLevelValue(ValuePtr value); class AffineOpsDialect : public Dialect { public: @@ -148,18 +148,19 @@ class AffineDmaStartOp : public OpgetType().cast(); } @@ -191,7 +192,7 @@ public: } /// Returns the destination MemRefType for this DMA operations. - Value *getDstMemRef() { return getOperand(getDstMemRefOperandIndex()); } + ValuePtr getDstMemRef() { return getOperand(getDstMemRefOperandIndex()); } MemRefType getDstMemRefType() { return getDstMemRef()->getType().cast(); } @@ -225,7 +226,7 @@ public: } /// Returns the Tag MemRef for this DMA operation. - Value *getTagMemRef() { return getOperand(getTagMemRefOperandIndex()); } + ValuePtr getTagMemRef() { return getOperand(getTagMemRefOperandIndex()); } MemRefType getTagMemRefType() { return getTagMemRef()->getType().cast(); } @@ -249,13 +250,13 @@ public: } /// Returns the number of elements being transferred by this DMA operation. - Value *getNumElements() { + ValuePtr getNumElements() { return getOperand(getTagMemRefOperandIndex() + 1 + getTagMap().getNumInputs()); } /// Returns the AffineMapAttr associated with 'memref'. - NamedAttribute getAffineMapAttrForMemRef(Value *memref) { + NamedAttribute getAffineMapAttrForMemRef(ValuePtr memref) { if (memref == getSrcMemRef()) return {Identifier::get(getSrcMapAttrName(), getContext()), getSrcMapAttr()}; @@ -305,14 +306,14 @@ public: } /// Returns the stride value for this DMA operation. - Value *getStride() { + ValuePtr getStride() { if (!isStrided()) return nullptr; return getOperand(getNumOperands() - 1 - 1); } /// Returns the number of elements to transfer per stride for this DMA op. - Value *getNumElementsPerStride() { + ValuePtr getNumElementsPerStride() { if (!isStrided()) return nullptr; return getOperand(getNumOperands() - 1); @@ -337,14 +338,14 @@ class AffineDmaWaitOp : public OpgetType().cast(); } @@ -367,14 +368,16 @@ public: } /// Returns the AffineMapAttr associated with 'memref'. - NamedAttribute getAffineMapAttrForMemRef(Value *memref) { + NamedAttribute getAffineMapAttrForMemRef(ValuePtr memref) { assert(memref == getTagMemRef()); return {Identifier::get(getTagMapAttrName(), getContext()), getTagMapAttr()}; } /// Returns the number of elements transferred in the associated DMA op. - Value *getNumElements() { return getOperand(1 + getTagMap().getNumInputs()); } + ValuePtr getNumElements() { + return getOperand(1 + getTagMap().getNumInputs()); + } static StringRef getTagMapAttrName() { return "tag_map"; } static ParseResult parse(OpAsmParser &parser, OperationState &result); @@ -409,18 +412,18 @@ public: static void build(Builder *builder, OperationState &result, AffineMap map, ValueRange operands); /// Builds an affine load op with an identity map and operands. - static void build(Builder *builder, OperationState &result, Value *memref, + static void build(Builder *builder, OperationState &result, ValuePtr memref, ValueRange indices = {}); /// Builds an affine load op with the specified map and its operands. - static void build(Builder *builder, OperationState &result, Value *memref, + static void build(Builder *builder, OperationState &result, ValuePtr memref, AffineMap map, ValueRange mapOperands); /// Returns the operand index of the memref. unsigned getMemRefOperandIndex() { return 0; } /// Get memref operand. - Value *getMemRef() { return getOperand(getMemRefOperandIndex()); } - void setMemRef(Value *value) { setOperand(getMemRefOperandIndex(), value); } + ValuePtr getMemRef() { return getOperand(getMemRefOperandIndex()); } + void setMemRef(ValuePtr value) { setOperand(getMemRefOperandIndex(), value); } MemRefType getMemRefType() { return getMemRef()->getType().cast(); } @@ -435,7 +438,7 @@ public: } /// Returns the AffineMapAttr associated with 'memref'. - NamedAttribute getAffineMapAttrForMemRef(Value *memref) { + NamedAttribute getAffineMapAttrForMemRef(ValuePtr memref) { assert(memref == getMemRef()); return {Identifier::get(getMapAttrName(), getContext()), getAffineMapAttr()}; @@ -476,21 +479,21 @@ public: /// Builds an affine store operation with the provided indices (identity map). static void build(Builder *builder, OperationState &result, - Value *valueToStore, Value *memref, ValueRange indices); + ValuePtr valueToStore, ValuePtr memref, ValueRange indices); /// Builds an affine store operation with the specified map and its operands. static void build(Builder *builder, OperationState &result, - Value *valueToStore, Value *memref, AffineMap map, + ValuePtr valueToStore, ValuePtr memref, AffineMap map, ValueRange mapOperands); /// Get value to be stored by store operation. - Value *getValueToStore() { return getOperand(0); } + ValuePtr getValueToStore() { return getOperand(0); } /// Returns the operand index of the memref. unsigned getMemRefOperandIndex() { return 1; } /// Get memref operand. - Value *getMemRef() { return getOperand(getMemRefOperandIndex()); } - void setMemRef(Value *value) { setOperand(getMemRefOperandIndex(), value); } + ValuePtr getMemRef() { return getOperand(getMemRefOperandIndex()); } + void setMemRef(ValuePtr value) { setOperand(getMemRefOperandIndex(), value); } MemRefType getMemRefType() { return getMemRef()->getType().cast(); @@ -506,7 +509,7 @@ public: } /// Returns the AffineMapAttr associated with 'memref'. - NamedAttribute getAffineMapAttrForMemRef(Value *memref) { + NamedAttribute getAffineMapAttrForMemRef(ValuePtr memref) { assert(memref == getMemRef()); return {Identifier::get(getMapAttrName(), getContext()), getAffineMapAttr()}; @@ -526,10 +529,10 @@ public: }; /// Returns true if the given Value can be used as a dimension id. -bool isValidDim(Value *value); +bool isValidDim(ValuePtr value); /// Returns true if the given Value can be used as a symbol. -bool isValidSymbol(Value *value); +bool isValidSymbol(ValuePtr value); /// Modifies both `map` and `operands` in-place so as to: /// 1. drop duplicate operands @@ -538,17 +541,17 @@ bool isValidSymbol(Value *value); /// dimensional operands /// 4. propagate constant operands and drop them void canonicalizeMapAndOperands(AffineMap *map, - SmallVectorImpl *operands); + SmallVectorImpl *operands); /// Canonicalizes an integer set the same way canonicalizeMapAndOperands does /// for affine maps. void canonicalizeSetAndOperands(IntegerSet *set, - SmallVectorImpl *operands); + SmallVectorImpl *operands); /// Returns a composed AffineApplyOp by composing `map` and `operands` with /// other AffineApplyOps supplying those operands. The operands of the resulting /// AffineApplyOp do not change the length of AffineApplyOp chains. AffineApplyOp makeComposedAffineApply(OpBuilder &b, Location loc, AffineMap map, - ArrayRef operands); + ArrayRef operands); /// Given an affine map `map` and its input `operands`, this method composes /// into `map`, maps of AffineApplyOps whose results are the values in @@ -558,22 +561,22 @@ AffineApplyOp makeComposedAffineApply(OpBuilder &b, Location loc, AffineMap map, /// terminal symbol, i.e., a symbol defined at the top level or a block/function /// argument. void fullyComposeAffineMapAndOperands(AffineMap *map, - SmallVectorImpl *operands); + SmallVectorImpl *operands); #define GET_OP_CLASSES #include "mlir/Dialect/AffineOps/AffineOps.h.inc" /// Returns if the provided value is the induction variable of a AffineForOp. -bool isForInductionVar(Value *val); +bool isForInductionVar(ValuePtr val); /// Returns the loop parent of an induction variable. If the provided value is /// not an induction variable, then return nullptr. -AffineForOp getForInductionVarOwner(Value *val); +AffineForOp getForInductionVarOwner(ValuePtr val); /// Extracts the induction variables from a list of AffineForOps and places them /// in the output argument `ivs`. void extractForInductionVars(ArrayRef forInsts, - SmallVectorImpl *ivs); + SmallVectorImpl *ivs); /// AffineBound represents a lower or upper bound in the for operation. /// This class does not own the underlying operands. Instead, it refers @@ -588,7 +591,7 @@ public: AffineValueMap getAsAffineValueMap(); unsigned getNumOperands() { return opEnd - opStart; } - Value *getOperand(unsigned idx) { return op.getOperand(opStart + idx); } + ValuePtr getOperand(unsigned idx) { return op.getOperand(opStart + idx); } using operand_iterator = AffineForOp::operand_iterator; using operand_range = AffineForOp::operand_range; @@ -613,7 +616,7 @@ private: }; /// An `AffineApplyNormalizer` is a helper class that supports renumbering -/// operands of AffineApplyOp. This acts as a reindexing map of Value* to +/// operands of AffineApplyOp. This acts as a reindexing map of Value to /// positional dims or symbols and allows simplifications such as: /// /// ```mlir @@ -626,13 +629,13 @@ private: /// %1 = affine.apply () -> (0) /// ``` struct AffineApplyNormalizer { - AffineApplyNormalizer(AffineMap map, ArrayRef operands); + AffineApplyNormalizer(AffineMap map, ArrayRef operands); /// Returns the AffineMap resulting from normalization. AffineMap getAffineMap() { return affineMap; } - SmallVector getOperands() { - SmallVector res(reorderedDims); + SmallVector getOperands() { + SmallVector res(reorderedDims); res.append(concatenatedSymbols.begin(), concatenatedSymbols.end()); return res; } @@ -642,13 +645,13 @@ struct AffineApplyNormalizer { /// Normalizes 'otherMap' and its operands 'otherOperands' to map to this /// normalizer's coordinate space. - void normalize(AffineMap *otherMap, SmallVectorImpl *otherOperands); + void normalize(AffineMap *otherMap, SmallVectorImpl *otherOperands); private: /// Helper function to insert `v` into the coordinate system of the current /// AffineApplyNormalizer. Returns the AffineDimExpr with the corresponding /// renumbered position. - AffineDimExpr renumberOneDim(Value *v); + AffineDimExpr renumberOneDim(ValuePtr v); /// Given an `other` normalizer, this rewrites `other.affineMap` in the /// coordinate system of the current AffineApplyNormalizer. @@ -656,13 +659,13 @@ private: /// `this`. AffineMap renumber(const AffineApplyNormalizer &other); - /// Maps of Value* to position in `affineMap`. - DenseMap dimValueToPosition; + /// Maps of Value to position in `affineMap`. + DenseMap dimValueToPosition; /// Ordered dims and symbols matching positional dims and symbols in /// `affineMap`. - SmallVector reorderedDims; - SmallVector concatenatedSymbols; + SmallVector reorderedDims; + SmallVector concatenatedSymbols; AffineMap affineMap; diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOps.td b/mlir/include/mlir/Dialect/AffineOps/AffineOps.td index b40990ecb5d..befdc2f6237 100644 --- a/mlir/include/mlir/Dialect/AffineOps/AffineOps.td +++ b/mlir/include/mlir/Dialect/AffineOps/AffineOps.td @@ -101,7 +101,7 @@ def AffineForOp : Affine_Op<"for", static StringRef getUpperBoundAttrName() { return "upper_bound"; } Block *getBody() { return ®ion().front(); } - Value *getInductionVar() { return getBody()->getArgument(0); } + ValuePtr getInductionVar() { return getBody()->getArgument(0); } OpBuilder getBodyBuilder() { return OpBuilder(getBody(), std::prev(getBody()->end())); } @@ -286,8 +286,8 @@ def AffinePrefetchOp : Affine_Op<"prefetch"> { BoolAttr:$isDataCache); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *memref," - "AffineMap map, ArrayRef mapOperands, bool isWrite," + "Builder *builder, OperationState &result, ValuePtr memref," + "AffineMap map, ArrayRef mapOperands, bool isWrite," "unsigned localityHint, bool isDataCache", [{ assert(map.getNumInputs() == mapOperands.size() @@ -315,7 +315,7 @@ def AffinePrefetchOp : Affine_Op<"prefetch"> { } /// Returns the AffineMapAttr associated with 'memref'. - NamedAttribute getAffineMapAttrForMemRef(Value *mref) { + NamedAttribute getAffineMapAttrForMemRef(ValuePtr mref) { assert(mref == memref()); return {Identifier::get(getMapAttrName(), getContext()), getAffineMapAttr()}; diff --git a/mlir/include/mlir/Dialect/GPU/GPUDialect.h b/mlir/include/mlir/Dialect/GPU/GPUDialect.h index 93c0b13ee3e..12c2aa1bbd1 100644 --- a/mlir/include/mlir/Dialect/GPU/GPUDialect.h +++ b/mlir/include/mlir/Dialect/GPU/GPUDialect.h @@ -77,9 +77,9 @@ public: /// Utility class for the GPU dialect to represent triples of `Value`s /// accessible through `.x`, `.y`, and `.z` similarly to CUDA notation. struct KernelDim3 { - Value *x; - Value *y; - Value *z; + ValuePtr x; + ValuePtr y; + ValuePtr z; }; #define GET_OP_CLASSES diff --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td b/mlir/include/mlir/Dialect/GPU/GPUOps.td index 6751f0a3f70..def1ff2b8a1 100644 --- a/mlir/include/mlir/Dialect/GPU/GPUOps.td +++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td @@ -157,7 +157,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [FunctionLike, IsolatedFromAbove, Symbol]> { /// Returns a list of block arguments that correspond to buffers located in /// the workgroup memory - ArrayRef getWorkgroupAttributions() { + ArrayRef getWorkgroupAttributions() { auto begin = std::next(getBody().front().args_begin(), getType().getNumInputs()); auto end = std::next(begin, getNumWorkgroupAttributions()); @@ -166,7 +166,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [FunctionLike, IsolatedFromAbove, Symbol]> { /// Returns a list of block arguments that correspond to buffers located in /// the private memory. - ArrayRef getPrivateAttributions() { + ArrayRef getPrivateAttributions() { auto begin = std::next(getBody().front().args_begin(), getType().getNumInputs() + getNumWorkgroupAttributions()); @@ -282,8 +282,8 @@ def GPU_LaunchFuncOp : GPU_Op<"launch_func">, let builders = [ OpBuilder<"Builder *builder, OperationState &result, GPUFuncOp kernelFunc, " - "Value *gridSizeX, Value *gridSizeY, Value *gridSizeZ, " - "Value *blockSizeX, Value *blockSizeY, Value *blockSizeZ, " + "ValuePtr gridSizeX, ValuePtr gridSizeY, ValuePtr gridSizeZ, " + "ValuePtr blockSizeX, ValuePtr blockSizeY, ValuePtr blockSizeZ, " "ValueRange kernelOperands">, OpBuilder<"Builder *builder, OperationState &result, GPUFuncOp kernelFunc, " "KernelDim3 gridSize, KernelDim3 blockSize, " @@ -302,7 +302,7 @@ def GPU_LaunchFuncOp : GPU_Op<"launch_func">, StringRef getKernelModuleName(); /// The i-th operand passed to the kernel function. - Value *getKernelOperand(unsigned i); + ValuePtr getKernelOperand(unsigned i); /// Get the SSA values passed as operands to specify the grid size. KernelDim3 getGridSizeOperandValues(); @@ -415,9 +415,9 @@ def GPU_LaunchOp : GPU_Op<"launch", [IsolatedFromAbove]>, let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"Builder *builder, OperationState &result, Value *gridSizeX," - "Value *gridSizeY, Value *gridSizeZ, Value *blockSizeX," - "Value *blockSizeY, Value *blockSizeZ," + OpBuilder<"Builder *builder, OperationState &result, ValuePtr gridSizeX," + "ValuePtr gridSizeY, ValuePtr gridSizeZ, ValuePtr blockSizeX," + "ValuePtr blockSizeY, ValuePtr blockSizeZ," "ValueRange operands"> ]; diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h index dae27d00e5a..a599d51b31f 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h @@ -194,9 +194,9 @@ private: /// surrounding the insertion point of builder. Obtain the address of that /// global and use it to compute the address of the first character in the /// string (operations inserted at the builder insertion point). -Value *createGlobalString(Location loc, OpBuilder &builder, StringRef name, - StringRef value, LLVM::Linkage linkage, - LLVM::LLVMDialect *llvmDialect); +ValuePtr createGlobalString(Location loc, OpBuilder &builder, StringRef name, + StringRef value, LLVM::Linkage linkage, + LLVM::LLVMDialect *llvmDialect); /// LLVM requires some operations to be inside of a Module operation. This /// function confirms that the Operation has the desired properties. diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td index 00acc539dab..cfbbf7da65d 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -185,8 +185,8 @@ def LLVM_ICmpOp : LLVM_OneResultOp<"icmp", [NoSideEffect]>, $res = builder.CreateICmp(getLLVMCmpPredicate($predicate), $lhs, $rhs); }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, ICmpPredicate predicate, Value *lhs, " - "Value *rhs", [{ + "Builder *b, OperationState &result, ICmpPredicate predicate, ValuePtr lhs, " + "ValuePtr rhs", [{ LLVMDialect *dialect = &lhs->getType().cast().getDialect(); build(b, result, LLVMType::getInt1Ty(dialect), b->getI64IntegerAttr(static_cast(predicate)), lhs, rhs); @@ -232,8 +232,8 @@ def LLVM_FCmpOp : LLVM_OneResultOp<"fcmp", [NoSideEffect]>, $res = builder.CreateFCmp(getLLVMCmpPredicate($predicate), $lhs, $rhs); }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, FCmpPredicate predicate, Value *lhs, " - "Value *rhs", [{ + "Builder *b, OperationState &result, FCmpPredicate predicate, ValuePtr lhs, " + "ValuePtr rhs", [{ LLVMDialect *dialect = &lhs->getType().cast().getDialect(); build(b, result, LLVMType::getInt1Ty(dialect), b->getI64IntegerAttr(static_cast(predicate)), lhs, rhs); @@ -265,7 +265,7 @@ def LLVM_AllocaOp : $res = alloca; }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, Type resultType, Value *arraySize, " + "Builder *b, OperationState &result, Type resultType, ValuePtr arraySize, " "unsigned alignment", [{ if (alignment == 0) @@ -292,7 +292,7 @@ def LLVM_GEPOp : LLVM_OneResultOp<"getelementptr", [NoSideEffect]>, def LLVM_LoadOp : LLVM_OneResultOp<"load">, Arguments<(ins LLVM_Type:$addr)>, LLVM_Builder<"$res = builder.CreateLoad($addr);"> { let builders = [OpBuilder< - "Builder *b, OperationState &result, Value *addr", + "Builder *b, OperationState &result, ValuePtr addr", [{ auto type = addr->getType().cast().getPointerElementTy(); build(b, result, type, addr); @@ -353,7 +353,7 @@ def LLVM_ExtractElementOp : LLVM_OneResultOp<"extractelement", [NoSideEffect]>, $res = builder.CreateExtractElement($vector, $position); }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, Value *vector, Value *position," + "Builder *b, OperationState &result, ValuePtr vector, ValuePtr position," "ArrayRef attrs = {}">]; let parser = [{ return parseExtractElementOp(parser, result); }]; let printer = [{ printExtractElementOp(p, *this); }]; @@ -384,7 +384,7 @@ def LLVM_InsertValueOp : LLVM_OneResultOp<"insertvalue", [NoSideEffect]>, extractPosition($position)); }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, Value *container, Value *value, " + "Builder *b, OperationState &result, ValuePtr container, ValuePtr value, " "ArrayAttr position", [{ build(b, result, container->getType(), container, value, position); @@ -398,7 +398,7 @@ def LLVM_ShuffleVectorOp LLVM_Builder< "$res = builder.CreateShuffleVector($v1, $v2, extractPosition($mask));"> { let builders = [OpBuilder< - "Builder *b, OperationState &result, Value *v1, Value *v2, " + "Builder *b, OperationState &result, ValuePtr v1, ValuePtr v2, " "ArrayAttr mask, ArrayRef attrs = {}">]; let verifier = [{ auto wrappedVectorType1 = v1()->getType().cast(); @@ -422,8 +422,8 @@ def LLVM_SelectOp LLVM_Builder< "$res = builder.CreateSelect($condition, $trueValue, $falseValue);"> { let builders = [OpBuilder< - "Builder *b, OperationState &result, Value *condition, Value *lhs, " - "Value *rhs", [{ + "Builder *b, OperationState &result, ValuePtr condition, ValuePtr lhs, " + "ValuePtr rhs", [{ build(b, result, lhs->getType(), condition, lhs, rhs); }]>]; let parser = [{ return parseSelectOp(parser, result); }]; diff --git a/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h b/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h index 01d3e4b239c..426708b14a8 100644 --- a/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h +++ b/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h @@ -37,15 +37,15 @@ class LinalgOp; class Aliases { public: /// Returns true if v1 and v2 alias. - bool alias(Value *v1, Value *v2) { return find(v1) == find(v2); } + bool alias(ValuePtr v1, ValuePtr v2) { return find(v1) == find(v2); } private: /// Returns the base buffer or block argument into which the view `v` aliases. /// This lazily records the new aliases discovered while walking back the /// use-def chain. - Value *find(Value *v); + ValuePtr find(ValuePtr v); - DenseMap aliases; + DenseMap aliases; }; /// Data structure for holding a dependence graph that operates on LinalgOp and @@ -54,7 +54,7 @@ class LinalgDependenceGraph { public: struct LinalgOpView { Operation *op; - Value *view; + ValuePtr view; }; struct LinalgDependenceGraphElem { // dependentOpView may be either: @@ -64,7 +64,7 @@ public: // View in the op that is used to index in the graph: // 1. src in the case of dependencesFromDstGraphs. // 2. dst in the case of dependencesIntoGraphs. - Value *indexingView; + ValuePtr indexingView; }; using LinalgDependences = SmallVector; using DependenceGraph = DenseMap; @@ -97,14 +97,14 @@ public: /// Dependences are restricted to views aliasing `view`. SmallVector findCoveringReads(LinalgOp srcLinalgOp, LinalgOp dstLinalgOp, - Value *view) const; + ValuePtr view) const; /// Returns the operations that are interleaved between `srcLinalgOp` and /// `dstLinalgOp` and that are involved in a WAR or WAW with `srcLinalgOp`. /// Dependences are restricted to views aliasing `view`. SmallVector findCoveringWrites(LinalgOp srcLinalgOp, LinalgOp dstLinalgOp, - Value *view) const; + ValuePtr view) const; private: // Keep dependences in both directions, this is not just a performance gain @@ -130,7 +130,7 @@ private: /// Implementation detail for findCoveringxxx. SmallVector findOperationsWithCoveringDependences(LinalgOp srcLinalgOp, - LinalgOp dstLinalgOp, Value *view, + LinalgOp dstLinalgOp, ValuePtr view, ArrayRef types) const; Aliases &aliases; diff --git a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h index cf6335278b7..8375e750a5c 100644 --- a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h @@ -55,34 +55,34 @@ inline StringRef toString(IterType t) { /// makeLinalgGenericOp({A({m, n}), B({k, n})}, {C({m, n})}, ... ); /// ``` struct StructuredIndexed { - StructuredIndexed(Value *v) : value(v) {} + StructuredIndexed(ValuePtr v) : value(v) {} StructuredIndexed operator()(ArrayRef indexings) { return StructuredIndexed(value, indexings); } - operator Value *() const /* implicit */ { return value; } + operator ValuePtr() const /* implicit */ { return value; } ArrayRef getExprs() { return exprs; } private: - StructuredIndexed(Value *v, ArrayRef indexings) + StructuredIndexed(ValuePtr v, ArrayRef indexings) : value(v), exprs(indexings.begin(), indexings.end()) { assert(v->getType().isa() && "MemRefType expected"); } StructuredIndexed(ValueHandle v, ArrayRef indexings) : StructuredIndexed(v.getValue(), indexings) {} - Value *value; + ValuePtr value; SmallVector exprs; }; -inline void defaultRegionBuilder(ArrayRef args) {} +inline void defaultRegionBuilder(ArrayRef args) {} Operation *makeLinalgGenericOp(ArrayRef iteratorTypes, ArrayRef inputs, ArrayRef outputs, - function_ref)> + function_ref)> regionBuilder = defaultRegionBuilder, - ArrayRef otherValues = {}, + ArrayRef otherValues = {}, ArrayRef otherAttributes = {}); namespace ops { @@ -96,7 +96,7 @@ using edsc::intrinsics::linalg_yield; /// Build the body of a region to compute a multiply-accumulate, under the /// current ScopedContext, at the current insert point. -void macRegionBuilder(ArrayRef args); +void macRegionBuilder(ArrayRef args); /// TODO(ntv): In the future we should tie these implementations to something in /// Tablegen that generates the proper interfaces and the proper sugared named @@ -120,7 +120,7 @@ void macRegionBuilder(ArrayRef args); /// with in-place semantics and parallelism. /// Unary pointwise operation (with broadcast) entry point. -using UnaryPointwiseOpBuilder = function_ref; +using UnaryPointwiseOpBuilder = function_ref; Operation *linalg_pointwise(UnaryPointwiseOpBuilder unaryOp, StructuredIndexed I, StructuredIndexed O); @@ -131,7 +131,7 @@ Operation *linalg_pointwise_tanh(StructuredIndexed I, StructuredIndexed O); /// Binary pointwise operation (with broadcast) entry point. using BinaryPointwiseOpBuilder = - function_ref; + function_ref; Operation *linalg_pointwise(BinaryPointwiseOpBuilder binaryOp, StructuredIndexed I1, StructuredIndexed I2, StructuredIndexed O); diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td index 12318a244df..18ca31cc376 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td @@ -92,22 +92,22 @@ def LinalgLibraryInterface : OpInterface<"LinalgOp"> { "Query the number of loops within the current operation.", "unsigned", "getNumLoops">, InterfaceMethod<"Query the input view at the given index.", - "Value *", "getInput", (ins "unsigned":$i) + "ValuePtr ", "getInput", (ins "unsigned":$i) >, InterfaceMethod<"Query the output view at the given index.", - "Value *", "getOutput", (ins "unsigned":$i) + "ValuePtr ", "getOutput", (ins "unsigned":$i) >, InterfaceMethod<[{ Query the index of the given input value, or `None` if the value is not an input. }], - "Optional", "getIndexOfInput", (ins "Value *":$view) + "Optional", "getIndexOfInput", (ins "ValuePtr ":$view) >, InterfaceMethod<[{ Query the index of the given view value, or `None` if the value is not an view. }], - "Optional", "getIndexOfOutput", (ins "Value *":$view) + "Optional", "getIndexOfOutput", (ins "ValuePtr ":$view) >, InterfaceMethod<[{ Query the type of the input view at the given index. @@ -228,7 +228,7 @@ def CopyOp : LinalgLibrary_Op<"copy", [NInputs<1>, NOutputs<1>]> { // TODO(ntv) this should go away once the usage of OptionalAttr triggers // emission of builders with default arguments left unspecified. let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *input, Value *output", [{ + "Builder *builder, OperationState &result, ValuePtr input, ValuePtr output", [{ return build( builder, result, input, output, AffineMapAttr(), AffineMapAttr()); }]>]; diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td index b806d7548fb..5d402a9ded9 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td @@ -56,8 +56,8 @@ def Linalg_RangeOp : ```` }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *min, Value *max, " - "Value *step", + "Builder *builder, OperationState &result, ValuePtr min, ValuePtr max, " + "ValuePtr step", [{ auto rangeType = RangeType::get(builder->getContext()); build(builder, result, rangeType, min, max, step); @@ -112,7 +112,7 @@ def Linalg_SliceOp : Linalg_Op<"slice", [NoSideEffect]>, }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, Value *base, " + "Builder *b, OperationState &result, ValuePtr base, " "ValueRange indexings">]; let extraClassDeclaration = [{ @@ -124,12 +124,12 @@ def Linalg_SliceOp : Linalg_Op<"slice", [NoSideEffect]>, MemRefType getBaseViewType() { return view()->getType().cast(); } // Get the underlying indexing at a given rank. - Value *indexing(unsigned rank) { return *(indexings().begin() + rank); } + ValuePtr indexing(unsigned rank) { return *(indexings().begin() + rank); } // Get the subset of indexings that are of RangeType. - SmallVector getRanges() { - SmallVector res; - for (auto *operand : indexings()) + SmallVector getRanges() { + SmallVector res; + for (auto operand : indexings()) if (!operand->getType().isa()) res.push_back(operand); return res; @@ -154,7 +154,7 @@ def Linalg_TransposeOp : Linalg_Op<"transpose", [NoSideEffect]>, }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, Value *view, " + "Builder *b, OperationState &result, ValuePtr view, " "AffineMapAttr permutation, ArrayRef attrs = {}">]; let verifier = [{ diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td index 75b63c93cd8..774be6616cd 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td @@ -92,22 +92,22 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> { "Query the number of loops within the current operation.", "unsigned", "getNumLoops">, InterfaceMethod<"Query the input view at the given index.", - "Value *", "getInput", (ins "unsigned":$i) + "ValuePtr ", "getInput", (ins "unsigned":$i) >, InterfaceMethod<"Query the output view at the given index.", - "Value *", "getOutput", (ins "unsigned":$i) + "ValuePtr ", "getOutput", (ins "unsigned":$i) >, InterfaceMethod<[{ Query the index of the given input value, or `None` if the value is not an input. }], - "llvm::Optional", "getIndexOfInput", (ins "Value *":$view) + "llvm::Optional", "getIndexOfInput", (ins "ValuePtr ":$view) >, InterfaceMethod<[{ Query the index of the given view value, or `None` if the value is not an view. }], - "llvm::Optional", "getIndexOfOutput", (ins "Value *":$view) + "llvm::Optional", "getIndexOfOutput", (ins "ValuePtr ":$view) >, InterfaceMethod<[{ Query the type of the input view at the given index. @@ -228,7 +228,7 @@ def CopyOp : LinalgStructured_Op<"copy", [NInputs<1>, NOutputs<1>]> { // TODO(ntv) this should go away once the usage of OptionalAttr triggers // emission of builders with default arguments left unspecified. let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *input, Value *output", [{ + "Builder *builder, OperationState &result, ValuePtr input, ValuePtr output", [{ return build( builder, result, input, output, AffineMapAttr(), AffineMapAttr()); }]>]; diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h index a24c1ca63c4..d196e6ccf94 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h @@ -77,13 +77,13 @@ private: public: /// Return the `i`-th input view. - Value *getInput(unsigned i) { + ValuePtr getInput(unsigned i) { assert(i < nInputs()); return this->getOperation()->getOperand(i); } /// Return the index of `view` in the list of input views if found, llvm::None /// otherwise. - Optional getIndexOfInput(Value *view) { + Optional getIndexOfInput(ValuePtr view) { auto it = llvm::find(getInputs(), view); if (it != getInputs().end()) return it - getInputs().begin(); @@ -99,12 +99,12 @@ public: return {range.begin(), range.begin() + nInputs()}; } /// Return the `i`-th output view. - Value *getOutput(unsigned i) { + ValuePtr getOutput(unsigned i) { return this->getOperation()->getOperand(nInputs() + i); } /// Return the index of `view` in the list of output views if found, /// llvm::None otherwise. - Optional getIndexOfOutput(Value *view) { + Optional getIndexOfOutput(ValuePtr view) { auto it = llvm::find(getOutputs(), view); if (it != getOutputs().end()) return it - getOutputs().begin(); diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td index 415dd918f74..dbc162f4132 100644 --- a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td @@ -45,7 +45,7 @@ class AffineMapDomainHasDim : CPred<[{ class HasOperandsOfType: CPred<[{ llvm::any_of($0.getOperands(), - [](Value* v) { + [](ValuePtr v) { return dyn_cast_or_null<}] # type # [{>(v->getDefiningOp()); }) }]>; diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h index dfbac5ac193..a1a7458ae7f 100644 --- a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h @@ -38,7 +38,7 @@ struct LinalgTransforms { namespace detail { // Implementation detail of isProducedByOpOfType avoids the need for explicit // template instantiations. -bool isProducedByOpOfTypeImpl(Operation *consumerOp, Value *consumedView, +bool isProducedByOpOfTypeImpl(Operation *consumerOp, ValuePtr consumedView, function_ref isaOpType); } // namespace detail @@ -46,7 +46,7 @@ bool isProducedByOpOfTypeImpl(Operation *consumerOp, Value *consumedView, // an op of type `OpTy`. This is used to implement use-def type information on // buffers. template -bool isProducedByOpOfType(Operation *consumerOp, Value *consumedView) { +bool isProducedByOpOfType(Operation *consumerOp, ValuePtr consumedView) { return detail::isProducedByOpOfTypeImpl( consumerOp, consumedView, [](Operation *op) { return isa(op); }); } diff --git a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h index f8d10ecfa57..50039dd9336 100644 --- a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h @@ -34,7 +34,7 @@ namespace edsc { /// A LoopRangeBuilder is a generic NestedBuilder for loop.for operations. /// More specifically it is meant to be used as a temporary object for -/// representing any nested MLIR construct that is "related to" an mlir::Value* +/// representing any nested MLIR construct that is "related to" an mlir::Value /// (for now an induction variable). class LoopRangeBuilder : public NestedBuilder { public: @@ -42,7 +42,7 @@ public: /// variable. A ValueHandle pointer is passed as the first argument and is the /// *only* way to capture the loop induction variable. LoopRangeBuilder(ValueHandle *iv, ValueHandle range); - LoopRangeBuilder(ValueHandle *iv, Value *range); + LoopRangeBuilder(ValueHandle *iv, ValuePtr range); LoopRangeBuilder(ValueHandle *iv, SubViewOp::Range range); LoopRangeBuilder(const LoopRangeBuilder &) = delete; @@ -65,7 +65,7 @@ public: LoopNestRangeBuilder(ArrayRef ivs, ArrayRef ranges); LoopNestRangeBuilder(ArrayRef ivs, - ArrayRef ranges); + ArrayRef ranges); LoopNestRangeBuilder(ArrayRef ivs, ArrayRef ranges); edsc::ValueHandle operator()(std::function fun = nullptr); @@ -88,14 +88,14 @@ struct FusionInfo { /// whole `consumedView`. This checks structural dominance, that the dependence /// is a RAW without any interleaved write to any piece of `consumedView`. bool isProducerLastWriteOfView(const LinalgDependenceGraph &graph, - LinalgOp consumer, Value *consumedView, + LinalgOp consumer, ValuePtr consumedView, LinalgOp producer); /// Checks whether fusing the specific `producer` of the `consumedView` is /// feasible. This checks `producer` is the last write of `consumedView` and /// that no interleaved dependence would be violated (RAW, WAR or WAW). bool isFusableInto(const LinalgDependenceGraph &graph, LinalgOp consumer, - Value *consumedView, LinalgOp producer); + ValuePtr consumedView, LinalgOp producer); /// Fuses producer into consumer if the producer is structurally feasible and /// the fusion would not violate dependencies. @@ -111,8 +111,8 @@ Optional fuseProducerOf(OpBuilder &b, LinalgOp consumer, /// the inverse, concatenated loopToOperandRangeMaps to this list allows the /// derivation of loop ranges for any linalgOp. template -SmallVector getViewSizes(ConcreteOp linalgOp) { - SmallVector res; +SmallVector getViewSizes(ConcreteOp linalgOp) { + SmallVector res; for (auto v : linalgOp.getInputsAndOutputs()) { MemRefType t = v->getType().template cast(); for (unsigned i = 0; i < t.getRank(); ++i) @@ -125,10 +125,10 @@ SmallVector getViewSizes(ConcreteOp linalgOp) { /// When non-null, the optional pointer `folder` is used to call into the /// `createAndFold` builder method. If `folder` is null, the regular `create` /// method is called. -SmallVector applyMapToValues(OpBuilder &b, Location loc, - AffineMap map, - ArrayRef values, - OperationFolder *folder = nullptr); +SmallVector applyMapToValues(OpBuilder &b, Location loc, + AffineMap map, + ArrayRef values, + OperationFolder *folder = nullptr); struct TiledLinalgOp { LinalgOp op; @@ -151,7 +151,7 @@ struct TiledLinalgOp { /// `createAndFold` builder method. If `folder` is null, the regular `create` /// method is called. Optional tileLinalgOp(OpBuilder &b, LinalgOp op, - ArrayRef tileSizes, + ArrayRef tileSizes, ArrayRef permutation = {}, OperationFolder *folder = nullptr); @@ -182,9 +182,9 @@ Optional tileLinalgOperation(OpBuilder &b, Operation *op, } struct PromotionInfo { - Value *buffer; - Value *fullLocalView; - Value *partialLocalView; + ValuePtr buffer; + ValuePtr fullLocalView; + ValuePtr partialLocalView; }; /// Promotes the `subViews` into a new buffer allocated at the insertion point @@ -199,13 +199,13 @@ struct PromotionInfo { /// Returns a list of PromotionInfo which hold the promoted buffer and the /// full and partial views indexing into the buffer. SmallVector -promoteSubViews(OpBuilder &b, Location loc, ArrayRef subViews, +promoteSubViews(OpBuilder &b, Location loc, ArrayRef subViews, bool dynamicBuffers = false, OperationFolder *folder = nullptr); /// Returns all the operands of `linalgOp` that are not views. /// Asserts that these operands are value types to allow transformations like /// tiling to just use the values when cloning `linalgOp`. -SmallVector getAssumedNonViewOperands(LinalgOp linalgOp); +SmallVector getAssumedNonViewOperands(LinalgOp linalgOp); /// Apply the permutation defined by `permutation` to `inVec`. /// Element `i` in `inVec` is mapped to location `j = permutation[i]`. @@ -226,7 +226,7 @@ void applyPermutationToVector(SmallVector &inVec, /// It is the entry point for declarative transformation /// Returns the cloned `LinalgOp` with the new operands LinalgOp promoteSubViewOperands(OpBuilder &b, LinalgOp op, - llvm::SetVector subViews, + llvm::SetVector subViews, bool dynamicBuffers = false, OperationFolder *folder = nullptr); diff --git a/mlir/include/mlir/Dialect/LoopOps/LoopOps.h b/mlir/include/mlir/Dialect/LoopOps/LoopOps.h index fdadf4a40dd..e7ff6f84977 100644 --- a/mlir/include/mlir/Dialect/LoopOps/LoopOps.h +++ b/mlir/include/mlir/Dialect/LoopOps/LoopOps.h @@ -50,7 +50,7 @@ void ensureLoopTerminator(Region ®ion, Builder &builder, Location loc); /// Returns the loop parent of an induction variable. If the provided value is /// not an induction variable, then return nullptr. -ForOp getForInductionVarOwner(Value *val); +ForOp getForInductionVarOwner(ValuePtr val); } // end namespace loop } // end namespace mlir diff --git a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td index 5e0b8098411..e0f5b896309 100644 --- a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td +++ b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td @@ -74,18 +74,18 @@ def ForOp : Loop_Op<"for", let skipDefaultBuilders = 1; let builders = [ OpBuilder<"Builder *builder, OperationState &result, " - "Value *lowerBound, Value *upperBound, Value *step"> + "ValuePtr lowerBound, ValuePtr upperBound, ValuePtr step"> ]; let extraClassDeclaration = [{ Block *getBody() { return ®ion().front(); } - Value *getInductionVar() { return getBody()->getArgument(0); } + ValuePtr getInductionVar() { return getBody()->getArgument(0); } OpBuilder getBodyBuilder() { return OpBuilder(getBody(), std::prev(getBody()->end())); } - void setLowerBound(Value *bound) { getOperation()->setOperand(0, bound); } - void setUpperBound(Value *bound) { getOperation()->setOperand(1, bound); } - void setStep(Value *step) { getOperation()->setOperand(2, step); } + void setLowerBound(ValuePtr bound) { getOperation()->setOperand(0, bound); } + void setUpperBound(ValuePtr bound) { getOperation()->setOperand(1, bound); } + void setStep(ValuePtr step) { getOperation()->setOperand(2, step); } }]; } @@ -116,7 +116,7 @@ def IfOp : Loop_Op<"if", let skipDefaultBuilders = 1; let builders = [ OpBuilder<"Builder *builder, OperationState &result, " - "Value *cond, bool withElseRegion"> + "ValuePtr cond, bool withElseRegion"> ]; let extraClassDeclaration = [{ diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td index d6e2e1c6fda..d19fd974684 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td @@ -120,7 +120,7 @@ def SPV_CompositeExtractOp : SPV_Op<"CompositeExtract", [NoSideEffect]> { let builders = [ OpBuilder<[{Builder *builder, OperationState &state, - Value *composite, ArrayRef indices}]> + ValuePtr composite, ArrayRef indices}]> ]; let hasFolder = 1; diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td index 464b670dae9..32a78024560 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td @@ -132,7 +132,7 @@ def SPV_BranchConditionalOp : SPV_Op<"BranchConditional", let builders = [ OpBuilder< - "Builder *builder, OperationState &state, Value *condition, " + "Builder *builder, OperationState &state, ValuePtr condition, " "Block *trueBlock, ValueRange trueArguments, " "Block *falseBlock, ValueRange falseArguments, " "Optional> weights = {}", diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td index 0c4b2902a12..e1e94bcd861 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td @@ -858,8 +858,8 @@ def SPV_SelectOp : SPV_Op<"Select", [NoSideEffect]> { ); let builders = [OpBuilder<[{Builder *builder, OperationState &state, - Value *cond, Value *trueValue, - Value *falseValue}]>]; + ValuePtr cond, ValuePtr trueValue, + ValuePtr falseValue}]>]; } // ----- diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h index f48a1d0b129..37b4ee24237 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h @@ -64,8 +64,8 @@ protected: namespace spirv { /// Returns a value that represents a builtin variable value within the SPIR-V /// module. -Value *getBuiltinVariableValue(Operation *op, spirv::BuiltIn builtin, - OpBuilder &builder); +ValuePtr getBuiltinVariableValue(Operation *op, spirv::BuiltIn builtin, + OpBuilder &builder); /// Attribute name for specifying argument ABI information. StringRef getInterfaceVarABIAttrName(); diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td index 91ea8d7d676..777e5750486 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td @@ -102,7 +102,7 @@ def SPV_AccessChainOp : SPV_Op<"AccessChain", [NoSideEffect]> { ); let builders = [OpBuilder<[{Builder *builder, OperationState &state, - Value *basePtr, ValueRange indices}]>]; + ValuePtr basePtr, ValueRange indices}]>]; let hasCanonicalizer = 1; } @@ -272,7 +272,7 @@ def SPV_LoadOp : SPV_Op<"Load", []> { ); let builders = [OpBuilder<[{Builder *builder, OperationState &state, - Value *basePtr, /*optional*/IntegerAttr memory_access, + ValuePtr basePtr, /*optional*/IntegerAttr memory_access, /*optional*/IntegerAttr alignment}]>]; } @@ -367,7 +367,7 @@ def SPV_StoreOp : SPV_Op<"Store", []> { let builders = [ OpBuilder<"Builder *builder, OperationState &state, " - "Value *ptr, Value *value, ArrayRef namedAttrs", [{ + "ValuePtr ptr, ValuePtr value, ArrayRef namedAttrs", [{ state.addOperands(ptr); state.addOperands(value); state.addAttributes(namedAttrs); diff --git a/mlir/include/mlir/Dialect/StandardOps/Ops.h b/mlir/include/mlir/Dialect/StandardOps/Ops.h index 1b1cf02d204..563116823d9 100644 --- a/mlir/include/mlir/Dialect/StandardOps/Ops.h +++ b/mlir/include/mlir/Dialect/StandardOps/Ops.h @@ -182,15 +182,15 @@ class DmaStartOp public: using Op::Op; - static void build(Builder *builder, OperationState &result, Value *srcMemRef, - ValueRange srcIndices, Value *destMemRef, - ValueRange destIndices, Value *numElements, - Value *tagMemRef, ValueRange tagIndices, - Value *stride = nullptr, - Value *elementsPerStride = nullptr); + static void build(Builder *builder, OperationState &result, + ValuePtr srcMemRef, ValueRange srcIndices, + ValuePtr destMemRef, ValueRange destIndices, + ValuePtr numElements, ValuePtr tagMemRef, + ValueRange tagIndices, ValuePtr stride = nullptr, + ValuePtr elementsPerStride = nullptr); // Returns the source MemRefType for this DMA operation. - Value *getSrcMemRef() { return getOperand(0); } + ValuePtr getSrcMemRef() { return getOperand(0); } // Returns the rank (number of indices) of the source MemRefType. unsigned getSrcMemRefRank() { return getSrcMemRef()->getType().cast().getRank(); @@ -202,7 +202,7 @@ public: } // Returns the destination MemRefType for this DMA operations. - Value *getDstMemRef() { return getOperand(1 + getSrcMemRefRank()); } + ValuePtr getDstMemRef() { return getOperand(1 + getSrcMemRefRank()); } // Returns the rank (number of indices) of the destination MemRefType. unsigned getDstMemRefRank() { return getDstMemRef()->getType().cast().getRank(); @@ -222,12 +222,12 @@ public: } // Returns the number of elements being transferred by this DMA operation. - Value *getNumElements() { + ValuePtr getNumElements() { return getOperand(1 + getSrcMemRefRank() + 1 + getDstMemRefRank()); } // Returns the Tag MemRef for this DMA operation. - Value *getTagMemRef() { + ValuePtr getTagMemRef() { return getOperand(1 + getSrcMemRefRank() + 1 + getDstMemRefRank() + 1); } // Returns the rank (number of indices) of the tag MemRefType. @@ -276,13 +276,13 @@ public: 1 + 1 + getTagMemRefRank(); } - Value *getStride() { + ValuePtr getStride() { if (!isStrided()) return nullptr; return getOperand(getNumOperands() - 1 - 1); } - Value *getNumElementsPerStride() { + ValuePtr getNumElementsPerStride() { if (!isStrided()) return nullptr; return getOperand(getNumOperands() - 1); @@ -307,13 +307,14 @@ class DmaWaitOp public: using Op::Op; - static void build(Builder *builder, OperationState &result, Value *tagMemRef, - ValueRange tagIndices, Value *numElements); + static void build(Builder *builder, OperationState &result, + ValuePtr tagMemRef, ValueRange tagIndices, + ValuePtr numElements); static StringRef getOperationName() { return "std.dma_wait"; } // Returns the Tag MemRef associated with the DMA operation being waited on. - Value *getTagMemRef() { return getOperand(0); } + ValuePtr getTagMemRef() { return getOperand(0); } // Returns the tag memref index for this DMA operation. operand_range getTagIndices() { @@ -327,7 +328,7 @@ public: } // Returns the number of elements transferred in the associated DMA operation. - Value *getNumElements() { return getOperand(1 + getTagMemRefRank()); } + ValuePtr getNumElements() { return getOperand(1 + getTagMemRefRank()); } static ParseResult parse(OpAsmParser &parser, OperationState &result); void print(OpAsmPrinter &p); @@ -342,7 +343,7 @@ void printDimAndSymbolList(Operation::operand_iterator begin, /// Parses dimension and symbol list and returns true if parsing failed. ParseResult parseDimAndSymbolList(OpAsmParser &parser, - SmallVectorImpl &operands, + SmallVectorImpl &operands, unsigned &numDims); raw_ostream &operator<<(raw_ostream &os, SubViewOp::Range &range); diff --git a/mlir/include/mlir/Dialect/StandardOps/Ops.td b/mlir/include/mlir/Dialect/StandardOps/Ops.td index c26baf6a76e..e00674708f6 100644 --- a/mlir/include/mlir/Dialect/StandardOps/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/Ops.td @@ -52,7 +52,7 @@ class CastOp traits = []> : let results = (outs AnyType); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *source, Type destType", [{ + "Builder *builder, OperationState &result, ValuePtr source, Type destType", [{ impl::buildCastOp(builder, result, source, destType); }]>]; @@ -191,7 +191,7 @@ def AllocOp : Std_Op<"alloc"> { }]>, OpBuilder< "Builder *builder, OperationState &result, MemRefType memrefType, " # - "ArrayRef operands, IntegerAttr alignment = IntegerAttr()", [{ + "ArrayRef operands, IntegerAttr alignment = IntegerAttr()", [{ result.addOperands(operands); result.types.push_back(memrefType); if (alignment) @@ -330,7 +330,7 @@ def CallIndirectOp : Std_Op<"call_indirect", [CallOpInterface]> { let results = (outs Variadic); let builders = [OpBuilder< - "Builder *, OperationState &result, Value *callee," + "Builder *, OperationState &result, ValuePtr callee," "ValueRange operands = {}", [{ result.operands.push_back(callee); result.addOperands(operands); @@ -338,7 +338,7 @@ def CallIndirectOp : Std_Op<"call_indirect", [CallOpInterface]> { }]>]; let extraClassDeclaration = [{ - Value *getCallee() { return getOperand(0); } + ValuePtr getCallee() { return getOperand(0); } /// Get the argument operands to the called function. operand_range getArgOperands() { @@ -395,7 +395,7 @@ def CmpFOp : Std_Op<"cmpf", let builders = [OpBuilder< "Builder *builder, OperationState &result, CmpFPredicate predicate," - "Value *lhs, Value *rhs", [{ + "ValuePtr lhs, ValuePtr rhs", [{ ::buildCmpFOp(builder, result, predicate, lhs, rhs); }]>]; @@ -463,7 +463,7 @@ def CmpIOp : Std_Op<"cmpi", let builders = [OpBuilder< "Builder *builder, OperationState &result, CmpIPredicate predicate," - "Value *lhs, Value *rhs", [{ + "ValuePtr lhs, ValuePtr rhs", [{ ::buildCmpIOp(builder, result, predicate, lhs, rhs); }]>]; @@ -502,7 +502,7 @@ def CondBranchOp : Std_Op<"cond_br", [Terminator]> { let arguments = (ins I1:$condition, Variadic:$branchOperands); let builders = [OpBuilder< - "Builder *, OperationState &result, Value *condition," + "Builder *, OperationState &result, ValuePtr condition," "Block *trueDest, ValueRange trueOperands," "Block *falseDest, ValueRange falseOperands", [{ result.addOperands(condition); @@ -518,7 +518,7 @@ def CondBranchOp : Std_Op<"cond_br", [Terminator]> { enum { trueIndex = 0, falseIndex = 1 }; // The condition operand is the first operand in the list. - Value *getCondition() { return getOperand(0); } + ValuePtr getCondition() { return getOperand(0); } /// Return the destination if the condition is true. Block *getTrueDest() { @@ -531,12 +531,12 @@ def CondBranchOp : Std_Op<"cond_br", [Terminator]> { } // Accessors for operands to the 'true' destination. - Value *getTrueOperand(unsigned idx) { + ValuePtr getTrueOperand(unsigned idx) { assert(idx < getNumTrueOperands()); return getOperand(getTrueDestOperandIndex() + idx); } - void setTrueOperand(unsigned idx, Value *value) { + void setTrueOperand(unsigned idx, ValuePtr value) { assert(idx < getNumTrueOperands()); setOperand(getTrueDestOperandIndex() + idx, value); } @@ -561,11 +561,11 @@ def CondBranchOp : Std_Op<"cond_br", [Terminator]> { } // Accessors for operands to the 'false' destination. - Value *getFalseOperand(unsigned idx) { + ValuePtr getFalseOperand(unsigned idx) { assert(idx < getNumFalseOperands()); return getOperand(getFalseDestOperandIndex() + idx); } - void setFalseOperand(unsigned idx, Value *value) { + void setFalseOperand(unsigned idx, ValuePtr value) { assert(idx < getNumFalseOperands()); setOperand(getFalseDestOperandIndex() + idx, value); } @@ -678,7 +678,7 @@ def DimOp : Std_Op<"dim", [NoSideEffect]> { let results = (outs Index); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *memrefOrTensor," + "Builder *builder, OperationState &result, ValuePtr memrefOrTensor," "unsigned index", [{ auto indexType = builder->getIndexType(); auto indexAttr = builder->getIntegerAttr(indexType, index); @@ -730,7 +730,7 @@ def ExtractElementOp : Std_Op<"extract_element", [NoSideEffect]> { let results = (outs AnyType); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *aggregate," + "Builder *builder, OperationState &result, ValuePtr aggregate," "ValueRange indices = {}", [{ auto resType = aggregate->getType().cast() .getElementType(); @@ -738,7 +738,7 @@ def ExtractElementOp : Std_Op<"extract_element", [NoSideEffect]> { }]>]; let extraClassDeclaration = [{ - Value *getAggregate() { return getOperand(0); } + ValuePtr getAggregate() { return getOperand(0); } operand_range getIndices() { return {operand_begin() + 1, operand_end()}; @@ -816,7 +816,7 @@ def LoadOp : Std_Op<"load"> { let results = (outs AnyType); let builders = [OpBuilder< - "Builder *, OperationState &result, Value *memref," + "Builder *, OperationState &result, ValuePtr memref," "ValueRange indices = {}", [{ auto memrefType = memref->getType().cast(); result.addOperands(memref); @@ -825,8 +825,8 @@ def LoadOp : Std_Op<"load"> { }]>]; let extraClassDeclaration = [{ - Value *getMemRef() { return getOperand(0); } - void setMemRef(Value *value) { setOperand(0, value); } + ValuePtr getMemRef() { return getOperand(0); } + void setMemRef(ValuePtr value) { setOperand(0, value); } MemRefType getMemRefType() { return getMemRef()->getType().cast(); } @@ -952,8 +952,8 @@ def PrefetchOp : Std_Op<"prefetch"> { BoolAttr:$isDataCache); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *memref," - "ArrayRef indices, bool isWrite, unsigned hint, bool isData", + "Builder *builder, OperationState &result, ValuePtr memref," + "ArrayRef indices, bool isWrite, unsigned hint, bool isData", [{ auto hintAttr = builder->getI32IntegerAttr(hint); auto isWriteAttr = builder->getBoolAttr(isWrite); @@ -990,7 +990,7 @@ def RankOp : Std_Op<"rank", [NoSideEffect]> { let verifier = ?; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *tensor", [{ + "Builder *builder, OperationState &result, ValuePtr tensor", [{ auto indexType = builder->getIndexType(); build(builder, result, indexType, tensor); }]>]; @@ -1052,16 +1052,16 @@ def SelectOp : Std_Op<"select", [NoSideEffect, SameOperandsAndResultShape]> { let results = (outs AnyType); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *condition," - "Value *trueValue, Value *falseValue", [{ + "Builder *builder, OperationState &result, ValuePtr condition," + "ValuePtr trueValue, ValuePtr falseValue", [{ result.addOperands({condition, trueValue, falseValue}); result.addTypes(trueValue->getType()); }]>]; let extraClassDeclaration = [{ - Value *getCondition() { return condition(); } - Value *getTrueValue() { return true_value(); } - Value *getFalseValue() { return false_value(); } + ValuePtr getCondition() { return condition(); } + ValuePtr getTrueValue() { return true_value(); } + ValuePtr getFalseValue() { return false_value(); } }]; let hasFolder = 1; @@ -1089,7 +1089,7 @@ def SignExtendIOp : Std_Op<"sexti", let results = (outs IntegerLike); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *value, Type destType", [{ + "Builder *builder, OperationState &result, ValuePtr value, Type destType", [{ result.addOperands(value); result.addTypes(destType); }]>]; @@ -1189,7 +1189,7 @@ def SplatOp : Std_Op<"splat", [NoSideEffect]> { let results = (outs AnyTypeOf<[AnyVector, AnyStaticShapeTensor]>:$aggregate); let builders = - [OpBuilder<"Builder *builder, OperationState &result, Value *element, " + [OpBuilder<"Builder *builder, OperationState &result, ValuePtr element, " "Type aggregateType", [{ build(builder, result, aggregateType, element); }]>]; @@ -1213,16 +1213,16 @@ def StoreOp : Std_Op<"store"> { Variadic:$indices); let builders = [OpBuilder< - "Builder *, OperationState &result, Value *valueToStore, Value *memref", [{ + "Builder *, OperationState &result, ValuePtr valueToStore, ValuePtr memref", [{ result.addOperands(valueToStore); result.addOperands(memref); }]>]; let extraClassDeclaration = [{ - Value *getValueToStore() { return getOperand(0); } + ValuePtr getValueToStore() { return getOperand(0); } - Value *getMemRef() { return getOperand(1); } - void setMemRef(Value *value) { setOperand(1, value); } + ValuePtr getMemRef() { return getOperand(1); } + void setMemRef(ValuePtr value) { setOperand(1, value); } MemRefType getMemRefType() { return getMemRef()->getType().cast(); } @@ -1364,13 +1364,13 @@ def SubViewOp : Std_Op<"subview", [AttrSizedOperandSegments, NoSideEffect]> { let builders = [ OpBuilder< - "Builder *b, OperationState &result, Value *source, " + "Builder *b, OperationState &result, ValuePtr source, " "ValueRange offsets, ValueRange sizes, " "ValueRange strides, Type resultType = Type(), " "ArrayRef attrs = {}">, OpBuilder< "Builder *builder, OperationState &result, " - "Type resultType, Value *source"> + "Type resultType, ValuePtr source"> ]; let extraClassDeclaration = [{ @@ -1403,7 +1403,7 @@ def SubViewOp : Std_Op<"subview", [AttrSizedOperandSegments, NoSideEffect]> { // offset, size and stride operands of the SubViewOp into a list of triples. // Such a list of triple is sometimes more convenient to manipulate. struct Range { - Value *offset, *size, *stride; + ValuePtr offset, size, stride; }; SmallVector getRanges(); }]; @@ -1465,7 +1465,7 @@ def TensorLoadOp : Std_Op<"tensor_load", let verifier = ?; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *memref", [{ + "Builder *builder, OperationState &result, ValuePtr memref", [{ auto memrefType = memref->getType().cast(); auto resultType = RankedTensorType::get(memrefType.getShape(), memrefType.getElementType()); @@ -1519,7 +1519,7 @@ def TruncateIOp : Std_Op<"trunci", [NoSideEffect, SameOperandsAndResultShape]> { let results = (outs IntegerLike); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *value, Type destType", [{ + "Builder *builder, OperationState &result, ValuePtr value, Type destType", [{ result.addOperands(value); result.addTypes(destType); }]>]; @@ -1578,7 +1578,7 @@ def ViewOp : Std_Op<"view", [NoSideEffect]> { /// Returns the dynamic offset for this view operation if specified. /// Returns nullptr if no dynamic offset was specified. - Value *getDynamicOffset(); + ValuePtr getDynamicOffset(); /// Returns the starting operand list position of the dynamic size operands. unsigned getDynamicSizesOperandStart() { @@ -1619,7 +1619,7 @@ def ZeroExtendIOp : Std_Op<"zexti", [NoSideEffect, SameOperandsAndResultShape]> let results = (outs IntegerLike); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *value, Type destType", [{ + "Builder *builder, OperationState &result, ValuePtr value, Type destType", [{ result.addOperands(value); result.addTypes(destType); }]>]; diff --git a/mlir/include/mlir/Dialect/VectorOps/Utils.h b/mlir/include/mlir/Dialect/VectorOps/Utils.h index f61a813855d..68c62cc7ec7 100644 --- a/mlir/include/mlir/Dialect/VectorOps/Utils.h +++ b/mlir/include/mlir/Dialect/VectorOps/Utils.h @@ -34,6 +34,9 @@ class Operation; class Value; class VectorType; +// TODO(riverriddle) Remove this after Value is value-typed. +using ValuePtr = Value *; + /// Computes and returns the multi-dimensional ratio of `superShape` to /// `subShape`. This is calculated by performing a traversal from minor to major /// dimensions (i.e. in reverse shape order). If integral division is not @@ -122,7 +125,7 @@ Optional> shapeRatio(VectorType superVectorType, /// `%arg0[%c0, %c0]` into vector<128xf32> which needs a 1-D vector broadcast. /// AffineMap -makePermutationMap(Operation *op, ArrayRef indices, +makePermutationMap(Operation *op, ArrayRef indices, const DenseMap &loopToVectorDim); namespace matcher { diff --git a/mlir/include/mlir/Dialect/VectorOps/VectorOps.td b/mlir/include/mlir/Dialect/VectorOps/VectorOps.td index 5fd19498350..94262e6f1ff 100644 --- a/mlir/include/mlir/Dialect/VectorOps/VectorOps.td +++ b/mlir/include/mlir/Dialect/VectorOps/VectorOps.td @@ -128,8 +128,8 @@ def Vector_ContractionOp : : vector<7x8x16x15xf32>, vector<8x16x7x5xf32> into vector<8x15x8x5xf32> }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *lhs, Value *rhs, " - "Value *acc, ArrayAttr indexingMaps, ArrayAttr iteratorTypes">]; + "Builder *builder, OperationState &result, ValuePtr lhs, ValuePtr rhs, " + "ValuePtr acc, ArrayAttr indexingMaps, ArrayAttr iteratorTypes">]; let extraClassDeclaration = [{ VectorType getLhsType() { return lhs()->getType().cast(); @@ -252,7 +252,8 @@ def Vector_ShuffleOp : ``` }]; - let builders = [OpBuilder<"Builder *builder, OperationState &result, Value *v1, Value *v2, ArrayRef">]; + let builders = [OpBuilder<"Builder *builder, OperationState &result," + "ValuePtr v1, ValuePtr v2, ArrayRef">]; let extraClassDeclaration = [{ static StringRef getMaskAttrName() { return "mask"; } VectorType getV1VectorType() { @@ -312,7 +313,8 @@ def Vector_ExtractOp : ``` }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *source, ArrayRef">]; + "Builder *builder, OperationState &result, ValuePtr source," + "ArrayRef">]; let extraClassDeclaration = [{ static StringRef getPositionAttrName() { return "position"; } VectorType getVectorType() { @@ -357,7 +359,7 @@ def Vector_ExtractSlicesOp : }]; let builders = [OpBuilder< "Builder *builder, OperationState &result, TupleType tupleType, " # - "Value *vector, ArrayRef sizes, " # + "ValuePtr vector, ArrayRef sizes, " # "ArrayRef strides">]; let extraClassDeclaration = [{ VectorType getSourceVectorType() { @@ -428,8 +430,8 @@ def Vector_InsertOp : ``` }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *source, " # - "Value *dest, ArrayRef">]; + "Builder *builder, OperationState &result, ValuePtr source, " # + "ValuePtr dest, ArrayRef">]; let extraClassDeclaration = [{ static StringRef getPositionAttrName() { return "position"; } Type getSourceType() { return source()->getType(); } @@ -521,7 +523,7 @@ def Vector_InsertStridedSliceOp : ``` }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *source, Value *dest, " # + "Builder *builder, OperationState &result, ValuePtr source, ValuePtr dest, " # "ArrayRef offsets, ArrayRef strides">]; let extraClassDeclaration = [{ static StringRef getOffsetsAttrName() { return "offsets"; } @@ -723,7 +725,7 @@ def Vector_StridedSliceOp : vector<4x8x16xf32> to vector<2x4x16xf32> }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *source, " # + "Builder *builder, OperationState &result, ValuePtr source, " # "ArrayRef offsets, ArrayRef sizes, " # "ArrayRef strides">]; let extraClassDeclaration = [{ @@ -975,7 +977,7 @@ def Vector_TypeCastOp : }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value *source">]; + "Builder *builder, OperationState &result, ValuePtr source">]; let parser = [{ return impl::parseCastOp(parser, result); diff --git a/mlir/include/mlir/Dialect/VectorOps/VectorTransforms.h b/mlir/include/mlir/Dialect/VectorOps/VectorTransforms.h index 2c2e4e7c4fa..b48cb51533f 100644 --- a/mlir/include/mlir/Dialect/VectorOps/VectorTransforms.h +++ b/mlir/include/mlir/Dialect/VectorOps/VectorTransforms.h @@ -73,8 +73,9 @@ namespace vector { // // This will be extended in the future to support more advanced use cases than // simple pointwise ops. -Value *unrollSingleResultOpMatchingType(PatternRewriter &builder, Operation *op, - ArrayRef targetShape); +ValuePtr unrollSingleResultOpMatchingType(PatternRewriter &builder, + Operation *op, + ArrayRef targetShape); } // namespace vector } // namespace mlir diff --git a/mlir/include/mlir/EDSC/Builders.h b/mlir/include/mlir/EDSC/Builders.h index 69c72a50870..11ee0bff342 100644 --- a/mlir/include/mlir/EDSC/Builders.h +++ b/mlir/include/mlir/EDSC/Builders.h @@ -152,7 +152,7 @@ private: /// A LoopBuilder is a generic NestedBuilder for loop-like MLIR operations. /// More specifically it is meant to be used as a temporary object for -/// representing any nested MLIR construct that is "related to" an mlir::Value* +/// representing any nested MLIR construct that is "related to" an mlir::Value /// (for now an induction variable). /// This is extensible and will evolve in the future as MLIR evolves, hence /// the name LoopBuilder (as opposed to say ForBuilder or AffineForBuilder). @@ -242,7 +242,7 @@ class Append {}; /// A BlockBuilder is a NestedBuilder for mlir::Block*. /// This exists by opposition to LoopBuilder which is not related to an -/// mlir::Block* but to a mlir::Value*. +/// mlir::Block* but to a mlir::Value. /// It is meant to be used as a temporary object for representing any nested /// MLIR construct that is "related to" an mlir::Block*. class BlockBuilder : public NestedBuilder { @@ -257,7 +257,7 @@ public: /// /// Prerequisites: /// The ValueHandle `args` are typed delayed ValueHandles; i.e. they are - /// not yet bound to mlir::Value*. + /// not yet bound to mlir::Value. BlockBuilder(BlockHandle *bh, ArrayRef args); /// The only purpose of this operator is to serve as a sequence point so that @@ -291,10 +291,10 @@ protected: /// typed "delayed" value that can be hold a Value in the future; /// 3. constructed state,in which case it holds a Value. /// -/// A ValueHandle is meant to capture a single Value* and should be used for +/// A ValueHandle is meant to capture a single Value and should be used for /// operations that have a single result. For convenience of use, we also /// include AffineForOp in this category although it does not return a value. -/// In the case of AffineForOp, the captured Value* is the loop induction +/// In the case of AffineForOp, the captured Value is the loop induction /// variable. class ValueHandle : public CapturableHandle { public: @@ -304,15 +304,15 @@ public: /// A ValueHandle that is constructed from a Type represents a typed "delayed" /// Value. A delayed Value can only capture Values of the specified type. /// Such a delayed value represents the declaration (in the PL sense) of a - /// placeholder for an mlir::Value* that will be constructed and captured at + /// placeholder for an mlir::Value that will be constructed and captured at /// some later point in the program. explicit ValueHandle(Type t) : t(t), v(nullptr) {} - /// A ValueHandle that is constructed from an mlir::Value* is an "eager" + /// A ValueHandle that is constructed from an mlir::Value is an "eager" /// Value. An eager Value represents both the declaration and the definition - /// (in the PL sense) of a placeholder for an mlir::Value* that has already + /// (in the PL sense) of a placeholder for an mlir::Value that has already /// been constructed in the past and that is captured "now" in the program. - explicit ValueHandle(Value *v) : t(v->getType()), v(v) {} + explicit ValueHandle(ValuePtr v) : t(v->getType()), v(v) {} /// Builds a ConstantIndexOp of value `cst`. The constant is created at the /// current insertion point. @@ -336,8 +336,8 @@ public: std::swap(v, other.v); } - /// Implicit conversion useful for automatic conversion to Container. - operator Value *() const { return getValue(); } + /// Implicit conversion useful for automatic conversion to Container. + operator ValuePtr() const { return getValue(); } /// Generic mlir::Op create. This is the key to being extensible to the whole /// of MLIR without duplicating the type system or the op definitions. @@ -355,7 +355,7 @@ public: /// Special case to build composed AffineApply operations. // TODO: createOrFold when available and move inside of the `create` method. static ValueHandle createComposedAffineApply(AffineMap map, - ArrayRef operands); + ArrayRef operands); /// Generic create for a named operation producing a single value. static ValueHandle create(StringRef name, ArrayRef operands, @@ -363,7 +363,7 @@ public: ArrayRef attributes = {}); bool hasValue() const { return v != nullptr; } - Value *getValue() const { + ValuePtr getValue() const { assert(hasValue() && "Unexpected null value;"); return v; } @@ -380,12 +380,12 @@ protected: ValueHandle() : t(), v(nullptr) {} Type t; - Value *v; + ValuePtr v; }; /// An OperationHandle can be used in lieu of ValueHandle to capture the /// operation in cases when one does not care about, or cannot extract, a -/// unique Value* from the operation. +/// unique Value from the operation. /// This can be used for capturing zero result operations as well as /// multi-result operations that are not supported by ValueHandle. /// We do not distinguish further between zero and multi-result operations at @@ -529,7 +529,7 @@ ValueHandle operator>=(ValueHandle lhs, ValueHandle rhs); } // namespace op -/// Entry point to build multiple ValueHandle from a `Container` of Value* or +/// Entry point to build multiple ValueHandle from a `Container` of Value or /// Type. template inline SmallVector makeValueHandles(Container values) { diff --git a/mlir/include/mlir/EDSC/Helpers.h b/mlir/include/mlir/EDSC/Helpers.h index 423c92b2d06..c18307e7121 100644 --- a/mlir/include/mlir/EDSC/Helpers.h +++ b/mlir/include/mlir/EDSC/Helpers.h @@ -75,7 +75,7 @@ protected: // TODO(ntv): Support MemRefs with layoutMaps. class MemRefView : public View { public: - explicit MemRefView(Value *v); + explicit MemRefView(ValuePtr v); MemRefView(const MemRefView &) = default; MemRefView &operator=(const MemRefView &) = default; @@ -91,7 +91,7 @@ private: /// a MemRefView but for vectors. This exists purely for boilerplate avoidance. class VectorView : public View { public: - explicit VectorView(Value *v); + explicit VectorView(ValuePtr v); VectorView(const VectorView &) = default; VectorView &operator=(const VectorView &) = default; @@ -120,7 +120,7 @@ private: template class TemplatedIndexedValue { public: explicit TemplatedIndexedValue(Type t) : base(t) {} - explicit TemplatedIndexedValue(Value *v) + explicit TemplatedIndexedValue(ValuePtr v) : TemplatedIndexedValue(ValueHandle(v)) {} explicit TemplatedIndexedValue(ValueHandle v) : base(v) {} @@ -161,8 +161,8 @@ public: return Load(getBase(), {indices.begin(), indices.end()}); } - /// Emits a `load` when converting to a Value*. - Value *operator*(void)const { + /// Emits a `load` when converting to a Value. + ValuePtr operator*(void) const { return Load(getBase(), {indices.begin(), indices.end()}).getValue(); } diff --git a/mlir/include/mlir/EDSC/Intrinsics.h b/mlir/include/mlir/EDSC/Intrinsics.h index 06c75505cb7..dc0c1186c7a 100644 --- a/mlir/include/mlir/EDSC/Intrinsics.h +++ b/mlir/include/mlir/EDSC/Intrinsics.h @@ -44,7 +44,7 @@ struct IndexHandle : public ValueHandle { explicit IndexHandle() : ValueHandle(ScopedContext::getBuilder().getIndexType()) {} explicit IndexHandle(index_t v) : ValueHandle(v) {} - explicit IndexHandle(Value *v) : ValueHandle(v) { + explicit IndexHandle(ValuePtr v) : ValueHandle(v) { assert(v->getType() == ScopedContext::getBuilder().getIndexType() && "Expected index type"); } @@ -79,9 +79,9 @@ makeHandlePointers(MutableArrayRef ivs) { return pivs; } -/// Returns a vector of the underlying Value* from `ivs`. -inline SmallVector extractValues(ArrayRef ivs) { - SmallVector vals; +/// Returns a vector of the underlying Value from `ivs`. +inline SmallVector extractValues(ArrayRef ivs) { + SmallVector vals; vals.reserve(ivs.size()); for (auto &iv : ivs) { vals.push_back(iv.getValue()); @@ -96,7 +96,7 @@ namespace intrinsics { namespace detail { /// Helper structure to be used with ValueBuilder / OperationBuilder. /// It serves the purpose of removing boilerplate specialization for the sole -/// purpose of implicitly converting ArrayRef -> ArrayRef. +/// purpose of implicitly converting ArrayRef -> ArrayRef. class ValueHandleArray { public: ValueHandleArray(ArrayRef vals) { @@ -109,11 +109,11 @@ public: SmallVector tmp(vals.begin(), vals.end()); values.append(tmp.begin(), tmp.end()); } - operator ArrayRef() { return values; } + operator ArrayRef() { return values; } private: ValueHandleArray() = default; - SmallVector values; + SmallVector values; }; template inline T unpack(T value) { return value; } @@ -128,8 +128,8 @@ inline detail::ValueHandleArray unpack(ArrayRef values) { /// boilerplate or Tablegen. /// Arguably a builder is not a ValueHandle but in practice it is only used as /// an alias to a notional ValueHandle. -/// Implementing it as a subclass allows it to compose all the way to Value*. -/// Without subclassing, implicit conversion to Value* would fail when composing +/// Implementing it as a subclass allows it to compose all the way to Value. +/// Without subclassing, implicit conversion to Value would fail when composing /// in patterns such as: `select(a, b, select(c, d, e))`. template struct ValueBuilder : public ValueHandle { // Builder-based @@ -238,8 +238,8 @@ OperationHandle br(BlockHandle bh, ArrayRef operands); /// /// Prerequisites: /// `b` has not yet captured an mlir::Block*. -/// No `captures` have captured any mlir::Value*. -/// All `operands` have already captured an mlir::Value* +/// No `captures` have captured any mlir::Value. +/// All `operands` have already captured an mlir::Value /// captures.size() == operands.size() /// captures and operands are pairwise of the same type. OperationHandle br(BlockHandle *bh, ArrayRef captures, @@ -266,8 +266,8 @@ OperationHandle cond_br(ValueHandle cond, BlockHandle trueBranch, /// /// Prerequisites: /// `trueBranch`/`falseBranch` has not yet captured an mlir::Block*. -/// No `trueCaptures`/`falseCaptures` have captured any mlir::Value*. -/// All `trueOperands`/`trueOperands` have already captured an mlir::Value* +/// No `trueCaptures`/`falseCaptures` have captured any mlir::Value. +/// All `trueOperands`/`trueOperands` have already captured an mlir::Value /// `trueCaptures`.size() == `trueOperands`.size() /// `falseCaptures`.size() == `falseOperands`.size() /// `trueCaptures` and `trueOperands` are pairwise of the same type diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h index 6c5099b06da..87c77160e1d 100644 --- a/mlir/include/mlir/IR/Block.h +++ b/mlir/include/mlir/IR/Block.h @@ -72,7 +72,7 @@ public: //===--------------------------------------------------------------------===// // This is the list of arguments to the block. - using BlockArgListType = ArrayRef; + using BlockArgListType = ArrayRef; BlockArgListType getArguments() { return arguments; } @@ -86,7 +86,7 @@ public: bool args_empty() { return arguments.empty(); } /// Add one value to the argument list. - BlockArgument *addArgument(Type type); + BlockArgumentPtr addArgument(Type type); /// Add one argument to the argument list for each type specified in the list. iterator_range addArguments(ArrayRef types); @@ -97,7 +97,7 @@ public: void eraseArgument(unsigned index, bool updatePredTerms = true); unsigned getNumArguments() { return arguments.size(); } - BlockArgument *getArgument(unsigned i) { return arguments[i]; } + BlockArgumentPtr getArgument(unsigned i) { return arguments[i]; } //===--------------------------------------------------------------------===// // Operation list management @@ -332,7 +332,7 @@ private: OpListType operations; /// This is the list of arguments to the block. - std::vector arguments; + std::vector arguments; Block(Block &) = delete; void operator=(Block &) = delete; diff --git a/mlir/include/mlir/IR/BlockAndValueMapping.h b/mlir/include/mlir/IR/BlockAndValueMapping.h index cd15d457a77..287dd508fa6 100644 --- a/mlir/include/mlir/IR/BlockAndValueMapping.h +++ b/mlir/include/mlir/IR/BlockAndValueMapping.h @@ -37,7 +37,7 @@ public: /// Inserts a new mapping for 'from' to 'to'. If there is an existing mapping, /// it is overwritten. void map(Block *from, Block *to) { valueMap[from] = to; } - void map(Value *from, Value *to) { valueMap[from] = to; } + void map(ValuePtr from, ValuePtr to) { valueMap[from] = to; } /// Erases a mapping for 'from'. void erase(IRObjectWithUseList *from) { valueMap.erase(from); } @@ -52,8 +52,8 @@ public: Block *lookupOrNull(Block *from) const { return lookupOrValue(from, (Block *)nullptr); } - Value *lookupOrNull(Value *from) const { - return lookupOrValue(from, (Value *)nullptr); + ValuePtr lookupOrNull(ValuePtr from) const { + return lookupOrValue(from, (ValuePtr) nullptr); } /// Lookup a mapped value within the map. If a mapping for the provided value @@ -61,7 +61,7 @@ public: Block *lookupOrDefault(Block *from) const { return lookupOrValue(from, from); } - Value *lookupOrDefault(Value *from) const { + ValuePtr lookupOrDefault(ValuePtr from) const { return lookupOrValue(from, from); } diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h index 766902fabfa..c199c09feb5 100644 --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -313,7 +313,7 @@ public: /// and immediately try to fold it. This functions populates 'results' with /// the results after folding the operation. template - void createOrFold(SmallVectorImpl &results, Location location, + void createOrFold(SmallVectorImpl &results, Location location, Args &&... args) { // Create the operation without using 'createOperation' as we don't want to // insert it yet. @@ -331,9 +331,9 @@ public: /// Overload to create or fold a single result operation. template typename std::enable_if(), - Value *>::type + ValuePtr>::type createOrFold(Location location, Args &&... args) { - SmallVector results; + SmallVector results; createOrFold(results, location, std::forward(args)...); return results.front(); } @@ -344,7 +344,7 @@ public: OpTy>::type createOrFold(Location location, Args &&... args) { auto op = create(location, std::forward(args)...); - SmallVector unused; + SmallVector unused; tryFold(op.getOperation(), unused); // Folding cannot remove a zero-result operation, so for convenience we @@ -355,7 +355,7 @@ public: /// Attempts to fold the given operation and places new results within /// 'results'. Returns success if the operation was folded, failure otherwise. /// Note: This function does not erase the operation on a successful fold. - LogicalResult tryFold(Operation *op, SmallVectorImpl &results); + LogicalResult tryFold(Operation *op, SmallVectorImpl &results); /// Creates a deep copy of the specified operation, remapping any operands /// that use values outside of the operation using the map that is provided diff --git a/mlir/include/mlir/IR/FunctionSupport.h b/mlir/include/mlir/IR/FunctionSupport.h index b15b056a3ec..1ba85d73df9 100644 --- a/mlir/include/mlir/IR/FunctionSupport.h +++ b/mlir/include/mlir/IR/FunctionSupport.h @@ -183,7 +183,7 @@ public: } /// Gets argument. - BlockArgument *getArgument(unsigned idx) { + BlockArgumentPtr getArgument(unsigned idx) { return getBlocks().front().getArgument(idx); } diff --git a/mlir/include/mlir/IR/Matchers.h b/mlir/include/mlir/IR/Matchers.h index 1261916dae2..3b36f2fb5eb 100644 --- a/mlir/include/mlir/IR/Matchers.h +++ b/mlir/include/mlir/IR/Matchers.h @@ -142,7 +142,7 @@ using has_operation_or_value_matcher_t = /// Statically switch to a Value matcher. template typename std::enable_if_t::value, + MatcherClass, ValuePtr>::value, bool> matchOperandOrValueAtIndex(Operation *op, unsigned idx, MatcherClass &matcher) { return matcher.match(op->getOperand(idx)); @@ -161,14 +161,14 @@ matchOperandOrValueAtIndex(Operation *op, unsigned idx, MatcherClass &matcher) { /// Terminal matcher, always returns true. struct AnyValueMatcher { - bool match(Value *op) const { return true; } + bool match(ValuePtr op) const { return true; } }; /// Binds to a specific value and matches it. struct PatternMatcherValue { - PatternMatcherValue(Value *val) : value(val) {} - bool match(Value *val) const { return val == value; } - Value *value; + PatternMatcherValue(ValuePtr val) : value(val) {} + bool match(ValuePtr val) const { return val == value; } + ValuePtr value; }; template @@ -235,7 +235,7 @@ inline detail::constant_int_not_value_matcher<0> m_NonZero() { /// Entry point for matching a pattern over a Value. template -inline bool matchPattern(Value *value, const Pattern &pattern) { +inline bool matchPattern(ValuePtr value, const Pattern &pattern) { // TODO: handle other cases if (auto *op = value->getDefiningOp()) return const_cast(pattern).match(op); @@ -262,7 +262,7 @@ auto m_Op(Matchers... matchers) { namespace matchers { inline auto m_Any() { return detail::AnyValueMatcher(); } -inline auto m_Val(Value *v) { return detail::PatternMatcherValue(v); } +inline auto m_Val(ValuePtr v) { return detail::PatternMatcherValue(v); } } // namespace matchers } // end namespace mlir diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index c220120b337..437540117c4 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -257,8 +257,8 @@ inline bool operator!=(OpState lhs, OpState rhs) { } /// This class represents a single result from folding an operation. -class OpFoldResult : public PointerUnion { - using PointerUnion::PointerUnion; +class OpFoldResult : public PointerUnion { + using PointerUnion::PointerUnion; }; /// This template defines the foldHook as used by AbstractOperation. @@ -311,8 +311,8 @@ class FoldingHook::type> { public: /// If the operation returns a single value, then the Op can be implicitly - /// converted to an Value*. This yields the value of the only result. - operator Value *() { + /// converted to an Value. This yields the value of the only result. + operator ValuePtr() { return static_cast(this)->getOperation()->getResult(0); } @@ -326,7 +326,7 @@ public: // Check if the operation was folded in place. In this case, the operation // returns itself. - if (result.template dyn_cast() != op->getResult(0)) + if (result.template dyn_cast() != op->getResult(0)) results.push_back(result); return success(); } @@ -428,10 +428,12 @@ struct MultiOperandTraitBase : public TraitBase { unsigned getNumOperands() { return this->getOperation()->getNumOperands(); } /// Return the operand at index 'i'. - Value *getOperand(unsigned i) { return this->getOperation()->getOperand(i); } + ValuePtr getOperand(unsigned i) { + return this->getOperation()->getOperand(i); + } /// Set the operand at index 'i' to 'value'. - void setOperand(unsigned i, Value *value) { + void setOperand(unsigned i, ValuePtr value) { this->getOperation()->setOperand(i, value); } @@ -475,9 +477,11 @@ private: template class OneOperand : public TraitBase { public: - Value *getOperand() { return this->getOperation()->getOperand(0); } + ValuePtr getOperand() { return this->getOperation()->getOperand(0); } - void setOperand(Value *value) { this->getOperation()->setOperand(0, value); } + void setOperand(ValuePtr value) { + this->getOperation()->setOperand(0, value); + } static LogicalResult verifyTrait(Operation *op) { return impl::verifyOneOperand(op); @@ -550,7 +554,7 @@ struct MultiResultTraitBase : public TraitBase { unsigned getNumResults() { return this->getOperation()->getNumResults(); } /// Return the result at index 'i'. - Value *getResult(unsigned i) { return this->getOperation()->getResult(i); } + ValuePtr getResult(unsigned i) { return this->getOperation()->getResult(i); } /// Replace all uses of results of this operation with the provided 'values'. /// 'values' may correspond to an existing operation, or a range of 'Value'. @@ -586,13 +590,13 @@ struct MultiResultTraitBase : public TraitBase { template class OneResult : public TraitBase { public: - Value *getResult() { return this->getOperation()->getResult(0); } + ValuePtr getResult() { return this->getOperation()->getResult(0); } Type getType() { return getResult()->getType(); } /// Replace all uses of 'this' value with the new value, updating anything in /// the IR that uses 'this' to use the other value instead. When this returns /// there are zero uses of 'this'. - void replaceAllUsesWith(Value *newValue) { + void replaceAllUsesWith(ValuePtr newValue) { getResult()->replaceAllUsesWith(newValue); } @@ -820,10 +824,10 @@ public: return this->getOperation()->setSuccessor(block, index); } - void addSuccessorOperand(unsigned index, Value *value) { + void addSuccessorOperand(unsigned index, ValuePtr value) { return this->getOperation()->addSuccessorOperand(index, value); } - void addSuccessorOperands(unsigned index, ArrayRef values) { + void addSuccessorOperands(unsigned index, ArrayRef values) { return this->getOperation()->addSuccessorOperand(index, values); } }; @@ -1209,8 +1213,8 @@ namespace impl { ParseResult parseOneResultOneOperandTypeOp(OpAsmParser &parser, OperationState &result); -void buildBinaryOp(Builder *builder, OperationState &result, Value *lhs, - Value *rhs); +void buildBinaryOp(Builder *builder, OperationState &result, ValuePtr lhs, + ValuePtr rhs); ParseResult parseOneResultSameOperandTypeOp(OpAsmParser &parser, OperationState &result); @@ -1223,11 +1227,11 @@ void printOneResultOp(Operation *op, OpAsmPrinter &p); // These functions are out-of-line implementations of the methods in CastOp, // which avoids them being template instantiated/duplicated. namespace impl { -void buildCastOp(Builder *builder, OperationState &result, Value *source, +void buildCastOp(Builder *builder, OperationState &result, ValuePtr source, Type destType); ParseResult parseCastOp(OpAsmParser &parser, OperationState &result); void printCastOp(Operation *op, OpAsmPrinter &p); -Value *foldCastOp(Operation *op); +ValuePtr foldCastOp(Operation *op); } // namespace impl } // end namespace mlir diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h index 7dd11d089c2..fcadce9ab16 100644 --- a/mlir/include/mlir/IR/OpImplementation.h +++ b/mlir/include/mlir/IR/OpImplementation.h @@ -45,7 +45,7 @@ public: virtual raw_ostream &getStream() const = 0; /// Print implementations for various things an operation contains. - virtual void printOperand(Value *value) = 0; + virtual void printOperand(ValuePtr value) = 0; /// Print a comma separated list of operands. template @@ -121,7 +121,7 @@ public: void printFunctionalType(Operation *op) { auto &os = getStream(); os << "("; - interleaveComma(op->getNonSuccessorOperands(), os, [&](Value *operand) { + interleaveComma(op->getNonSuccessorOperands(), os, [&](ValuePtr operand) { if (operand) printType(operand->getType()); else @@ -150,18 +150,18 @@ private: }; // Make the implementations convenient to use. -inline OpAsmPrinter &operator<<(OpAsmPrinter &p, Value &value) { +inline OpAsmPrinter &operator<<(OpAsmPrinter &p, ValueRef value) { p.printOperand(&value); return p; } -inline OpAsmPrinter &operator<<(OpAsmPrinter &p, Value *value) { +inline OpAsmPrinter &operator<<(OpAsmPrinter &p, ValuePtr value) { return p << *value; } -template ::value && - !std::is_convertible::value, - T>::type * = nullptr> +template ::value && + !std::is_convertible::value, + T>::type * = nullptr> inline OpAsmPrinter &operator<<(OpAsmPrinter &p, const T &values) { p.printOperands(values); return p; @@ -181,8 +181,8 @@ inline OpAsmPrinter &operator<<(OpAsmPrinter &p, Attribute attr) { // even if it isn't exactly one of them. For example, we want to print // FunctionType with the Type version above, not have it match this. template ::value && - !std::is_convertible::value && + !std::is_convertible::value && + !std::is_convertible::value && !std::is_convertible::value && !std::is_convertible::value && !std::is_convertible::value && @@ -467,13 +467,13 @@ public: /// Resolve an operand to an SSA value, emitting an error on failure. virtual ParseResult resolveOperand(const OperandType &operand, Type type, - SmallVectorImpl &result) = 0; + SmallVectorImpl &result) = 0; /// Resolve a list of operands to SSA values, emitting an error on failure, or /// appending the results to the list on success. This method should be used /// when all operands have the same type. ParseResult resolveOperands(ArrayRef operands, Type type, - SmallVectorImpl &result) { + SmallVectorImpl &result) { for (auto elt : operands) if (resolveOperand(elt, type, result)) return failure(); @@ -485,7 +485,7 @@ public: /// to the list on success. ParseResult resolveOperands(ArrayRef operands, ArrayRef types, llvm::SMLoc loc, - SmallVectorImpl &result) { + SmallVectorImpl &result) { if (operands.size() != types.size()) return emitError(loc) << operands.size() << " operands present, but expected " @@ -556,7 +556,7 @@ public: /// Parse a single operation successor and its operand list. virtual ParseResult parseSuccessorAndUseList(Block *&dest, - SmallVectorImpl &operands) = 0; + SmallVectorImpl &operands) = 0; //===--------------------------------------------------------------------===// // Type Parsing @@ -634,7 +634,7 @@ private: /// A functor used to set the name of the start of a result group of an /// operation. See 'getAsmResultNames' below for more details. -using OpAsmSetValueNameFn = function_ref; +using OpAsmSetValueNameFn = function_ref; class OpAsmDialectInterface : public DialectInterface::Base { diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index 2159d10fd2a..ad0dc600f8f 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -44,7 +44,7 @@ public: /// Create a new Operation with the specific fields. static Operation *create(Location location, OperationName name, ArrayRef resultTypes, - ArrayRef operands, + ArrayRef operands, ArrayRef attributes, ArrayRef successors, unsigned numRegions, bool resizableOperandList); @@ -53,7 +53,7 @@ public: /// unnecessarily uniquing a list of attributes. static Operation *create(Location location, OperationName name, ArrayRef resultTypes, - ArrayRef operands, + ArrayRef operands, NamedAttributeList attributes, ArrayRef successors, unsigned numRegions, bool resizableOperandList); @@ -64,7 +64,7 @@ public: /// Create a new Operation with the specific fields. static Operation * create(Location location, OperationName name, ArrayRef resultTypes, - ArrayRef operands, NamedAttributeList attributes, + ArrayRef operands, NamedAttributeList attributes, ArrayRef successors = {}, RegionRange regions = {}, bool resizableOperandList = false); @@ -149,7 +149,7 @@ public: } /// Replace any uses of 'from' with 'to' within this operation. - void replaceUsesOfWith(Value *from, Value *to); + void replaceUsesOfWith(ValuePtr from, ValuePtr to); /// Replace all uses of results of this operation with the provided 'values'. template > decomposeSuccessorOperandIndex(unsigned operandIndex); - /// Returns the `BlockArgument*` corresponding to operand `operandIndex` in + /// Returns the `BlockArgument` corresponding to operand `operandIndex` in /// some successor, or None if `operandIndex` isn't a successor operand index. - Optional getSuccessorBlockArgument(unsigned operandIndex) { + Optional getSuccessorBlockArgument(unsigned operandIndex) { auto decomposed = decomposeSuccessorOperandIndex(operandIndex); if (!decomposed.hasValue()) return None; diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h index 23ef0ce5937..b7f63218ba5 100644 --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -270,7 +270,7 @@ inline llvm::hash_code hash_value(OperationName arg) { struct OperationState { Location location; OperationName name; - SmallVector operands; + SmallVector operands; /// Types of the results of this operation. SmallVector types; SmallVector attributes; @@ -534,8 +534,8 @@ private: /// This class implements iteration on the types of a given range of values. template class ValueTypeIterator final - : public llvm::mapped_iterator { - static Type unwrap(Value *value) { return value->getType(); } + : public llvm::mapped_iterator { + static Type unwrap(ValuePtr value) { return value->getType(); } public: using reference = Type; @@ -545,7 +545,8 @@ public: /// Initializes the type iterator to the specified value iterator. ValueTypeIterator(ValueIteratorT it) - : llvm::mapped_iterator(it, &unwrap) {} + : llvm::mapped_iterator(it, &unwrap) { + } }; //===----------------------------------------------------------------------===// @@ -554,7 +555,7 @@ public: /// This class implements the operand iterators for the Operation class. class OperandRange final : public detail::indexed_accessor_range_base { + ValuePtr, ValuePtr, ValuePtr> { public: using RangeBaseT::RangeBaseT; OperandRange(Operation *op); @@ -569,7 +570,7 @@ private: return object + index; } /// See `detail::indexed_accessor_range_base` for details. - static Value *dereference_iterator(OpOperand *object, ptrdiff_t index) { + static ValuePtr dereference_iterator(OpOperand *object, ptrdiff_t index) { return object[index].get(); } @@ -582,8 +583,8 @@ private: /// This class implements the result iterators for the Operation class. class ResultRange final - : public detail::indexed_accessor_range_base { + : public detail::indexed_accessor_range_base { public: using RangeBaseT::RangeBaseT; ResultRange(Operation *op); @@ -594,11 +595,11 @@ public: private: /// See `detail::indexed_accessor_range_base` for details. - static OpResult *offset_base(OpResult *object, ptrdiff_t index) { + static OpResultPtr offset_base(OpResultPtr object, ptrdiff_t index) { return object + index; } /// See `detail::indexed_accessor_range_base` for details. - static Value *dereference_iterator(OpResult *object, ptrdiff_t index) { + static ValuePtr dereference_iterator(OpResultPtr object, ptrdiff_t index) { return &object[index]; } @@ -610,31 +611,31 @@ private: // ValueRange /// This class provides an abstraction over the different types of ranges over -/// Value*s. In many cases, this prevents the need to explicitly materialize a +/// Values. In many cases, this prevents the need to explicitly materialize a /// SmallVector/std::vector. This class should be used in places that are not /// suitable for a more derived type (e.g. ArrayRef) or a template range /// parameter. class ValueRange final : public detail::indexed_accessor_range_base< - ValueRange, PointerUnion, - Value *, Value *, Value *> { + ValueRange, PointerUnion, + ValuePtr, ValuePtr, ValuePtr> { public: using RangeBaseT::RangeBaseT; template , Arg>::value && - !std::is_convertible::value>> + std::is_constructible, Arg>::value && + !std::is_convertible::value>> ValueRange(Arg &&arg) - : ValueRange(ArrayRef(std::forward(arg))) {} - ValueRange(Value *const &value) : ValueRange(&value, /*count=*/1) {} - ValueRange(const std::initializer_list &values) - : ValueRange(ArrayRef(values)) {} + : ValueRange(ArrayRef(std::forward(arg))) {} + ValueRange(ValuePtr const &value) : ValueRange(&value, /*count=*/1) {} + ValueRange(const std::initializer_list &values) + : ValueRange(ArrayRef(values)) {} ValueRange(iterator_range values) : ValueRange(OperandRange(values)) {} ValueRange(iterator_range values) : ValueRange(ResultRange(values)) {} - ValueRange(ArrayRef values = llvm::None); + ValueRange(ArrayRef values = llvm::None); ValueRange(OperandRange values); ValueRange(ResultRange values); @@ -645,12 +646,12 @@ public: private: /// The type representing the owner of this range. This is either a list of /// values, operands, or results. - using OwnerT = PointerUnion; + using OwnerT = PointerUnion; /// See `detail::indexed_accessor_range_base` for details. static OwnerT offset_base(const OwnerT &owner, ptrdiff_t index); /// See `detail::indexed_accessor_range_base` for details. - static Value *dereference_iterator(const OwnerT &owner, ptrdiff_t index); + static ValuePtr dereference_iterator(const OwnerT &owner, ptrdiff_t index); /// Allow access to `offset_base` and `dereference_iterator`. friend RangeBaseT; diff --git a/mlir/include/mlir/IR/TypeUtilities.h b/mlir/include/mlir/IR/TypeUtilities.h index 2cce4dbb6cf..af22f9c4a9f 100644 --- a/mlir/include/mlir/IR/TypeUtilities.h +++ b/mlir/include/mlir/IR/TypeUtilities.h @@ -41,8 +41,8 @@ Type getElementTypeOrSelf(Type type); /// Return the element type or return the type itself. Type getElementTypeOrSelf(Attribute attr); -Type getElementTypeOrSelf(Value *val); -Type getElementTypeOrSelf(Value &val); +Type getElementTypeOrSelf(ValuePtr val); +Type getElementTypeOrSelf(ValueRef val); /// Get the types within a nested Tuple. A helper for the class method that /// handles storage concerns, which is tricky to do in tablegen. @@ -72,7 +72,7 @@ LogicalResult verifyCompatibleShape(Type type1, Type type2); // An iterator for the element types of an op's operands of shaped types. class OperandElementTypeIterator final : public llvm::mapped_iterator { + Type (*)(ValuePtr)> { public: using reference = Type; @@ -81,7 +81,7 @@ public: explicit OperandElementTypeIterator(Operation::operand_iterator it); private: - static Type unwrap(Value *value); + static Type unwrap(ValuePtr value); }; using OperandElementTypeRange = iterator_range; @@ -89,7 +89,7 @@ using OperandElementTypeRange = iterator_range; // An iterator for the tensor element types of an op's results of shaped types. class ResultElementTypeIterator final : public llvm::mapped_iterator { + Type (*)(ValuePtr)> { public: using reference = Type; @@ -98,7 +98,7 @@ public: explicit ResultElementTypeIterator(Operation::result_iterator it); private: - static Type unwrap(Value *value); + static Type unwrap(ValuePtr value); }; using ResultElementTypeRange = iterator_range; diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h index 34c74c888cb..11cb8cdcbc7 100644 --- a/mlir/include/mlir/IR/Value.h +++ b/mlir/include/mlir/IR/Value.h @@ -28,10 +28,18 @@ namespace mlir { class Block; +class BlockArgument; class Operation; +class OpResult; class Region; class Value; +/// Using directives that simplify the transition of Value to being value typed. +using BlockArgumentPtr = BlockArgument *; +using OpResultPtr = OpResult *; +using ValueRef = Value &; +using ValuePtr = Value *; + /// Operands contain a Value. using OpOperand = IROperandImpl; @@ -48,6 +56,15 @@ public: ~Value() {} + template bool isa() const { return U::classof(this); } + template U *dyn_cast() const { + return isa() ? (U *)this : nullptr; + } + template U *cast() const { + assert(isa()); + return (U *)this; + } + Kind getKind() const { return typeAndKind.getInt(); } Type getType() const { return typeAndKind.getPointer(); } @@ -66,7 +83,7 @@ public: /// Replace all uses of 'this' value with the new value, updating anything in /// the IR that uses 'this' to use the other value instead. When this returns /// there are zero uses of 'this'. - void replaceAllUsesWith(Value *newValue) { + void replaceAllUsesWith(ValuePtr newValue) { IRObjectWithUseList::replaceAllUsesWith(newValue); } @@ -100,7 +117,7 @@ private: llvm::PointerIntPair typeAndKind; }; -inline raw_ostream &operator<<(raw_ostream &os, Value &value) { +inline raw_ostream &operator<<(raw_ostream &os, ValueRef value) { value.print(os); return os; } @@ -160,7 +177,6 @@ private: /// through bitpacking shenanigans. Operation *const owner; }; - } // namespace mlir #endif diff --git a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h index 070b3c36e8c..202e86566fc 100644 --- a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h +++ b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h @@ -163,7 +163,7 @@ public: } virtual Operation *getOp() const = 0; - virtual Value *getValue() const = 0; + virtual ValuePtr getValue() const = 0; static bool classof(const CAGNode *n) { return n->getKind() >= Kind::Anchor && n->getKind() <= Kind::LastAnchor; @@ -210,7 +210,7 @@ public: return n->getKind() == Kind::Anchor || n->getKind() == Kind::OperandAnchor; } - Value *getValue() const final { return op->getOperand(operandIdx); } + ValuePtr getValue() const final { return op->getOperand(operandIdx); } void printLabel(raw_ostream &os) const override; @@ -221,7 +221,7 @@ private: /// An anchor tied to a specific result. /// Since a result is already anchored to its defining op, result anchors refer -/// directly to the underlying Value*. +/// directly to the underlying Value. class CAGResultAnchor : public CAGAnchorNode { public: CAGResultAnchor(Operation *op, unsigned resultIdx); @@ -231,12 +231,12 @@ public: } Operation *getOp() const final { return resultValue->getDefiningOp(); } - Value *getValue() const final { return resultValue; } + ValuePtr getValue() const final { return resultValue; } void printLabel(raw_ostream &os) const override; private: - Value *resultValue; + ValuePtr resultValue; }; /// Base class for constraint nodes. diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h index 7adb4aac2e2..7464e2a347d 100644 --- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h +++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h @@ -113,7 +113,7 @@ private: protected: // Mappings between original and translated values, used for lookups. llvm::StringMap functionMapping; - DenseMap valueMapping; + DenseMap valueMapping; DenseMap blockMapping; }; diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index 814f2202f01..f9f1207c0a0 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -60,7 +60,7 @@ public: /// remaps an existing signature input. struct InputMapping { size_t inputNo, size; - Value *replacementValue; + ValuePtr replacementValue; }; /// Return the argument types for the new signature. @@ -90,7 +90,7 @@ public: /// Remap an input of the original signature to another `replacement` /// value. This drops the original argument. - void remapInput(unsigned origInputNo, Value *replacement); + void remapInput(unsigned origInputNo, ValuePtr replacement); private: /// The remapping information for each of the original arguments. @@ -143,7 +143,7 @@ public: /// the conversion has finished. virtual Operation *materializeConversion(PatternRewriter &rewriter, Type resultType, - ArrayRef inputs, + ArrayRef inputs, Location loc) { llvm_unreachable("expected 'materializeConversion' to be overridden"); } @@ -172,7 +172,7 @@ public: /// ConversionPattern ever needs to replace an operation that does not /// have successors. This function should not fail. If some specific cases of /// the operation are not supported, these cases should not be matched. - virtual void rewrite(Operation *op, ArrayRef operands, + virtual void rewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const { llvm_unreachable("unimplemented rewrite"); } @@ -187,18 +187,18 @@ public: /// terminator operation that has successors. This function should not fail /// the pass. If some specific cases of the operation are not supported, /// these cases should not be matched. - virtual void rewrite(Operation *op, ArrayRef properOperands, + virtual void rewrite(Operation *op, ArrayRef properOperands, ArrayRef destinations, - ArrayRef> operands, + ArrayRef> operands, ConversionPatternRewriter &rewriter) const { llvm_unreachable("unimplemented rewrite for terminators"); } /// Hook for derived classes to implement combined matching and rewriting. virtual PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef properOperands, + matchAndRewrite(Operation *op, ArrayRef properOperands, ArrayRef destinations, - ArrayRef> operands, + ArrayRef> operands, ConversionPatternRewriter &rewriter) const { if (!match(op)) return matchFailure(); @@ -208,7 +208,7 @@ public: /// Hook for derived classes to implement combined matching and rewriting. virtual PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const { if (!match(op)) return matchFailure(); @@ -234,27 +234,27 @@ struct OpConversionPattern : public ConversionPattern { /// Wrappers around the ConversionPattern methods that pass the derived op /// type. - void rewrite(Operation *op, ArrayRef operands, + void rewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { rewrite(cast(op), operands, rewriter); } - void rewrite(Operation *op, ArrayRef properOperands, + void rewrite(Operation *op, ArrayRef properOperands, ArrayRef destinations, - ArrayRef> operands, + ArrayRef> operands, ConversionPatternRewriter &rewriter) const final { rewrite(cast(op), properOperands, destinations, operands, rewriter); } PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef properOperands, + matchAndRewrite(Operation *op, ArrayRef properOperands, ArrayRef destinations, - ArrayRef> operands, + ArrayRef> operands, ConversionPatternRewriter &rewriter) const final { return matchAndRewrite(cast(op), properOperands, destinations, operands, rewriter); } PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { return matchAndRewrite(cast(op), operands, rewriter); } @@ -264,22 +264,22 @@ struct OpConversionPattern : public ConversionPattern { /// Rewrite and Match methods that operate on the SourceOp type. These must be /// overridden by the derived pattern class. - virtual void rewrite(SourceOp op, ArrayRef operands, + virtual void rewrite(SourceOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const { llvm_unreachable("must override matchAndRewrite or a rewrite method"); } - virtual void rewrite(SourceOp op, ArrayRef properOperands, + virtual void rewrite(SourceOp op, ArrayRef properOperands, ArrayRef destinations, - ArrayRef> operands, + ArrayRef> operands, ConversionPatternRewriter &rewriter) const { llvm_unreachable("unimplemented rewrite for terminators"); } virtual PatternMatchResult - matchAndRewrite(SourceOp op, ArrayRef properOperands, + matchAndRewrite(SourceOp op, ArrayRef properOperands, ArrayRef destinations, - ArrayRef> operands, + ArrayRef> operands, ConversionPatternRewriter &rewriter) const { if (!match(op)) return matchFailure(); @@ -288,7 +288,7 @@ struct OpConversionPattern : public ConversionPattern { } virtual PatternMatchResult - matchAndRewrite(SourceOp op, ArrayRef operands, + matchAndRewrite(SourceOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const { if (!match(op)) return matchFailure(); @@ -330,11 +330,11 @@ public: TypeConverter::SignatureConversion &conversion); /// Replace all the uses of the block argument `from` with value `to`. - void replaceUsesOfBlockArgument(BlockArgument *from, Value *to); + void replaceUsesOfBlockArgument(BlockArgumentPtr from, ValuePtr to); /// Return the converted value that replaces 'key'. Return 'key' if there is /// no such a converted value. - Value *getRemappedValue(Value *key); + ValuePtr getRemappedValue(ValuePtr key); //===--------------------------------------------------------------------===// // PatternRewriter Hooks diff --git a/mlir/include/mlir/Transforms/FoldUtils.h b/mlir/include/mlir/Transforms/FoldUtils.h index bdf88d3bfb2..65dd1b6df16 100644 --- a/mlir/include/mlir/Transforms/FoldUtils.h +++ b/mlir/include/mlir/Transforms/FoldUtils.h @@ -82,7 +82,7 @@ public: /// and immediately try to fold it. This function populates 'results' with /// the results after folding the operation. template - void create(OpBuilder &builder, SmallVectorImpl &results, + void create(OpBuilder &builder, SmallVectorImpl &results, Location location, Args &&... args) { Operation *op = builder.create(location, std::forward(args)...); if (failed(tryToFold(op, results))) @@ -94,9 +94,9 @@ public: /// Overload to create or fold a single result operation. template typename std::enable_if(), - Value *>::type + ValuePtr>::type create(OpBuilder &builder, Location location, Args &&... args) { - SmallVector results; + SmallVector results; create(builder, results, location, std::forward(args)...); return results.front(); } @@ -107,7 +107,7 @@ public: OpTy>::type create(OpBuilder &builder, Location location, Args &&... args) { auto op = builder.create(location, std::forward(args)...); - SmallVector unused; + SmallVector unused; (void)tryToFold(op.getOperation(), unused); // Folding cannot remove a zero-result operation, so for convenience we @@ -126,7 +126,7 @@ private: /// Tries to perform folding on the given `op`. If successful, populates /// `results` with the results of the folding. LogicalResult tryToFold( - Operation *op, SmallVectorImpl &results, + Operation *op, SmallVectorImpl &results, function_ref processGeneratedConstants = nullptr); /// Try to get or create a new constant entry. On success this returns the diff --git a/mlir/include/mlir/Transforms/InliningUtils.h b/mlir/include/mlir/Transforms/InliningUtils.h index 590b46a5d12..47c4f48f468 100644 --- a/mlir/include/mlir/Transforms/InliningUtils.h +++ b/mlir/include/mlir/Transforms/InliningUtils.h @@ -105,7 +105,7 @@ public: /// operation). The given 'op' will be removed by the caller, after this /// function has been called. virtual void handleTerminator(Operation *op, - ArrayRef valuesToReplace) const { + ArrayRef valuesToReplace) const { llvm_unreachable( "must implement handleTerminator in the case of one inlined block"); } @@ -125,8 +125,8 @@ public: /// ... = foo.call @foo(%input : i32) -> i16 /// /// NOTE: This hook may be invoked before the 'isLegal' checks above. - virtual Operation *materializeCallConversion(OpBuilder &builder, Value *input, - Type resultType, + virtual Operation *materializeCallConversion(OpBuilder &builder, + ValuePtr input, Type resultType, Location conversionLoc) const { return nullptr; } @@ -165,7 +165,7 @@ public: virtual void handleTerminator(Operation *op, Block *newDest) const; virtual void handleTerminator(Operation *op, - ArrayRef valuesToRepl) const; + ArrayRef valuesToRepl) const; }; //===----------------------------------------------------------------------===// @@ -187,7 +187,7 @@ public: /// be cloned into the 'inlinePoint' or spliced directly. LogicalResult inlineRegion(InlinerInterface &interface, Region *src, Operation *inlinePoint, BlockAndValueMapping &mapper, - ArrayRef resultsToReplace, + ArrayRef resultsToReplace, Optional inlineLoc = llvm::None, bool shouldCloneInlinedRegion = true); @@ -196,8 +196,8 @@ LogicalResult inlineRegion(InlinerInterface &interface, Region *src, /// in-favor of the region arguments when inlining. LogicalResult inlineRegion(InlinerInterface &interface, Region *src, Operation *inlinePoint, - ArrayRef inlinedOperands, - ArrayRef resultsToReplace, + ArrayRef inlinedOperands, + ArrayRef resultsToReplace, Optional inlineLoc = llvm::None, bool shouldCloneInlinedRegion = true); diff --git a/mlir/include/mlir/Transforms/LoopLikeInterface.td b/mlir/include/mlir/Transforms/LoopLikeInterface.td index 5c324b79f67..583cfe26d87 100644 --- a/mlir/include/mlir/Transforms/LoopLikeInterface.td +++ b/mlir/include/mlir/Transforms/LoopLikeInterface.td @@ -38,7 +38,7 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> { explicit capture of dependencies, an implementation could check whether the value corresponds to a captured dependency. }], - "bool", "isDefinedOutsideOfLoop", (ins "Value *":$value) + "bool", "isDefinedOutsideOfLoop", (ins "ValuePtr ":$value) >, InterfaceMethod<[{ Returns the region that makes up the body of the loop and should be diff --git a/mlir/include/mlir/Transforms/LoopUtils.h b/mlir/include/mlir/Transforms/LoopUtils.h index 5ca3f7f6510..37434ea2ea8 100644 --- a/mlir/include/mlir/Transforms/LoopUtils.h +++ b/mlir/include/mlir/Transforms/LoopUtils.h @@ -85,7 +85,7 @@ void promoteSingleIterationLoops(FuncOp f); /// expression. void getCleanupLoopLowerBound(AffineForOp forOp, unsigned unrollFactor, AffineMap *map, - SmallVectorImpl *operands, + SmallVectorImpl *operands, OpBuilder &builder); /// Skew the operations in the body of a 'affine.for' operation with the @@ -140,7 +140,7 @@ SmallVector, 8> tile(ArrayRef forOps, ArrayRef sizes, ArrayRef targets); SmallVector tile(ArrayRef forOps, - ArrayRef sizes, + ArrayRef sizes, ArrayRef targets); /// Performs tiling (with interchange) by strip-mining the `forOps` by `sizes` @@ -149,7 +149,7 @@ SmallVector tile(ArrayRef forOps, /// `target`. SmallVector tile(ArrayRef forOps, ArrayRef sizes, AffineForOp target); -Loops tile(ArrayRef forOps, ArrayRef sizes, +Loops tile(ArrayRef forOps, ArrayRef sizes, loop::ForOp target); /// Tile a nest of loop::ForOp loops rooted at `rootForOp` with the given @@ -157,7 +157,7 @@ Loops tile(ArrayRef forOps, ArrayRef sizes, /// runtime. If more sizes than loops are provided, discard the trailing values /// in sizes. Assumes the loop nest is permutable. /// Returns the newly created intra-tile loops. -Loops tilePerfectlyNested(loop::ForOp rootForOp, ArrayRef sizes); +Loops tilePerfectlyNested(loop::ForOp rootForOp, ArrayRef sizes); /// Explicit copy / DMA generation options for mlir::affineDataCopyGenerate. struct AffineCopyOptions { @@ -229,8 +229,8 @@ void coalesceLoops(MutableArrayRef loops); /// ... /// } /// ``` -void mapLoopToProcessorIds(loop::ForOp forOp, ArrayRef processorId, - ArrayRef numProcessors); +void mapLoopToProcessorIds(loop::ForOp forOp, ArrayRef processorId, + ArrayRef numProcessors); } // end namespace mlir #endif // MLIR_TRANSFORMS_LOOP_UTILS_H diff --git a/mlir/include/mlir/Transforms/RegionUtils.h b/mlir/include/mlir/Transforms/RegionUtils.h index 48080b26c2c..63236d6a5a0 100644 --- a/mlir/include/mlir/Transforms/RegionUtils.h +++ b/mlir/include/mlir/Transforms/RegionUtils.h @@ -30,14 +30,14 @@ namespace mlir { /// of `limit`. template bool areValuesDefinedAbove(Range values, Region &limit) { - for (Value *v : values) + for (ValuePtr v : values) if (!v->getParentRegion()->isProperAncestor(&limit)) return false; return true; } /// Replace all uses of `orig` within the given region with `replacement`. -void replaceAllUsesInRegionWith(Value *orig, Value *replacement, +void replaceAllUsesInRegionWith(ValuePtr orig, ValuePtr replacement, Region ®ion); /// Calls `callback` for each use of a value within `region` or its descendants @@ -53,12 +53,12 @@ void visitUsedValuesDefinedAbove(MutableArrayRef regions, /// Fill `values` with a list of values defined at the ancestors of the `limit` /// region and used within `region` or its descendants. void getUsedValuesDefinedAbove(Region ®ion, Region &limit, - llvm::SetVector &values); + llvm::SetVector &values); /// Fill `values` with a list of values used within any of the regions provided /// but defined in one of the ancestors. void getUsedValuesDefinedAbove(MutableArrayRef regions, - llvm::SetVector &values); + llvm::SetVector &values); /// Run a set of structural simplifications over the given regions. This /// includes transformations like unreachable block elimination, dead argument diff --git a/mlir/include/mlir/Transforms/Utils.h b/mlir/include/mlir/Transforms/Utils.h index c682b48f331..02c368ec496 100644 --- a/mlir/include/mlir/Transforms/Utils.h +++ b/mlir/include/mlir/Transforms/Utils.h @@ -66,22 +66,22 @@ class OpBuilder; // extra operands, note that 'indexRemap' would just be applied to existing // indices (%i, %j). // TODO(bondhugula): allow extraIndices to be added at any position. -LogicalResult replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, - ArrayRef extraIndices = {}, +LogicalResult replaceAllMemRefUsesWith(ValuePtr oldMemRef, ValuePtr newMemRef, + ArrayRef extraIndices = {}, AffineMap indexRemap = AffineMap(), - ArrayRef extraOperands = {}, - ArrayRef symbolOperands = {}, + ArrayRef extraOperands = {}, + ArrayRef symbolOperands = {}, Operation *domInstFilter = nullptr, Operation *postDomInstFilter = nullptr); /// Performs the same replacement as the other version above but only for the /// dereferencing uses of `oldMemRef` in `op`. -LogicalResult replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, +LogicalResult replaceAllMemRefUsesWith(ValuePtr oldMemRef, ValuePtr newMemRef, Operation *op, - ArrayRef extraIndices = {}, + ArrayRef extraIndices = {}, AffineMap indexRemap = AffineMap(), - ArrayRef extraOperands = {}, - ArrayRef symbolOperands = {}); + ArrayRef extraOperands = {}, + ArrayRef symbolOperands = {}); /// Rewrites the memref defined by this alloc op to have an identity layout map /// and updates all its indexing uses. Returns failure if any of its uses @@ -96,9 +96,9 @@ LogicalResult normalizeMemRef(AllocOp op); /// The final results of the composed AffineApplyOp are returned in output /// parameter 'results'. Returns the affine apply op created. Operation *createComposedAffineApplyOp(OpBuilder &builder, Location loc, - ArrayRef operands, + ArrayRef operands, ArrayRef affineApplyOps, - SmallVectorImpl *results); + SmallVectorImpl *results); /// Given an operation, inserts one or more single result affine apply /// operations, results of which are exclusively used by this operation. diff --git a/mlir/lib/Analysis/AffineAnalysis.cpp b/mlir/lib/Analysis/AffineAnalysis.cpp index 97868a56524..60b2f17292b 100644 --- a/mlir/lib/Analysis/AffineAnalysis.cpp +++ b/mlir/lib/Analysis/AffineAnalysis.cpp @@ -48,15 +48,15 @@ using llvm::dbgs; // TODO(andydavis) Add a method to AffineApplyOp which forward substitutes // the AffineApplyOp into any user AffineApplyOps. void mlir::getReachableAffineApplyOps( - ArrayRef operands, SmallVectorImpl &affineApplyOps) { + ArrayRef operands, SmallVectorImpl &affineApplyOps) { struct State { // The ssa value for this node in the DFS traversal. - Value *value; + ValuePtr value; // The operand index of 'value' to explore next during DFS traversal. unsigned operandIndex; }; SmallVector worklist; - for (auto *operand : operands) { + for (auto operand : operands) { worklist.push_back({operand, 0}); } @@ -77,7 +77,7 @@ void mlir::getReachableAffineApplyOps( if (state.operandIndex < opInst->getNumOperands()) { // Visit: Add next 'affineApplyOp' operand to worklist. // Get next operand to visit at 'operandIndex'. - auto *nextOperand = opInst->getOperand(state.operandIndex); + auto nextOperand = opInst->getOperand(state.operandIndex); // Increment 'operandIndex' in 'state'. ++state.operandIndex; // Add 'nextOperand' to worklist. @@ -99,7 +99,7 @@ void mlir::getReachableAffineApplyOps( // setExprStride(ArrayRef expr, int64_t stride) LogicalResult mlir::getIndexSet(MutableArrayRef forOps, FlatAffineConstraints *domain) { - SmallVector indices; + SmallVector indices; extractForInductionVars(forOps, &indices); // Reset while associated Values in 'indices' to the domain. domain->reset(forOps.size(), /*numSymbols=*/0, /*numLocals=*/0, indices); @@ -146,25 +146,25 @@ static LogicalResult getInstIndexSet(Operation *op, // of maps to check. So getSrcDimOrSymPos would be "getPos(value, {0, 2})". class ValuePositionMap { public: - void addSrcValue(Value *value) { + void addSrcValue(ValuePtr value) { if (addValueAt(value, &srcDimPosMap, numSrcDims)) ++numSrcDims; } - void addDstValue(Value *value) { + void addDstValue(ValuePtr value) { if (addValueAt(value, &dstDimPosMap, numDstDims)) ++numDstDims; } - void addSymbolValue(Value *value) { + void addSymbolValue(ValuePtr value) { if (addValueAt(value, &symbolPosMap, numSymbols)) ++numSymbols; } - unsigned getSrcDimOrSymPos(Value *value) const { + unsigned getSrcDimOrSymPos(ValuePtr value) const { return getDimOrSymPos(value, srcDimPosMap, 0); } - unsigned getDstDimOrSymPos(Value *value) const { + unsigned getDstDimOrSymPos(ValuePtr value) const { return getDimOrSymPos(value, dstDimPosMap, numSrcDims); } - unsigned getSymPos(Value *value) const { + unsigned getSymPos(ValuePtr value) const { auto it = symbolPosMap.find(value); assert(it != symbolPosMap.end()); return numSrcDims + numDstDims + it->second; @@ -176,7 +176,7 @@ public: unsigned getNumSymbols() const { return numSymbols; } private: - bool addValueAt(Value *value, DenseMap *posMap, + bool addValueAt(ValuePtr value, DenseMap *posMap, unsigned position) { auto it = posMap->find(value); if (it == posMap->end()) { @@ -185,8 +185,8 @@ private: } return false; } - unsigned getDimOrSymPos(Value *value, - const DenseMap &dimPosMap, + unsigned getDimOrSymPos(ValuePtr value, + const DenseMap &dimPosMap, unsigned dimPosOffset) const { auto it = dimPosMap.find(value); if (it != dimPosMap.end()) { @@ -200,9 +200,9 @@ private: unsigned numSrcDims = 0; unsigned numDstDims = 0; unsigned numSymbols = 0; - DenseMap srcDimPosMap; - DenseMap dstDimPosMap; - DenseMap symbolPosMap; + DenseMap srcDimPosMap; + DenseMap dstDimPosMap; + DenseMap symbolPosMap; }; // Builds a map from Value to identifier position in a new merged identifier @@ -219,9 +219,9 @@ static void buildDimAndSymbolPositionMaps( const FlatAffineConstraints &dstDomain, const AffineValueMap &srcAccessMap, const AffineValueMap &dstAccessMap, ValuePositionMap *valuePosMap, FlatAffineConstraints *dependenceConstraints) { - auto updateValuePosMap = [&](ArrayRef values, bool isSrc) { + auto updateValuePosMap = [&](ArrayRef values, bool isSrc) { for (unsigned i = 0, e = values.size(); i < e; ++i) { - auto *value = values[i]; + auto value = values[i]; if (!isForInductionVar(values[i])) { assert(isValidSymbol(values[i]) && "access operand has to be either a loop IV or a symbol"); @@ -234,7 +234,7 @@ static void buildDimAndSymbolPositionMaps( } }; - SmallVector srcValues, destValues; + SmallVector srcValues, destValues; srcDomain.getIdValues(0, srcDomain.getNumDimAndSymbolIds(), &srcValues); dstDomain.getIdValues(0, dstDomain.getNumDimAndSymbolIds(), &destValues); // Update value position map with identifiers from src iteration domain. @@ -273,7 +273,7 @@ void initDependenceConstraints(const FlatAffineConstraints &srcDomain, numLocals); // Set values corresponding to dependence constraint identifiers. - SmallVector srcLoopIVs, dstLoopIVs; + SmallVector srcLoopIVs, dstLoopIVs; srcDomain.getIdValues(0, srcDomain.getNumDimIds(), &srcLoopIVs); dstDomain.getIdValues(0, dstDomain.getNumDimIds(), &dstLoopIVs); @@ -282,8 +282,8 @@ void initDependenceConstraints(const FlatAffineConstraints &srcDomain, srcLoopIVs.size(), srcLoopIVs.size() + dstLoopIVs.size(), dstLoopIVs); // Set values for the symbolic identifier dimensions. - auto setSymbolIds = [&](ArrayRef values) { - for (auto *value : values) { + auto setSymbolIds = [&](ArrayRef values) { + for (auto value : values) { if (!isForInductionVar(value)) { assert(isValidSymbol(value) && "expected symbol"); dependenceConstraints->setIdValue(valuePosMap.getSymPos(value), value); @@ -294,7 +294,7 @@ void initDependenceConstraints(const FlatAffineConstraints &srcDomain, setSymbolIds(srcAccessMap.getOperands()); setSymbolIds(dstAccessMap.getOperands()); - SmallVector srcSymbolValues, dstSymbolValues; + SmallVector srcSymbolValues, dstSymbolValues; srcDomain.getIdValues(srcDomain.getNumDimIds(), srcDomain.getNumDimAndSymbolIds(), &srcSymbolValues); dstDomain.getIdValues(dstDomain.getNumDimIds(), @@ -398,10 +398,10 @@ addMemRefAccessConstraints(const AffineValueMap &srcAccessMap, unsigned numResults = srcMap.getNumResults(); unsigned srcNumIds = srcMap.getNumDims() + srcMap.getNumSymbols(); - ArrayRef srcOperands = srcAccessMap.getOperands(); + ArrayRef srcOperands = srcAccessMap.getOperands(); unsigned dstNumIds = dstMap.getNumDims() + dstMap.getNumSymbols(); - ArrayRef dstOperands = dstAccessMap.getOperands(); + ArrayRef dstOperands = dstAccessMap.getOperands(); std::vector> srcFlatExprs; std::vector> destFlatExprs; @@ -457,11 +457,11 @@ addMemRefAccessConstraints(const AffineValueMap &srcAccessMap, } // Add equality constraints for any operands that are defined by constant ops. - auto addEqForConstOperands = [&](ArrayRef operands) { + auto addEqForConstOperands = [&](ArrayRef operands) { for (unsigned i = 0, e = operands.size(); i < e; ++i) { if (isForInductionVar(operands[i])) continue; - auto *symbol = operands[i]; + auto symbol = operands[i]; assert(isValidSymbol(symbol)); // Check if the symbol is a constant. if (auto cOp = dyn_cast_or_null(symbol->getDefiningOp())) @@ -553,7 +553,7 @@ static Block *getCommonBlock(const MemRefAccess &srcAccess, } return block; } - auto *commonForValue = srcDomain.getIdValue(numCommonLoops - 1); + auto commonForValue = srcDomain.getIdValue(numCommonLoops - 1); auto forOp = getForInductionVarOwner(commonForValue); assert(forOp && "commonForValue was not an induction variable"); return forOp.getBody(); @@ -675,7 +675,7 @@ void MemRefAccess::getAccessMap(AffineValueMap *accessMap) const { map = loadOp.getAffineMap(); else if (auto storeOp = dyn_cast(opInst)) map = storeOp.getAffineMap(); - SmallVector operands(indices.begin(), indices.end()); + SmallVector operands(indices.begin(), indices.end()); fullyComposeAffineMapAndOperands(&map, &operands); map = simplifyAffineMap(map); canonicalizeMapAndOperands(&map, &operands); diff --git a/mlir/lib/Analysis/AffineStructures.cpp b/mlir/lib/Analysis/AffineStructures.cpp index d678355880e..21c2830c016 100644 --- a/mlir/lib/Analysis/AffineStructures.cpp +++ b/mlir/lib/Analysis/AffineStructures.cpp @@ -204,8 +204,8 @@ MutableIntegerSet::MutableIntegerSet(unsigned numDims, unsigned numSymbols, // AffineValueMap. //===----------------------------------------------------------------------===// -AffineValueMap::AffineValueMap(AffineMap map, ArrayRef operands, - ArrayRef results) +AffineValueMap::AffineValueMap(AffineMap map, ArrayRef operands, + ArrayRef results) : map(map), operands(operands.begin(), operands.end()), results(results.begin(), results.end()) {} @@ -219,8 +219,8 @@ AffineValueMap::AffineValueMap(AffineBound bound) : map(bound.getMap()), operands(bound.operand_begin(), bound.operand_end()) {} -void AffineValueMap::reset(AffineMap map, ArrayRef operands, - ArrayRef results) { +void AffineValueMap::reset(AffineMap map, ArrayRef operands, + ArrayRef results) { this->map.reset(map); this->operands.assign(operands.begin(), operands.end()); this->results.assign(results.begin(), results.end()); @@ -232,14 +232,14 @@ void AffineValueMap::difference(const AffineValueMap &a, // Fully compose A's map + operands. auto aMap = a.getAffineMap(); - SmallVector aOperands(a.getOperands().begin(), - a.getOperands().end()); + SmallVector aOperands(a.getOperands().begin(), + a.getOperands().end()); fullyComposeAffineMapAndOperands(&aMap, &aOperands); // Use the affine apply normalizer to get B's map into A's coordinate space. AffineApplyNormalizer normalizer(aMap, aOperands); - SmallVector bOperands(b.getOperands().begin(), - b.getOperands().end()); + SmallVector bOperands(b.getOperands().begin(), + b.getOperands().end()); auto bMap = b.getAffineMap(); normalizer.normalize(&bMap, &bOperands); @@ -263,7 +263,7 @@ void AffineValueMap::difference(const AffineValueMap &a, // Returns true and sets 'indexOfMatch' if 'valueToMatch' is found in // 'valuesToSearch' beginning at 'indexStart'. Returns false otherwise. -static bool findIndex(Value *valueToMatch, ArrayRef valuesToSearch, +static bool findIndex(ValuePtr valueToMatch, ArrayRef valuesToSearch, unsigned indexStart, unsigned *indexOfMatch) { unsigned size = valuesToSearch.size(); for (unsigned i = indexStart; i < size; ++i) { @@ -281,7 +281,7 @@ inline bool AffineValueMap::isMultipleOf(unsigned idx, int64_t factor) const { /// This method uses the invariant that operands are always positionally aligned /// with the AffineDimExpr in the underlying AffineMap. -bool AffineValueMap::isFunctionOf(unsigned idx, Value *value) const { +bool AffineValueMap::isFunctionOf(unsigned idx, ValuePtr value) const { unsigned index; if (!findIndex(value, operands, /*indexStart=*/0, &index)) { return false; @@ -292,12 +292,12 @@ bool AffineValueMap::isFunctionOf(unsigned idx, Value *value) const { return expr.isFunctionOfDim(index); } -Value *AffineValueMap::getOperand(unsigned i) const { - return static_cast(operands[i]); +ValuePtr AffineValueMap::getOperand(unsigned i) const { + return static_cast(operands[i]); } -ArrayRef AffineValueMap::getOperands() const { - return ArrayRef(operands); +ArrayRef AffineValueMap::getOperands() const { + return ArrayRef(operands); } AffineMap AffineValueMap::getAffineMap() const { return map.getAffineMap(); } @@ -378,7 +378,7 @@ void FlatAffineConstraints::reset(unsigned numReservedInequalities, unsigned newNumReservedCols, unsigned newNumDims, unsigned newNumSymbols, unsigned newNumLocals, - ArrayRef idArgs) { + ArrayRef idArgs) { assert(newNumReservedCols >= newNumDims + newNumSymbols + newNumLocals + 1 && "minimum 1 column"); numReservedCols = newNumReservedCols; @@ -401,7 +401,7 @@ void FlatAffineConstraints::reset(unsigned numReservedInequalities, void FlatAffineConstraints::reset(unsigned newNumDims, unsigned newNumSymbols, unsigned newNumLocals, - ArrayRef idArgs) { + ArrayRef idArgs) { reset(0, 0, newNumDims + newNumSymbols + newNumLocals + 1, newNumDims, newNumSymbols, newNumLocals, idArgs); } @@ -428,17 +428,17 @@ void FlatAffineConstraints::addLocalId(unsigned pos) { addId(IdKind::Local, pos); } -void FlatAffineConstraints::addDimId(unsigned pos, Value *id) { +void FlatAffineConstraints::addDimId(unsigned pos, ValuePtr id) { addId(IdKind::Dimension, pos, id); } -void FlatAffineConstraints::addSymbolId(unsigned pos, Value *id) { +void FlatAffineConstraints::addSymbolId(unsigned pos, ValuePtr id) { addId(IdKind::Symbol, pos, id); } /// Adds a dimensional identifier. The added column is initialized to /// zero. -void FlatAffineConstraints::addId(IdKind kind, unsigned pos, Value *id) { +void FlatAffineConstraints::addId(IdKind kind, unsigned pos, ValuePtr id) { if (kind == IdKind::Dimension) { assert(pos <= getNumDimIds()); } else if (kind == IdKind::Symbol) { @@ -527,7 +527,7 @@ bool FlatAffineConstraints::areIdsAlignedWithOther( /// Checks if the SSA values associated with `cst''s identifiers are unique. static bool LLVM_ATTRIBUTE_UNUSED areIdsUnique(const FlatAffineConstraints &cst) { - SmallPtrSet uniqueIds; + SmallPtrSet uniqueIds; for (auto id : cst.getIds()) { if (id.hasValue() && !uniqueIds.insert(id.getValue()).second) return false; @@ -571,11 +571,11 @@ static void mergeAndAlignIds(unsigned offset, FlatAffineConstraints *A, assert(std::all_of(A->getIds().begin() + offset, A->getIds().begin() + A->getNumDimAndSymbolIds(), - [](Optional id) { return id.hasValue(); })); + [](Optional id) { return id.hasValue(); })); assert(std::all_of(B->getIds().begin() + offset, B->getIds().begin() + B->getNumDimAndSymbolIds(), - [](Optional id) { return id.hasValue(); })); + [](Optional id) { return id.hasValue(); })); // Place local id's of A after local id's of B. for (unsigned l = 0, e = A->getNumLocalIds(); l < e; l++) { @@ -586,13 +586,13 @@ static void mergeAndAlignIds(unsigned offset, FlatAffineConstraints *A, A->addLocalId(A->getNumLocalIds()); } - SmallVector aDimValues, aSymValues; + SmallVector aDimValues, aSymValues; A->getIdValues(offset, A->getNumDimIds(), &aDimValues); A->getIdValues(A->getNumDimIds(), A->getNumDimAndSymbolIds(), &aSymValues); { // Merge dims from A into B. unsigned d = offset; - for (auto *aDimValue : aDimValues) { + for (auto aDimValue : aDimValues) { unsigned loc; if (B->findId(*aDimValue, &loc)) { assert(loc >= offset && "A's dim appears in B's aligned range"); @@ -615,7 +615,7 @@ static void mergeAndAlignIds(unsigned offset, FlatAffineConstraints *A, { // Merge symbols: merge A's symbols into B first. unsigned s = B->getNumDimIds(); - for (auto *aSymValue : aSymValues) { + for (auto aSymValue : aSymValues) { unsigned loc; if (B->findId(*aSymValue, &loc)) { assert(loc >= B->getNumDimIds() && loc < B->getNumDimAndSymbolIds() && @@ -785,7 +785,7 @@ LogicalResult FlatAffineConstraints::composeMatchingMap(AffineMap other) { } // Turn a dimension into a symbol. -static void turnDimIntoSymbol(FlatAffineConstraints *cst, Value &id) { +static void turnDimIntoSymbol(FlatAffineConstraints *cst, ValueRef id) { unsigned pos; if (cst->findId(id, &pos) && pos < cst->getNumDimIds()) { swapId(cst, pos, cst->getNumDimIds() - 1); @@ -794,7 +794,7 @@ static void turnDimIntoSymbol(FlatAffineConstraints *cst, Value &id) { } // Turn a symbol into a dimension. -static void turnSymbolIntoDim(FlatAffineConstraints *cst, Value &id) { +static void turnSymbolIntoDim(FlatAffineConstraints *cst, ValueRef id) { unsigned pos; if (cst->findId(id, &pos) && pos >= cst->getNumDimIds() && pos < cst->getNumDimAndSymbolIds()) { @@ -806,18 +806,18 @@ static void turnSymbolIntoDim(FlatAffineConstraints *cst, Value &id) { // Changes all symbol identifiers which are loop IVs to dim identifiers. void FlatAffineConstraints::convertLoopIVSymbolsToDims() { // Gather all symbols which are loop IVs. - SmallVector loopIVs; + SmallVector loopIVs; for (unsigned i = getNumDimIds(), e = getNumDimAndSymbolIds(); i < e; i++) { if (ids[i].hasValue() && getForInductionVarOwner(ids[i].getValue())) loopIVs.push_back(ids[i].getValue()); } // Turn each symbol in 'loopIVs' into a dim identifier. - for (auto *iv : loopIVs) { + for (auto iv : loopIVs) { turnSymbolIntoDim(this, *iv); } } -void FlatAffineConstraints::addInductionVarOrTerminalSymbol(Value *id) { +void FlatAffineConstraints::addInductionVarOrTerminalSymbol(ValuePtr id) { if (containsId(*id)) return; @@ -876,8 +876,8 @@ LogicalResult FlatAffineConstraints::addAffineForOpDomain(AffineForOp forOp) { addConstantLowerBound(pos, forOp.getConstantLowerBound()); } else { // Non-constant lower bound case. - SmallVector lbOperands(forOp.getLowerBoundOperands().begin(), - forOp.getLowerBoundOperands().end()); + SmallVector lbOperands(forOp.getLowerBoundOperands().begin(), + forOp.getLowerBoundOperands().end()); if (failed(addLowerOrUpperBound(pos, forOp.getLowerBoundMap(), lbOperands, /*eq=*/false, /*lower=*/true))) return failure(); @@ -888,8 +888,8 @@ LogicalResult FlatAffineConstraints::addAffineForOpDomain(AffineForOp forOp) { return success(); } // Non-constant upper bound case. - SmallVector ubOperands(forOp.getUpperBoundOperands().begin(), - forOp.getUpperBoundOperands().end()); + SmallVector ubOperands(forOp.getUpperBoundOperands().begin(), + forOp.getUpperBoundOperands().end()); return addLowerOrUpperBound(pos, forOp.getUpperBoundMap(), ubOperands, /*eq=*/false, /*lower=*/false); } @@ -1757,7 +1757,7 @@ void FlatAffineConstraints::getSliceBounds(unsigned offset, unsigned num, LogicalResult FlatAffineConstraints::addLowerOrUpperBound(unsigned pos, AffineMap boundMap, - ArrayRef boundOperands, + ArrayRef boundOperands, bool eq, bool lower) { assert(pos < getNumDimAndSymbolIds() && "invalid position"); // Equality follows the logic of lower bound except that we add an equality @@ -1769,11 +1769,11 @@ FlatAffineConstraints::addLowerOrUpperBound(unsigned pos, AffineMap boundMap, // Fully compose map and operands; canonicalize and simplify so that we // transitively get to terminal symbols or loop IVs. auto map = boundMap; - SmallVector operands(boundOperands.begin(), boundOperands.end()); + SmallVector operands(boundOperands.begin(), boundOperands.end()); fullyComposeAffineMapAndOperands(&map, &operands); map = simplifyAffineMap(map); canonicalizeMapAndOperands(&map, &operands); - for (auto *operand : operands) + for (auto operand : operands) addInductionVarOrTerminalSymbol(operand); FlatAffineConstraints localVarCst; @@ -1787,7 +1787,7 @@ FlatAffineConstraints::addLowerOrUpperBound(unsigned pos, AffineMap boundMap, if (localVarCst.getNumLocalIds() > 0) { // Set values for localVarCst. localVarCst.setIdValues(0, localVarCst.getNumDimAndSymbolIds(), operands); - for (auto *operand : operands) { + for (auto operand : operands) { unsigned pos; if (findId(*operand, &pos)) { if (pos >= getNumDimIds() && pos < getNumDimAndSymbolIds()) { @@ -1807,7 +1807,7 @@ FlatAffineConstraints::addLowerOrUpperBound(unsigned pos, AffineMap boundMap, // this here since the constraint system changes after a bound is added. SmallVector positions; unsigned numOperands = operands.size(); - for (auto *operand : operands) { + for (auto operand : operands) { unsigned pos; if (!findId(*operand, &pos)) assert(0 && "expected to be found"); @@ -1848,8 +1848,8 @@ FlatAffineConstraints::addLowerOrUpperBound(unsigned pos, AffineMap boundMap, // Returns failure for unimplemented cases such as semi-affine expressions or // expressions with mod/floordiv. LogicalResult FlatAffineConstraints::addSliceBounds( - ArrayRef values, ArrayRef lbMaps, - ArrayRef ubMaps, ArrayRef operands) { + ArrayRef values, ArrayRef lbMaps, + ArrayRef ubMaps, ArrayRef operands) { assert(values.size() == lbMaps.size()); assert(lbMaps.size() == ubMaps.size()); @@ -1971,7 +1971,7 @@ void FlatAffineConstraints::addLocalFloorDiv(ArrayRef dividend, addInequality(bound); } -bool FlatAffineConstraints::findId(Value &id, unsigned *pos) const { +bool FlatAffineConstraints::findId(ValueRef id, unsigned *pos) const { unsigned i = 0; for (const auto &mayBeId : ids) { if (mayBeId.hasValue() && mayBeId.getValue() == &id) { @@ -1983,8 +1983,8 @@ bool FlatAffineConstraints::findId(Value &id, unsigned *pos) const { return false; } -bool FlatAffineConstraints::containsId(Value &id) const { - return llvm::any_of(ids, [&](const Optional &mayBeId) { +bool FlatAffineConstraints::containsId(ValueRef id) const { + return llvm::any_of(ids, [&](const Optional &mayBeId) { return mayBeId.hasValue() && mayBeId.getValue() == &id; }); } @@ -2008,7 +2008,7 @@ void FlatAffineConstraints::setIdToConstant(unsigned pos, int64_t val) { /// Sets the specified identifier to a constant value; asserts if the id is not /// found. -void FlatAffineConstraints::setIdToConstant(Value &id, int64_t val) { +void FlatAffineConstraints::setIdToConstant(ValueRef id, int64_t val) { unsigned pos; if (!findId(id, &pos)) // This is a pre-condition for this method. @@ -2573,7 +2573,7 @@ void FlatAffineConstraints::FourierMotzkinEliminate( unsigned newNumDims = dimsSymbols.first; unsigned newNumSymbols = dimsSymbols.second; - SmallVector, 8> newIds; + SmallVector, 8> newIds; newIds.reserve(numIds - 1); newIds.append(ids.begin(), ids.begin() + pos); newIds.append(ids.begin() + pos + 1, ids.end()); @@ -2709,7 +2709,7 @@ void FlatAffineConstraints::projectOut(unsigned pos, unsigned num) { normalizeConstraintsByGCD(); } -void FlatAffineConstraints::projectOut(Value *id) { +void FlatAffineConstraints::projectOut(ValuePtr id) { unsigned pos; bool ret = findId(*id, &pos); assert(ret); diff --git a/mlir/lib/Analysis/CallGraph.cpp b/mlir/lib/Analysis/CallGraph.cpp index 93017ca3b57..6ec7c059526 100644 --- a/mlir/lib/Analysis/CallGraph.cpp +++ b/mlir/lib/Analysis/CallGraph.cpp @@ -188,7 +188,7 @@ CallGraphNode *CallGraph::resolveCallable(CallInterfaceCallable callable, callee = SymbolTable::lookupNearestSymbolFrom(from, symbolRef.getRootReference()); else - callee = callable.get()->getDefiningOp(); + callee = callable.get()->getDefiningOp(); // If the callee is non-null and is a valid callable object, try to get the // called region from it. diff --git a/mlir/lib/Analysis/Dominance.cpp b/mlir/lib/Analysis/Dominance.cpp index c422578320f..532972b771b 100644 --- a/mlir/lib/Analysis/Dominance.cpp +++ b/mlir/lib/Analysis/Dominance.cpp @@ -127,7 +127,7 @@ bool DominanceInfo::properlyDominates(Operation *a, Operation *b) { } /// Return true if value A properly dominates operation B. -bool DominanceInfo::properlyDominates(Value *a, Operation *b) { +bool DominanceInfo::properlyDominates(ValuePtr a, Operation *b) { if (auto *aOp = a->getDefiningOp()) { // The values defined by an operation do *not* dominate any nested // operations. diff --git a/mlir/lib/Analysis/Liveness.cpp b/mlir/lib/Analysis/Liveness.cpp index 6aaec4cc719..edb18e5645d 100644 --- a/mlir/lib/Analysis/Liveness.cpp +++ b/mlir/lib/Analysis/Liveness.cpp @@ -40,13 +40,13 @@ struct BlockInfoBuilder { /// Fills the block builder with initial liveness information. BlockInfoBuilder(Block *block) : block(block) { // Mark all block arguments (phis) as defined. - for (BlockArgument *argument : block->getArguments()) + for (BlockArgumentPtr argument : block->getArguments()) defValues.insert(argument); // Check all result values and whether their uses // are inside this block or not (see outValues). for (Operation &operation : *block) - for (Value *result : operation.getResults()) { + for (ValuePtr result : operation.getResults()) { defValues.insert(result); // Check whether this value will be in the outValues @@ -63,7 +63,7 @@ struct BlockInfoBuilder { // Check all operations for used operands. for (Operation &operation : block->getOperations()) - for (Value *operand : operation.getOperands()) { + for (ValuePtr operand : operation.getOperands()) { // If the operand is already defined in the scope of this // block, we can skip the value in the use set. if (!defValues.count(operand)) @@ -173,7 +173,7 @@ void Liveness::build(MutableArrayRef regions) { } /// Gets liveness info (if any) for the given value. -Liveness::OperationListT Liveness::resolveLiveness(Value *value) const { +Liveness::OperationListT Liveness::resolveLiveness(ValuePtr value) const { OperationListT result; SmallPtrSet visited; SmallVector toProcess; @@ -238,7 +238,7 @@ const Liveness::ValueSetT &Liveness::getLiveOut(Block *block) const { /// Returns true if the given operation represent the last use of the /// given value. -bool Liveness::isLastUse(Value *value, Operation *operation) const { +bool Liveness::isLastUse(ValuePtr value, Operation *operation) const { Block *block = operation->getBlock(); const LivenessBlockInfo *blockInfo = getLiveness(block); @@ -263,21 +263,21 @@ void Liveness::print(raw_ostream &os) const { // Builds unique block/value mappings for testing purposes. DenseMap blockIds; DenseMap operationIds; - DenseMap valueIds; + DenseMap valueIds; for (Region ®ion : operation->getRegions()) for (Block &block : region) { blockIds.insert({&block, blockIds.size()}); - for (BlockArgument *argument : block.getArguments()) + for (BlockArgumentPtr argument : block.getArguments()) valueIds.insert({argument, valueIds.size()}); for (Operation &operation : block) { operationIds.insert({&operation, operationIds.size()}); - for (Value *result : operation.getResults()) + for (ValuePtr result : operation.getResults()) valueIds.insert({result, valueIds.size()}); } } // Local printing helpers - auto printValueRef = [&](Value *value) { + auto printValueRef = [&](ValuePtr value) { if (Operation *defOp = value->getDefiningOp()) os << "val_" << defOp->getName(); else { @@ -289,12 +289,12 @@ void Liveness::print(raw_ostream &os) const { }; auto printValueRefs = [&](const ValueSetT &values) { - std::vector orderedValues(values.begin(), values.end()); + std::vector orderedValues(values.begin(), values.end()); std::sort(orderedValues.begin(), orderedValues.end(), - [&](Value *left, Value *right) { + [&](ValuePtr left, ValuePtr right) { return valueIds[left] < valueIds[right]; }); - for (Value *value : orderedValues) + for (ValuePtr value : orderedValues) printValueRef(value); }; @@ -315,7 +315,7 @@ void Liveness::print(raw_ostream &os) const { if (op.getNumResults() < 1) continue; os << "\n"; - for (Value *result : op.getResults()) { + for (ValuePtr result : op.getResults()) { os << "// "; printValueRef(result); os << ":"; @@ -340,18 +340,18 @@ void Liveness::print(raw_ostream &os) const { //===----------------------------------------------------------------------===// /// Returns true if the given value is in the live-in set. -bool LivenessBlockInfo::isLiveIn(Value *value) const { +bool LivenessBlockInfo::isLiveIn(ValuePtr value) const { return inValues.count(value); } /// Returns true if the given value is in the live-out set. -bool LivenessBlockInfo::isLiveOut(Value *value) const { +bool LivenessBlockInfo::isLiveOut(ValuePtr value) const { return outValues.count(value); } /// Gets the start operation for the given value /// (must be referenced in this block). -Operation *LivenessBlockInfo::getStartOperation(Value *value) const { +Operation *LivenessBlockInfo::getStartOperation(ValuePtr value) const { Operation *definingOp = value->getDefiningOp(); // The given value is either live-in or is defined // in the scope of this block. @@ -362,7 +362,7 @@ Operation *LivenessBlockInfo::getStartOperation(Value *value) const { /// Gets the end operation for the given value using the start operation /// provided (must be referenced in this block). -Operation *LivenessBlockInfo::getEndOperation(Value *value, +Operation *LivenessBlockInfo::getEndOperation(ValuePtr value, Operation *startOperation) const { // The given value is either dying in this block or live-out. if (isLiveOut(value)) diff --git a/mlir/lib/Analysis/LoopAnalysis.cpp b/mlir/lib/Analysis/LoopAnalysis.cpp index a81116579ce..9dfbfe0c542 100644 --- a/mlir/lib/Analysis/LoopAnalysis.cpp +++ b/mlir/lib/Analysis/LoopAnalysis.cpp @@ -43,7 +43,7 @@ using namespace mlir; // be more powerful (since both inequalities and equalities will be considered). void mlir::buildTripCountMapAndOperands( AffineForOp forOp, AffineMap *tripCountMap, - SmallVectorImpl *tripCountOperands) { + SmallVectorImpl *tripCountOperands) { int64_t loopSpan; int64_t step = forOp.getStep(); @@ -65,8 +65,8 @@ void mlir::buildTripCountMapAndOperands( *tripCountMap = AffineMap(); return; } - SmallVector lbOperands(forOp.getLowerBoundOperands()); - SmallVector ubOperands(forOp.getUpperBoundOperands()); + SmallVector lbOperands(forOp.getLowerBoundOperands()); + SmallVector ubOperands(forOp.getUpperBoundOperands()); // Difference of each upper bound expression from the single lower bound // expression (divided by the step) provides the expressions for the trip @@ -98,7 +98,7 @@ void mlir::buildTripCountMapAndOperands( // works with analysis structures (FlatAffineConstraints) and thus doesn't // update the IR. Optional mlir::getConstantTripCount(AffineForOp forOp) { - SmallVector operands; + SmallVector operands; AffineMap map; buildTripCountMapAndOperands(forOp, &map, &operands); @@ -124,7 +124,7 @@ Optional mlir::getConstantTripCount(AffineForOp forOp) { /// expression analysis is used (indirectly through getTripCount), and /// this method is thus able to determine non-trivial divisors. uint64_t mlir::getLargestDivisorOfTripCount(AffineForOp forOp) { - SmallVector operands; + SmallVector operands; AffineMap map; buildTripCountMapAndOperands(forOp, &map, &operands); @@ -173,7 +173,7 @@ uint64_t mlir::getLargestDivisorOfTripCount(AffineForOp forOp) { /// /// Returns false in cases with more than one AffineApplyOp, this is /// conservative. -static bool isAccessIndexInvariant(Value *iv, Value *index) { +static bool isAccessIndexInvariant(ValuePtr iv, ValuePtr index) { assert(isForInductionVar(iv) && "iv must be a AffineForOp"); assert(index->getType().isa() && "index must be of IndexType"); SmallVector affineApplyOps; @@ -197,11 +197,11 @@ static bool isAccessIndexInvariant(Value *iv, Value *index) { return !(AffineValueMap(composeOp).isFunctionOf(0, iv)); } -DenseSet mlir::getInvariantAccesses(Value *iv, - ArrayRef indices) { - DenseSet res; +DenseSet mlir::getInvariantAccesses(ValuePtr iv, + ArrayRef indices) { + DenseSet res; for (unsigned idx = 0, n = indices.size(); idx < n; ++idx) { - auto *val = indices[idx]; + auto val = indices[idx]; if (isAccessIndexInvariant(iv, val)) { res.insert(val); } @@ -229,7 +229,7 @@ DenseSet mlir::getInvariantAccesses(Value *iv, /// // TODO(ntv): check strides. template -static bool isContiguousAccess(Value *iv, LoadOrStoreOp memoryOp, +static bool isContiguousAccess(ValuePtr iv, LoadOrStoreOp memoryOp, int *memRefDim) { static_assert(std::is_same::value || std::is_same::value, @@ -250,11 +250,11 @@ static bool isContiguousAccess(Value *iv, LoadOrStoreOp memoryOp, int uniqueVaryingIndexAlongIv = -1; auto accessMap = memoryOp.getAffineMap(); - SmallVector mapOperands(memoryOp.getMapOperands()); + SmallVector mapOperands(memoryOp.getMapOperands()); unsigned numDims = accessMap.getNumDims(); for (unsigned i = 0, e = memRefType.getRank(); i < e; ++i) { // Gather map operands used result expr 'i' in 'exprOperands'. - SmallVector exprOperands; + SmallVector exprOperands; auto resultExpr = accessMap.getResult(i); resultExpr.walk([&](AffineExpr expr) { if (auto dimExpr = expr.dyn_cast()) @@ -263,7 +263,7 @@ static bool isContiguousAccess(Value *iv, LoadOrStoreOp memoryOp, exprOperands.push_back(mapOperands[numDims + symExpr.getPosition()]); }); // Check access invariance of each operand in 'exprOperands'. - for (auto *exprOperand : exprOperands) { + for (auto exprOperand : exprOperands) { if (!isAccessIndexInvariant(iv, exprOperand)) { if (uniqueVaryingIndexAlongIv != -1) { // 2+ varying indices -> do not vectorize along iv. @@ -382,7 +382,7 @@ bool mlir::isInstwiseShiftValid(AffineForOp forOp, ArrayRef shifts) { // Validate the results of this operation if it were to be shifted. for (unsigned i = 0, e = op.getNumResults(); i < e; ++i) { - Value *result = op.getResult(i); + ValuePtr result = op.getResult(i); for (auto *user : result->getUsers()) { // If an ancestor operation doesn't lie in the block of forOp, // there is no shift to check. diff --git a/mlir/lib/Analysis/SliceAnalysis.cpp b/mlir/lib/Analysis/SliceAnalysis.cpp index 700321ebb40..b09bddddd66 100644 --- a/mlir/lib/Analysis/SliceAnalysis.cpp +++ b/mlir/lib/Analysis/SliceAnalysis.cpp @@ -104,8 +104,8 @@ static void getBackwardSliceImpl(Operation *op, } for (auto en : llvm::enumerate(op->getOperands())) { - auto *operand = en.value(); - if (auto *blockArg = dyn_cast(operand)) { + auto operand = en.value(); + if (auto blockArg = dyn_cast(operand)) { if (auto affIv = getForInductionVarOwner(operand)) { auto *affOp = affIv.getOperation(); if (backwardSlice->count(affOp) == 0) diff --git a/mlir/lib/Analysis/Utils.cpp b/mlir/lib/Analysis/Utils.cpp index 3ba27bbb299..73aa07e7d7b 100644 --- a/mlir/lib/Analysis/Utils.cpp +++ b/mlir/lib/Analysis/Utils.cpp @@ -60,7 +60,7 @@ ComputationSliceState::getAsConstraints(FlatAffineConstraints *cst) { // Adds operands (dst ivs and symbols) as symbols in 'cst'. unsigned numSymbols = lbOperands[0].size(); - SmallVector values(ivs); + SmallVector values(ivs); // Append 'ivs' then 'operands' to 'values'. values.append(lbOperands[0].begin(), lbOperands[0].end()); cst->reset(numDims, numSymbols, 0, values); @@ -185,7 +185,7 @@ LogicalResult MemRefRegion::compute(Operation *op, unsigned loopDepth, if (rank == 0) { SmallVector ivs; getLoopIVs(*op, &ivs); - SmallVector regionSymbols; + SmallVector regionSymbols; extractForInductionVars(ivs, ®ionSymbols); // A rank 0 memref has a 0-d region. cst.reset(rank, loopDepth, 0, regionSymbols); @@ -201,7 +201,7 @@ LogicalResult MemRefRegion::compute(Operation *op, unsigned loopDepth, unsigned numSymbols = accessMap.getNumSymbols(); unsigned numOperands = accessValueMap.getNumOperands(); // Merge operands with slice operands. - SmallVector operands; + SmallVector operands; operands.resize(numOperands); for (unsigned i = 0; i < numOperands; ++i) operands[i] = accessValueMap.getOperand(i); @@ -224,7 +224,7 @@ LogicalResult MemRefRegion::compute(Operation *op, unsigned loopDepth, // Add equality constraints. // Add inequalities for loop lower/upper bounds. for (unsigned i = 0; i < numDims + numSymbols; ++i) { - auto *operand = operands[i]; + auto operand = operands[i]; if (auto loop = getForInductionVarOwner(operand)) { // Note that cst can now have more dimensions than accessMap if the // bounds expressions involve outer loops or other symbols. @@ -234,7 +234,7 @@ LogicalResult MemRefRegion::compute(Operation *op, unsigned loopDepth, return failure(); } else { // Has to be a valid symbol. - auto *symbol = operand; + auto symbol = operand; assert(isValidSymbol(symbol)); // Check if the symbol is a constant. if (auto *op = symbol->getDefiningOp()) { @@ -278,9 +278,9 @@ LogicalResult MemRefRegion::compute(Operation *op, unsigned loopDepth, getLoopIVs(*op, &enclosingIVs); assert(loopDepth <= enclosingIVs.size() && "invalid loop depth"); enclosingIVs.resize(loopDepth); - SmallVector ids; + SmallVector ids; cst.getIdValues(cst.getNumDimIds(), cst.getNumDimAndSymbolIds(), &ids); - for (auto *id : ids) { + for (auto id : ids) { AffineForOp iv; if ((iv = getForInductionVarOwner(id)) && llvm::is_contained(enclosingIVs, iv) == false) { @@ -345,9 +345,9 @@ Optional MemRefRegion::getRegionSize() { // Indices to use for the DmaStart op. // Indices for the original memref being DMAed from/to. - SmallVector memIndices; + SmallVector memIndices; // Indices for the faster buffer being DMAed into/from. - SmallVector bufIndices; + SmallVector bufIndices; // Compute the extents of the buffer. Optional numElements = getConstantBoundingSizeAndShape(); @@ -480,10 +480,10 @@ static Operation *getInstAtPosition(ArrayRef positions, } // Adds loop IV bounds to 'cst' for loop IVs not found in 'ivs'. -LogicalResult addMissingLoopIVBounds(SmallPtrSet &ivs, +LogicalResult addMissingLoopIVBounds(SmallPtrSet &ivs, FlatAffineConstraints *cst) { for (unsigned i = 0, e = cst->getNumDimIds(); i < e; ++i) { - auto *value = cst->getIdValue(i); + auto value = cst->getIdValue(i); if (ivs.count(value) == 0) { assert(isForInductionVar(value)); auto loop = getForInductionVarOwner(value); @@ -596,10 +596,10 @@ LogicalResult mlir::computeSliceUnion(ArrayRef opsA, // Pre-constraint id alignment: record loop IVs used in each constraint // system. - SmallPtrSet sliceUnionIVs; + SmallPtrSet sliceUnionIVs; for (unsigned k = 0, l = sliceUnionCst.getNumDimIds(); k < l; ++k) sliceUnionIVs.insert(sliceUnionCst.getIdValue(k)); - SmallPtrSet tmpSliceIVs; + SmallPtrSet tmpSliceIVs; for (unsigned k = 0, l = tmpSliceCst.getNumDimIds(); k < l; ++k) tmpSliceIVs.insert(tmpSliceCst.getIdValue(k)); @@ -659,7 +659,7 @@ LogicalResult mlir::computeSliceUnion(ArrayRef opsA, &sliceUnion->ubs); // Add slice bound operands of union. - SmallVector sliceBoundOperands; + SmallVector sliceBoundOperands; sliceUnionCst.getIdValues(numSliceLoopIVs, sliceUnionCst.getNumDimAndSymbolIds(), &sliceBoundOperands); @@ -725,7 +725,7 @@ void mlir::getComputationSliceState( &sliceState->lbs, &sliceState->ubs); // Set up bound operands for the slice's lower and upper bounds. - SmallVector sliceBoundOperands; + SmallVector sliceBoundOperands; unsigned numDimsAndSymbols = dependenceConstraints->getNumDimAndSymbolIds(); for (unsigned i = 0; i < numDimsAndSymbols; ++i) { if (i < offset || i >= offset + numSliceLoopIVs) { @@ -743,7 +743,7 @@ void mlir::getComputationSliceState( isBackwardSlice ? dstLoopIVs[loopDepth - 1].getBody()->begin() : std::prev(srcLoopIVs[loopDepth - 1].getBody()->end()); - llvm::SmallDenseSet sequentialLoops; + llvm::SmallDenseSet sequentialLoops; if (isa(depSourceOp) && isa(depSinkOp)) { // For read-read access pairs, clear any slice bounds on sequential loops. // Get sequential loops in loop nest rooted at 'srcLoopIVs[0]'. @@ -758,7 +758,7 @@ void mlir::getComputationSliceState( return isBackwardSlice ? srcLoopIVs[i] : dstLoopIVs[i]; }; for (unsigned i = 0; i < numSliceLoopIVs; ++i) { - Value *iv = getSliceLoop(i).getInductionVar(); + ValuePtr iv = getSliceLoop(i).getInductionVar(); if (sequentialLoops.count(iv) == 0 && getSliceLoop(i).getAttr(kSliceFusionBarrierAttrName) == nullptr) continue; @@ -846,7 +846,7 @@ MemRefAccess::MemRefAccess(Operation *loadOrStoreOpInst) { opInst = loadOrStoreOpInst; auto loadMemrefType = loadOp.getMemRefType(); indices.reserve(loadMemrefType.getRank()); - for (auto *index : loadOp.getMapOperands()) { + for (auto index : loadOp.getMapOperands()) { indices.push_back(index); } } else { @@ -856,7 +856,7 @@ MemRefAccess::MemRefAccess(Operation *loadOrStoreOpInst) { memref = storeOp.getMemRef(); auto storeMemrefType = storeOp.getMemRefType(); indices.reserve(storeMemrefType.getRank()); - for (auto *index : storeOp.getMapOperands()) { + for (auto index : storeOp.getMapOperands()) { indices.push_back(index); } } @@ -919,7 +919,7 @@ static Optional getMemoryFootprintBytes(Block &block, Block::iterator start, Block::iterator end, int memorySpace) { - SmallDenseMap, 4> regions; + SmallDenseMap, 4> regions; // Walk this 'affine.for' operation to gather all memory regions. auto result = block.walk(start, end, [&](Operation *opInst) -> WalkResult { @@ -970,7 +970,7 @@ Optional mlir::getMemoryFootprintBytes(AffineForOp forOp, /// Returns in 'sequentialLoops' all sequential loops in loop nest rooted /// at 'forOp'. void mlir::getSequentialLoops( - AffineForOp forOp, llvm::SmallDenseSet *sequentialLoops) { + AffineForOp forOp, llvm::SmallDenseSet *sequentialLoops) { forOp.getOperation()->walk([&](Operation *op) { if (auto innerFor = dyn_cast(op)) if (!isLoopParallel(innerFor)) diff --git a/mlir/lib/Analysis/VectorAnalysis.cpp b/mlir/lib/Analysis/VectorAnalysis.cpp index 42d3f10b14c..a7917eba503 100644 --- a/mlir/lib/Analysis/VectorAnalysis.cpp +++ b/mlir/lib/Analysis/VectorAnalysis.cpp @@ -109,7 +109,7 @@ Optional> mlir::shapeRatio(VectorType superVectorType, /// Examples can be found in the documentation of `makePermutationMap`, in the /// header file. static AffineMap makePermutationMap( - ArrayRef indices, + ArrayRef indices, const DenseMap &enclosingLoopToVectorDim) { if (enclosingLoopToVectorDim.empty()) return AffineMap(); @@ -167,7 +167,7 @@ static SetVector getEnclosingforOps(Operation *op) { } AffineMap mlir::makePermutationMap( - Operation *op, ArrayRef indices, + Operation *op, ArrayRef indices, const DenseMap &loopToVectorDim) { DenseMap enclosingLoopToVectorDim; auto enclosingLoops = getEnclosingforOps(op); diff --git a/mlir/lib/Analysis/Verifier.cpp b/mlir/lib/Analysis/Verifier.cpp index 82f5aa5e01c..be499a93898 100644 --- a/mlir/lib/Analysis/Verifier.cpp +++ b/mlir/lib/Analysis/Verifier.cpp @@ -138,7 +138,7 @@ LogicalResult OperationVerifier::verifyRegion(Region ®ion) { } LogicalResult OperationVerifier::verifyBlock(Block &block) { - for (auto *arg : block.getArguments()) + for (auto arg : block.getArguments()) if (arg->getOwner() != &block) return emitError(block, "block argument not owned by block"); @@ -175,7 +175,7 @@ LogicalResult OperationVerifier::verifyBlock(Block &block) { LogicalResult OperationVerifier::verifyOperation(Operation &op) { // Check that operands are non-nil and structurally ok. - for (auto *operand : op.getOperands()) + for (auto operand : op.getOperands()) if (!operand) return op.emitError("null operand found"); @@ -244,7 +244,7 @@ LogicalResult OperationVerifier::verifyDominance(Operation &op) { // Check that operands properly dominate this use. for (unsigned operandNo = 0, e = op.getNumOperands(); operandNo != e; ++operandNo) { - auto *operand = op.getOperand(operandNo); + auto operand = op.getOperand(operandNo); if (domInfo->properlyDominates(operand, &op)) continue; diff --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp index 3f613c6bfb5..144b4a97e87 100644 --- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp +++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp @@ -42,16 +42,16 @@ namespace { // that correspond to it. Visitation functions return an Value of the // expression subtree they visited or `nullptr` on error. class AffineApplyExpander - : public AffineExprVisitor { + : public AffineExprVisitor { public: // This internal class expects arguments to be non-null, checks must be // performed at the call site. - AffineApplyExpander(OpBuilder &builder, ArrayRef dimValues, - ArrayRef symbolValues, Location loc) + AffineApplyExpander(OpBuilder &builder, ArrayRef dimValues, + ArrayRef symbolValues, Location loc) : builder(builder), dimValues(dimValues), symbolValues(symbolValues), loc(loc) {} - template Value *buildBinaryExpr(AffineBinaryOpExpr expr) { + template ValuePtr buildBinaryExpr(AffineBinaryOpExpr expr) { auto lhs = visit(expr.getLHS()); auto rhs = visit(expr.getRHS()); if (!lhs || !rhs) @@ -60,11 +60,11 @@ public: return op.getResult(); } - Value *visitAddExpr(AffineBinaryOpExpr expr) { + ValuePtr visitAddExpr(AffineBinaryOpExpr expr) { return buildBinaryExpr(expr); } - Value *visitMulExpr(AffineBinaryOpExpr expr) { + ValuePtr visitMulExpr(AffineBinaryOpExpr expr) { return buildBinaryExpr(expr); } @@ -77,7 +77,7 @@ public: // let remainder = srem a, b; // negative = a < 0 in // select negative, remainder + b, remainder. - Value *visitModExpr(AffineBinaryOpExpr expr) { + ValuePtr visitModExpr(AffineBinaryOpExpr expr) { auto rhsConst = expr.getRHS().dyn_cast(); if (!rhsConst) { emitError( @@ -94,13 +94,13 @@ public: auto rhs = visit(expr.getRHS()); assert(lhs && rhs && "unexpected affine expr lowering failure"); - Value *remainder = builder.create(loc, lhs, rhs); - Value *zeroCst = builder.create(loc, 0); - Value *isRemainderNegative = + ValuePtr remainder = builder.create(loc, lhs, rhs); + ValuePtr zeroCst = builder.create(loc, 0); + ValuePtr isRemainderNegative = builder.create(loc, CmpIPredicate::slt, remainder, zeroCst); - Value *correctedRemainder = builder.create(loc, remainder, rhs); - Value *result = builder.create(loc, isRemainderNegative, - correctedRemainder, remainder); + ValuePtr correctedRemainder = builder.create(loc, remainder, rhs); + ValuePtr result = builder.create(loc, isRemainderNegative, + correctedRemainder, remainder); return result; } @@ -114,7 +114,7 @@ public: // let absolute = negative ? -a - 1 : a in // let quotient = absolute / b in // negative ? -quotient - 1 : quotient - Value *visitFloorDivExpr(AffineBinaryOpExpr expr) { + ValuePtr visitFloorDivExpr(AffineBinaryOpExpr expr) { auto rhsConst = expr.getRHS().dyn_cast(); if (!rhsConst) { emitError( @@ -131,16 +131,16 @@ public: auto rhs = visit(expr.getRHS()); assert(lhs && rhs && "unexpected affine expr lowering failure"); - Value *zeroCst = builder.create(loc, 0); - Value *noneCst = builder.create(loc, -1); - Value *negative = + ValuePtr zeroCst = builder.create(loc, 0); + ValuePtr noneCst = builder.create(loc, -1); + ValuePtr negative = builder.create(loc, CmpIPredicate::slt, lhs, zeroCst); - Value *negatedDecremented = builder.create(loc, noneCst, lhs); - Value *dividend = + ValuePtr negatedDecremented = builder.create(loc, noneCst, lhs); + ValuePtr dividend = builder.create(loc, negative, negatedDecremented, lhs); - Value *quotient = builder.create(loc, dividend, rhs); - Value *correctedQuotient = builder.create(loc, noneCst, quotient); - Value *result = + ValuePtr quotient = builder.create(loc, dividend, rhs); + ValuePtr correctedQuotient = builder.create(loc, noneCst, quotient); + ValuePtr result = builder.create(loc, negative, correctedQuotient, quotient); return result; } @@ -155,7 +155,7 @@ public: // let absolute = negative ? -a : a - 1 in // let quotient = absolute / b in // negative ? -quotient : quotient + 1 - Value *visitCeilDivExpr(AffineBinaryOpExpr expr) { + ValuePtr visitCeilDivExpr(AffineBinaryOpExpr expr) { auto rhsConst = expr.getRHS().dyn_cast(); if (!rhsConst) { emitError(loc) << "semi-affine expressions (division by non-const) are " @@ -170,23 +170,24 @@ public: auto rhs = visit(expr.getRHS()); assert(lhs && rhs && "unexpected affine expr lowering failure"); - Value *zeroCst = builder.create(loc, 0); - Value *oneCst = builder.create(loc, 1); - Value *nonPositive = + ValuePtr zeroCst = builder.create(loc, 0); + ValuePtr oneCst = builder.create(loc, 1); + ValuePtr nonPositive = builder.create(loc, CmpIPredicate::sle, lhs, zeroCst); - Value *negated = builder.create(loc, zeroCst, lhs); - Value *decremented = builder.create(loc, lhs, oneCst); - Value *dividend = + ValuePtr negated = builder.create(loc, zeroCst, lhs); + ValuePtr decremented = builder.create(loc, lhs, oneCst); + ValuePtr dividend = builder.create(loc, nonPositive, negated, decremented); - Value *quotient = builder.create(loc, dividend, rhs); - Value *negatedQuotient = builder.create(loc, zeroCst, quotient); - Value *incrementedQuotient = builder.create(loc, quotient, oneCst); - Value *result = builder.create(loc, nonPositive, negatedQuotient, - incrementedQuotient); + ValuePtr quotient = builder.create(loc, dividend, rhs); + ValuePtr negatedQuotient = builder.create(loc, zeroCst, quotient); + ValuePtr incrementedQuotient = + builder.create(loc, quotient, oneCst); + ValuePtr result = builder.create( + loc, nonPositive, negatedQuotient, incrementedQuotient); return result; } - Value *visitConstantExpr(AffineConstantExpr expr) { + ValuePtr visitConstantExpr(AffineConstantExpr expr) { auto valueAttr = builder.getIntegerAttr(builder.getIndexType(), expr.getValue()); auto op = @@ -194,13 +195,13 @@ public: return op.getResult(); } - Value *visitDimExpr(AffineDimExpr expr) { + ValuePtr visitDimExpr(AffineDimExpr expr) { assert(expr.getPosition() < dimValues.size() && "affine dim position out of range"); return dimValues[expr.getPosition()]; } - Value *visitSymbolExpr(AffineSymbolExpr expr) { + ValuePtr visitSymbolExpr(AffineSymbolExpr expr) { assert(expr.getPosition() < symbolValues.size() && "symbol dim position out of range"); return symbolValues[expr.getPosition()]; @@ -208,8 +209,8 @@ public: private: OpBuilder &builder; - ArrayRef dimValues; - ArrayRef symbolValues; + ArrayRef dimValues; + ArrayRef symbolValues; Location loc; }; @@ -217,18 +218,18 @@ private: // Create a sequence of operations that implement the `expr` applied to the // given dimension and symbol values. -mlir::Value *mlir::expandAffineExpr(OpBuilder &builder, Location loc, - AffineExpr expr, - ArrayRef dimValues, - ArrayRef symbolValues) { +mlir::ValuePtr mlir::expandAffineExpr(OpBuilder &builder, Location loc, + AffineExpr expr, + ArrayRef dimValues, + ArrayRef symbolValues) { return AffineApplyExpander(builder, dimValues, symbolValues, loc).visit(expr); } // Create a sequence of operations that implement the `affineMap` applied to // the given `operands` (as it it were an AffineApplyOp). -Optional> static expandAffineMap( +Optional> static expandAffineMap( OpBuilder &builder, Location loc, AffineMap affineMap, - ArrayRef operands) { + ArrayRef operands) { auto numDims = affineMap.getNumDims(); auto expanded = functional::map( [numDims, &builder, loc, operands](AffineExpr expr) { @@ -237,7 +238,7 @@ Optional> static expandAffineMap( operands.drop_front(numDims)); }, affineMap.getResults()); - if (llvm::all_of(expanded, [](Value *v) { return v; })) + if (llvm::all_of(expanded, [](ValuePtr v) { return v; })) return expanded; return None; } @@ -253,13 +254,13 @@ Optional> static expandAffineMap( // Multiple values are scanned in a linear sequence. This creates a data // dependences that wouldn't exist in a tree reduction, but is easier to // recognize as a reduction by the subsequent passes. -static Value *buildMinMaxReductionSeq(Location loc, CmpIPredicate predicate, - ArrayRef values, - OpBuilder &builder) { +static ValuePtr buildMinMaxReductionSeq(Location loc, CmpIPredicate predicate, + ArrayRef values, + OpBuilder &builder) { assert(!llvm::empty(values) && "empty min/max chain"); auto valueIt = values.begin(); - Value *value = *valueIt++; + ValuePtr value = *valueIt++; for (; valueIt != values.end(); ++valueIt) { auto cmpOp = builder.create(loc, predicate, value, *valueIt); value = builder.create(loc, cmpOp.getResult(), value, *valueIt); @@ -271,8 +272,8 @@ static Value *buildMinMaxReductionSeq(Location loc, CmpIPredicate predicate, // Emit instructions that correspond to the affine map in the lower bound // applied to the respective operands, and compute the maximum value across // the results. -Value *mlir::lowerAffineLowerBound(AffineForOp op, OpBuilder &builder) { - SmallVector boundOperands(op.getLowerBoundOperands()); +ValuePtr mlir::lowerAffineLowerBound(AffineForOp op, OpBuilder &builder) { + SmallVector boundOperands(op.getLowerBoundOperands()); auto lbValues = expandAffineMap(builder, op.getLoc(), op.getLowerBoundMap(), boundOperands); if (!lbValues) @@ -284,8 +285,8 @@ Value *mlir::lowerAffineLowerBound(AffineForOp op, OpBuilder &builder) { // Emit instructions that correspond to the affine map in the upper bound // applied to the respective operands, and compute the minimum value across // the results. -Value *mlir::lowerAffineUpperBound(AffineForOp op, OpBuilder &builder) { - SmallVector boundOperands(op.getUpperBoundOperands()); +ValuePtr mlir::lowerAffineUpperBound(AffineForOp op, OpBuilder &builder) { + SmallVector boundOperands(op.getUpperBoundOperands()); auto ubValues = expandAffineMap(builder, op.getLoc(), op.getUpperBoundMap(), boundOperands); if (!ubValues) @@ -314,9 +315,9 @@ public: PatternMatchResult matchAndRewrite(AffineForOp op, PatternRewriter &rewriter) const override { Location loc = op.getLoc(); - Value *lowerBound = lowerAffineLowerBound(op, rewriter); - Value *upperBound = lowerAffineUpperBound(op, rewriter); - Value *step = rewriter.create(loc, op.getStep()); + ValuePtr lowerBound = lowerAffineLowerBound(op, rewriter); + ValuePtr upperBound = lowerAffineUpperBound(op, rewriter); + ValuePtr step = rewriter.create(loc, op.getStep()); auto f = rewriter.create(loc, lowerBound, upperBound, step); f.region().getBlocks().clear(); rewriter.inlineRegionBefore(op.region(), f.region(), f.region().end()); @@ -335,25 +336,25 @@ public: // Now we just have to handle the condition logic. auto integerSet = op.getIntegerSet(); - Value *zeroConstant = rewriter.create(loc, 0); - SmallVector operands(op.getOperands()); + ValuePtr zeroConstant = rewriter.create(loc, 0); + SmallVector operands(op.getOperands()); auto operandsRef = llvm::makeArrayRef(operands); // Calculate cond as a conjunction without short-circuiting. - Value *cond = nullptr; + ValuePtr cond = nullptr; for (unsigned i = 0, e = integerSet.getNumConstraints(); i < e; ++i) { AffineExpr constraintExpr = integerSet.getConstraint(i); bool isEquality = integerSet.isEq(i); // Build and apply an affine expression auto numDims = integerSet.getNumDims(); - Value *affResult = expandAffineExpr(rewriter, loc, constraintExpr, - operandsRef.take_front(numDims), - operandsRef.drop_front(numDims)); + ValuePtr affResult = expandAffineExpr(rewriter, loc, constraintExpr, + operandsRef.take_front(numDims), + operandsRef.drop_front(numDims)); if (!affResult) return matchFailure(); auto pred = isEquality ? CmpIPredicate::eq : CmpIPredicate::sge; - Value *cmpVal = + ValuePtr cmpVal = rewriter.create(loc, pred, affResult, zeroConstant); cond = cond ? rewriter.create(loc, cond, cmpVal).getResult() : cmpVal; @@ -404,7 +405,7 @@ public: PatternMatchResult matchAndRewrite(AffineLoadOp op, PatternRewriter &rewriter) const override { // Expand affine map from 'affineLoadOp'. - SmallVector indices(op.getMapOperands()); + SmallVector indices(op.getMapOperands()); auto resultOperands = expandAffineMap(rewriter, op.getLoc(), op.getAffineMap(), indices); if (!resultOperands) @@ -426,7 +427,7 @@ public: PatternMatchResult matchAndRewrite(AffinePrefetchOp op, PatternRewriter &rewriter) const override { // Expand affine map from 'affinePrefetchOp'. - SmallVector indices(op.getMapOperands()); + SmallVector indices(op.getMapOperands()); auto resultOperands = expandAffineMap(rewriter, op.getLoc(), op.getAffineMap(), indices); if (!resultOperands) @@ -450,7 +451,7 @@ public: PatternMatchResult matchAndRewrite(AffineStoreOp op, PatternRewriter &rewriter) const override { // Expand affine map from 'affineStoreOp'. - SmallVector indices(op.getMapOperands()); + SmallVector indices(op.getMapOperands()); auto maybeExpandedMap = expandAffineMap(rewriter, op.getLoc(), op.getAffineMap(), indices); if (!maybeExpandedMap) @@ -472,7 +473,7 @@ public: PatternMatchResult matchAndRewrite(AffineDmaStartOp op, PatternRewriter &rewriter) const override { - SmallVector operands(op.getOperands()); + SmallVector operands(op.getOperands()); auto operandsRef = llvm::makeArrayRef(operands); // Expand affine map for DMA source memref. @@ -513,7 +514,7 @@ public: PatternMatchResult matchAndRewrite(AffineDmaWaitOp op, PatternRewriter &rewriter) const override { // Expand affine map for DMA tag memref. - SmallVector indices(op.getTagIndices()); + SmallVector indices(op.getTagIndices()); auto maybeExpandedTagMap = expandAffineMap(rewriter, op.getLoc(), op.getTagMap(), indices); if (!maybeExpandedTagMap) diff --git a/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h b/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h index 6a1a580e369..a408ab5b5d9 100644 --- a/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h +++ b/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h @@ -57,11 +57,11 @@ public: // Convert the kernel arguments to an LLVM type, preserve the rest. PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto loc = op->getLoc(); auto dialect = lowering.getDialect(); - Value *newOp; + ValuePtr newOp; switch (dimensionToIndex(cast(op))) { case X: newOp = rewriter.create(loc, LLVM::LLVMType::getInt32Ty(dialect)); diff --git a/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h b/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h index 23bfa303708..3ab8e75633e 100644 --- a/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h +++ b/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h @@ -44,7 +44,7 @@ public: f32Func(f32Func), f64Func(f64Func) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { using LLVM::LLVMFuncOp; using LLVM::LLVMType; @@ -69,10 +69,10 @@ public: private: LLVM::LLVMType getFunctionType(LLVM::LLVMType resultType, - ArrayRef operands) const { + ArrayRef operands) const { using LLVM::LLVMType; SmallVector operandTypes; - for (Value *operand : operands) { + for (ValuePtr operand : operands) { operandTypes.push_back(operand->getType().cast()); } return LLVMType::getFunctionTy(resultType, operandTypes, diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp index f342083bee7..840ad6ba701 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp @@ -114,7 +114,7 @@ private: } // Allocate a void pointer on the stack. - Value *allocatePointer(OpBuilder &builder, Location loc) { + ValuePtr allocatePointer(OpBuilder &builder, Location loc) { auto one = builder.create(loc, getInt32Type(), builder.getI32IntegerAttr(1)); return builder.create(loc, getPointerPointerType(), one, @@ -122,9 +122,9 @@ private: } void declareCudaFunctions(Location loc); - Value *setupParamsArray(gpu::LaunchFuncOp launchOp, OpBuilder &builder); - Value *generateKernelNameConstant(StringRef name, Location loc, - OpBuilder &builder); + ValuePtr setupParamsArray(gpu::LaunchFuncOp launchOp, OpBuilder &builder); + ValuePtr generateKernelNameConstant(StringRef name, Location loc, + OpBuilder &builder); void translateGpuLaunchCalls(mlir::gpu::LaunchFuncOp launchOp); public: @@ -248,7 +248,7 @@ void GpuLaunchFuncToCudaCallsPass::declareCudaFunctions(Location loc) { // for (i : [0, NumKernelOperands)) // %array[i] = cast(KernelOperand[i]) // return %array -Value * +ValuePtr GpuLaunchFuncToCudaCallsPass::setupParamsArray(gpu::LaunchFuncOp launchOp, OpBuilder &builder) { auto numKernelOperands = launchOp.getNumKernelOperands(); @@ -264,7 +264,7 @@ GpuLaunchFuncToCudaCallsPass::setupParamsArray(gpu::LaunchFuncOp launchOp, for (unsigned idx = 0; idx < numKernelOperands; ++idx) { auto operand = launchOp.getKernelOperand(idx); auto llvmType = operand->getType().cast(); - Value *memLocation = builder.create( + ValuePtr memLocation = builder.create( loc, llvmType.getPointerTo(), one, /*alignment=*/1); builder.create(loc, operand, memLocation); auto casted = @@ -280,12 +280,12 @@ GpuLaunchFuncToCudaCallsPass::setupParamsArray(gpu::LaunchFuncOp launchOp, getModule().lookupSymbol(kMcuMemHostRegister); auto nullPtr = builder.create(loc, llvmType.getPointerTo()); auto gep = builder.create(loc, llvmType.getPointerTo(), - ArrayRef{nullPtr, one}); + ArrayRef{nullPtr, one}); auto size = builder.create(loc, getInt64Type(), gep); builder.create(loc, ArrayRef{}, builder.getSymbolRefAttr(registerFunc), - ArrayRef{casted, size}); - Value *memLocation = builder.create( + ArrayRef{casted, size}); + ValuePtr memLocation = builder.create( loc, getPointerPointerType(), one, /*alignment=*/1); builder.create(loc, casted, memLocation); casted = @@ -295,7 +295,7 @@ GpuLaunchFuncToCudaCallsPass::setupParamsArray(gpu::LaunchFuncOp launchOp, auto index = builder.create( loc, getInt32Type(), builder.getI32IntegerAttr(idx)); auto gep = builder.create(loc, getPointerPointerType(), array, - ArrayRef{index}); + ArrayRef{index}); builder.create(loc, casted, gep); } return array; @@ -311,7 +311,7 @@ GpuLaunchFuncToCudaCallsPass::setupParamsArray(gpu::LaunchFuncOp launchOp, // %1 = llvm.constant (0 : index) // %2 = llvm.getelementptr %0[%1, %1] : !llvm<"i8*"> // } -Value *GpuLaunchFuncToCudaCallsPass::generateKernelNameConstant( +ValuePtr GpuLaunchFuncToCudaCallsPass::generateKernelNameConstant( StringRef name, Location loc, OpBuilder &builder) { // Make sure the trailing zero is included in the constant. std::vector kernelName(name.begin(), name.end()); @@ -367,7 +367,7 @@ void GpuLaunchFuncToCudaCallsPass::translateGpuLaunchCalls( assert(kernelModule.getName() && "expected a named module"); SmallString<128> nameBuffer(*kernelModule.getName()); nameBuffer.append(kCubinStorageSuffix); - Value *data = LLVM::createGlobalString( + ValuePtr data = LLVM::createGlobalString( loc, builder, nameBuffer.str(), cubinAttr.getValue(), LLVM::Linkage::Internal, getLLVMDialect()); @@ -378,7 +378,7 @@ void GpuLaunchFuncToCudaCallsPass::translateGpuLaunchCalls( getModule().lookupSymbol(cuModuleLoadName); builder.create(loc, ArrayRef{getCUResultType()}, builder.getSymbolRefAttr(cuModuleLoad), - ArrayRef{cuModule, data}); + ArrayRef{cuModule, data}); // Get the function from the module. The name corresponds to the name of // the kernel function. auto cuOwningModuleRef = @@ -390,13 +390,13 @@ void GpuLaunchFuncToCudaCallsPass::translateGpuLaunchCalls( builder.create( loc, ArrayRef{getCUResultType()}, builder.getSymbolRefAttr(cuModuleGetFunction), - ArrayRef{cuFunction, cuOwningModuleRef, kernelName}); + ArrayRef{cuFunction, cuOwningModuleRef, kernelName}); // Grab the global stream needed for execution. auto cuGetStreamHelper = getModule().lookupSymbol(cuGetStreamHelperName); auto cuStream = builder.create( loc, ArrayRef{getPointerType()}, - builder.getSymbolRefAttr(cuGetStreamHelper), ArrayRef{}); + builder.getSymbolRefAttr(cuGetStreamHelper), ArrayRef{}); // Invoke the function with required arguments. auto cuLaunchKernel = getModule().lookupSymbol(cuLaunchKernelName); @@ -408,19 +408,19 @@ void GpuLaunchFuncToCudaCallsPass::translateGpuLaunchCalls( builder.create( loc, ArrayRef{getCUResultType()}, builder.getSymbolRefAttr(cuLaunchKernel), - ArrayRef{cuFunctionRef, launchOp.getOperand(0), - launchOp.getOperand(1), launchOp.getOperand(2), - launchOp.getOperand(3), launchOp.getOperand(4), - launchOp.getOperand(5), zero, /* sharedMemBytes */ - cuStream.getResult(0), /* stream */ - paramsArray, /* kernel params */ - nullpointer /* extra */}); + ArrayRef{cuFunctionRef, launchOp.getOperand(0), + launchOp.getOperand(1), launchOp.getOperand(2), + launchOp.getOperand(3), launchOp.getOperand(4), + launchOp.getOperand(5), zero, /* sharedMemBytes */ + cuStream.getResult(0), /* stream */ + paramsArray, /* kernel params */ + nullpointer /* extra */}); // Sync on the stream to make it synchronous. auto cuStreamSync = getModule().lookupSymbol(cuStreamSynchronizeName); builder.create(loc, ArrayRef{getCUResultType()}, builder.getSymbolRefAttr(cuStreamSync), - ArrayRef(cuStream.getResult(0))); + ArrayRef(cuStream.getResult(0))); launchOp.erase(); } diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp index 220df53b977..bf18ea03dab 100644 --- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp +++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp @@ -60,8 +60,8 @@ public: /// Converts all_reduce op to LLVM/NVVM ops. struct GPUAllReduceOpLowering : public LLVMOpLowering { - using AccumulatorFactory = std::function; + using AccumulatorFactory = std::function; explicit GPUAllReduceOpLowering(LLVMTypeConverter &lowering_) : LLVMOpLowering(gpu::AllReduceOp::getOperationName(), @@ -69,10 +69,10 @@ struct GPUAllReduceOpLowering : public LLVMOpLowering { int32Type(LLVM::LLVMType::getInt32Ty(lowering_.getDialect())) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { Location loc = op->getLoc(); - Value *operand = operands.front(); + ValuePtr operand = operands.front(); // TODO(csigg): Generalize to other types of accumulation. assert(op->getOperand(0)->getType().isIntOrFloat()); @@ -81,7 +81,7 @@ struct GPUAllReduceOpLowering : public LLVMOpLowering { AccumulatorFactory factory = getFactory(cast(op), operand); assert(factory && "failed to create accumulator factory"); - Value *result = createBlockReduce(loc, operand, factory, rewriter); + ValuePtr result = createBlockReduce(loc, operand, factory, rewriter); rewriter.replaceOp(op, {result}); return matchSuccess(); @@ -91,7 +91,7 @@ private: /// Returns an accumulator factory using either the op attribute or the body /// region. AccumulatorFactory getFactory(gpu::AllReduceOp allReduce, - Value *operand) const { + ValuePtr operand) const { if (!allReduce.body().empty()) { return getFactory(allReduce.body()); } @@ -106,7 +106,7 @@ private: /// block is expected to have 2 arguments. The gpu.yield return the /// accumulated value of the same type. AccumulatorFactory getFactory(Region &body) const { - return AccumulatorFactory([&](Location loc, Value *lhs, Value *rhs, + return AccumulatorFactory([&](Location loc, ValuePtr lhs, ValuePtr rhs, ConversionPatternRewriter &rewriter) { Block *block = rewriter.getInsertionBlock(); Block *split = rewriter.splitBlock(block, rewriter.getInsertionPoint()); @@ -120,7 +120,7 @@ private: // Add branch before inserted body, into body. block = block->getNextNode(); - rewriter.create(loc, ArrayRef{}, + rewriter.create(loc, ArrayRef{}, llvm::makeArrayRef(block), ValueRange()); // Replace all gpu.yield ops with branch out of body. @@ -130,7 +130,7 @@ private: continue; rewriter.setInsertionPointToEnd(block); rewriter.replaceOpWithNewOp( - terminator, ArrayRef{}, llvm::makeArrayRef(split), + terminator, ArrayRef{}, llvm::makeArrayRef(split), ValueRange(terminator->getOperand(0))); } @@ -161,7 +161,7 @@ private: /// Returns an accumulator factory that creates an op of type T. template AccumulatorFactory getFactory() const { - return [](Location loc, Value *lhs, Value *rhs, + return [](Location loc, ValuePtr lhs, ValuePtr rhs, ConversionPatternRewriter &rewriter) { return rewriter.create(loc, lhs->getType(), lhs, rhs); }; @@ -203,60 +203,60 @@ private: /// %result = llvm.load %result_ptr /// return %result /// - Value *createBlockReduce(Location loc, Value *operand, - AccumulatorFactory &accumFactory, - ConversionPatternRewriter &rewriter) const { + ValuePtr createBlockReduce(Location loc, ValuePtr operand, + AccumulatorFactory &accumFactory, + ConversionPatternRewriter &rewriter) const { auto type = operand->getType().cast(); // Create shared memory array to store the warp reduction. auto module = operand->getDefiningOp()->getParentOfType(); assert(module && "op must belong to a module"); - Value *sharedMemPtr = + ValuePtr sharedMemPtr = createSharedMemoryArray(loc, module, type, kWarpSize, rewriter); - Value *zero = rewriter.create( + ValuePtr zero = rewriter.create( loc, int32Type, rewriter.getI32IntegerAttr(0u)); - Value *laneId = rewriter.create(loc, int32Type); - Value *isFirstLane = rewriter.create( + ValuePtr laneId = rewriter.create(loc, int32Type); + ValuePtr isFirstLane = rewriter.create( loc, LLVM::ICmpPredicate::eq, laneId, zero); - Value *threadIdx = getLinearThreadIndex(loc, rewriter); - Value *blockSize = getBlockSize(loc, rewriter); - Value *activeWidth = getActiveWidth(loc, threadIdx, blockSize, rewriter); + ValuePtr threadIdx = getLinearThreadIndex(loc, rewriter); + ValuePtr blockSize = getBlockSize(loc, rewriter); + ValuePtr activeWidth = getActiveWidth(loc, threadIdx, blockSize, rewriter); // Reduce elements within each warp to produce the intermediate results. - Value *warpReduce = createWarpReduce(loc, activeWidth, laneId, operand, - accumFactory, rewriter); + ValuePtr warpReduce = createWarpReduce(loc, activeWidth, laneId, operand, + accumFactory, rewriter); // Write the intermediate results to shared memory, using the first lane of // each warp. createPredicatedBlock(loc, rewriter, isFirstLane, [&] { - Value *warpId = getDivideByWarpSize(threadIdx, rewriter); - Value *storeDst = rewriter.create( - loc, type, sharedMemPtr, ArrayRef({zero, warpId})); + ValuePtr warpId = getDivideByWarpSize(threadIdx, rewriter); + ValuePtr storeDst = rewriter.create( + loc, type, sharedMemPtr, ArrayRef({zero, warpId})); rewriter.create(loc, warpReduce, storeDst); }); rewriter.create(loc); - Value *numWarps = getNumWarps(loc, blockSize, rewriter); - Value *isValidWarp = rewriter.create( + ValuePtr numWarps = getNumWarps(loc, blockSize, rewriter); + ValuePtr isValidWarp = rewriter.create( loc, LLVM::ICmpPredicate::slt, threadIdx, numWarps); - Value *resultPtr = rewriter.create( - loc, type, sharedMemPtr, ArrayRef({zero, zero})); + ValuePtr resultPtr = rewriter.create( + loc, type, sharedMemPtr, ArrayRef({zero, zero})); // Use the first numWarps threads to reduce the intermediate results from // shared memory. The final result is written to shared memory again. createPredicatedBlock(loc, rewriter, isValidWarp, [&] { - Value *loadSrc = rewriter.create( - loc, type, sharedMemPtr, ArrayRef({zero, threadIdx})); - Value *value = rewriter.create(loc, type, loadSrc); - Value *result = createWarpReduce(loc, numWarps, laneId, value, - accumFactory, rewriter); + ValuePtr loadSrc = rewriter.create( + loc, type, sharedMemPtr, ArrayRef({zero, threadIdx})); + ValuePtr value = rewriter.create(loc, type, loadSrc); + ValuePtr result = createWarpReduce(loc, numWarps, laneId, value, + accumFactory, rewriter); rewriter.create(loc, result, resultPtr); }); rewriter.create(loc); // Load and return result from shared memory. - Value *result = rewriter.create(loc, type, resultPtr); + ValuePtr result = rewriter.create(loc, type, resultPtr); return result; } @@ -274,7 +274,7 @@ private: /// template void createIf(Location loc, ConversionPatternRewriter &rewriter, - Value *condition, ThenOpsFactory &&thenOpsFactory, + ValuePtr condition, ThenOpsFactory &&thenOpsFactory, ElseOpsFactory &&elseOpsFactory) const { Block *currentBlock = rewriter.getInsertionBlock(); auto currentPoint = rewriter.getInsertionPoint(); @@ -288,7 +288,7 @@ private: ArrayRef{thenBlock, elseBlock}); auto addBranch = [&](ValueRange operands) { - rewriter.create(loc, ArrayRef{}, + rewriter.create(loc, ArrayRef{}, llvm::makeArrayRef(continueBlock), llvm::makeArrayRef(operands)); }; @@ -303,32 +303,32 @@ private: assert(thenOperands.size() == elseOperands.size()); rewriter.setInsertionPointToStart(continueBlock); - for (auto *operand : thenOperands) + for (auto operand : thenOperands) continueBlock->addArgument(operand->getType()); } /// Shortcut for createIf with empty else block and no block operands. template void createPredicatedBlock(Location loc, ConversionPatternRewriter &rewriter, - Value *condition, + ValuePtr condition, Factory &&predicatedOpsFactory) const { createIf( loc, rewriter, condition, [&] { predicatedOpsFactory(); - return ArrayRef(); + return ArrayRef(); }, - [&] { return ArrayRef(); }); + [&] { return ArrayRef(); }); } /// Creates a reduction across the first activeWidth lanes of a warp. /// The first lane returns the result, all others return values are undefined. - Value *createWarpReduce(Location loc, Value *activeWidth, Value *laneId, - Value *operand, AccumulatorFactory accumFactory, - ConversionPatternRewriter &rewriter) const { - Value *warpSize = rewriter.create( + ValuePtr createWarpReduce(Location loc, ValuePtr activeWidth, ValuePtr laneId, + ValuePtr operand, AccumulatorFactory accumFactory, + ConversionPatternRewriter &rewriter) const { + ValuePtr warpSize = rewriter.create( loc, int32Type, rewriter.getI32IntegerAttr(kWarpSize)); - Value *isPartialWarp = rewriter.create( + ValuePtr isPartialWarp = rewriter.create( loc, LLVM::ICmpPredicate::slt, activeWidth, warpSize); auto type = operand->getType().cast(); @@ -336,16 +336,16 @@ private: loc, rewriter, isPartialWarp, // Generate reduction over a (potentially) partial warp. [&] { - Value *value = operand; - Value *one = rewriter.create( + ValuePtr value = operand; + ValuePtr one = rewriter.create( loc, int32Type, rewriter.getI32IntegerAttr(1)); // Bit mask of active lanes: `(1 << activeWidth) - 1`. - Value *activeMask = rewriter.create( + ValuePtr activeMask = rewriter.create( loc, int32Type, rewriter.create(loc, int32Type, one, activeWidth), one); // Clamp lane: `activeWidth - 1` - Value *maskAndClamp = + ValuePtr maskAndClamp = rewriter.create(loc, int32Type, activeWidth, one); auto dialect = lowering.getDialect(); auto predTy = LLVM::LLVMType::getInt1Ty(dialect); @@ -356,53 +356,53 @@ private: // lane is within the active range. All lanes contain the final // result, but only the first lane's result is used. for (int i = 1; i < kWarpSize; i <<= 1) { - Value *offset = rewriter.create( + ValuePtr offset = rewriter.create( loc, int32Type, rewriter.getI32IntegerAttr(i)); - Value *shfl = rewriter.create( + ValuePtr shfl = rewriter.create( loc, shflTy, activeMask, value, offset, maskAndClamp, returnValueAndIsValidAttr); - Value *isActiveSrcLane = rewriter.create( + ValuePtr isActiveSrcLane = rewriter.create( loc, predTy, shfl, rewriter.getIndexArrayAttr(1)); // Skip the accumulation if the shuffle op read from a lane outside // of the active range. createIf( loc, rewriter, isActiveSrcLane, [&] { - Value *shflValue = rewriter.create( + ValuePtr shflValue = rewriter.create( loc, type, shfl, rewriter.getIndexArrayAttr(0)); - return SmallVector{ + return SmallVector{ accumFactory(loc, value, shflValue, rewriter)}; }, [&] { return llvm::makeArrayRef(value); }); value = rewriter.getInsertionBlock()->getArgument(0); } - return SmallVector{value}; + return SmallVector{value}; }, // Generate a reduction over the entire warp. This is a specialization // of the above reduction with unconditional accumulation. [&] { - Value *value = operand; - Value *activeMask = rewriter.create( + ValuePtr value = operand; + ValuePtr activeMask = rewriter.create( loc, int32Type, rewriter.getI32IntegerAttr(~0u)); - Value *maskAndClamp = rewriter.create( + ValuePtr maskAndClamp = rewriter.create( loc, int32Type, rewriter.getI32IntegerAttr(kWarpSize - 1)); for (int i = 1; i < kWarpSize; i <<= 1) { - Value *offset = rewriter.create( + ValuePtr offset = rewriter.create( loc, int32Type, rewriter.getI32IntegerAttr(i)); - Value *shflValue = rewriter.create( + ValuePtr shflValue = rewriter.create( loc, type, activeMask, value, offset, maskAndClamp, /*return_value_and_is_valid=*/UnitAttr()); value = accumFactory(loc, value, shflValue, rewriter); } - return SmallVector{value}; + return SmallVector{value}; }); return rewriter.getInsertionBlock()->getArgument(0); } /// Creates a global array stored in shared memory. - Value *createSharedMemoryArray(Location loc, ModuleOp module, - LLVM::LLVMType elementType, int numElements, - ConversionPatternRewriter &rewriter) const { + ValuePtr createSharedMemoryArray(Location loc, ModuleOp module, + LLVM::LLVMType elementType, int numElements, + ConversionPatternRewriter &rewriter) const { OpBuilder builder(module.getBodyRegion()); auto arrayType = LLVM::LLVMType::getArrayTy(elementType, numElements); @@ -416,31 +416,32 @@ private: } /// Returns the index of the thread within the block. - Value *getLinearThreadIndex(Location loc, - ConversionPatternRewriter &rewriter) const { - Value *dimX = rewriter.create(loc, int32Type); - Value *dimY = rewriter.create(loc, int32Type); - Value *idX = rewriter.create(loc, int32Type); - Value *idY = rewriter.create(loc, int32Type); - Value *idZ = rewriter.create(loc, int32Type); - Value *tmp1 = rewriter.create(loc, int32Type, idZ, dimY); - Value *tmp2 = rewriter.create(loc, int32Type, tmp1, idY); - Value *tmp3 = rewriter.create(loc, int32Type, tmp2, dimX); + ValuePtr getLinearThreadIndex(Location loc, + ConversionPatternRewriter &rewriter) const { + ValuePtr dimX = rewriter.create(loc, int32Type); + ValuePtr dimY = rewriter.create(loc, int32Type); + ValuePtr idX = rewriter.create(loc, int32Type); + ValuePtr idY = rewriter.create(loc, int32Type); + ValuePtr idZ = rewriter.create(loc, int32Type); + ValuePtr tmp1 = rewriter.create(loc, int32Type, idZ, dimY); + ValuePtr tmp2 = rewriter.create(loc, int32Type, tmp1, idY); + ValuePtr tmp3 = rewriter.create(loc, int32Type, tmp2, dimX); return rewriter.create(loc, int32Type, tmp3, idX); } /// Returns the number of threads in the block. - Value *getBlockSize(Location loc, ConversionPatternRewriter &rewriter) const { - Value *dimX = rewriter.create(loc, int32Type); - Value *dimY = rewriter.create(loc, int32Type); - Value *dimZ = rewriter.create(loc, int32Type); - Value *dimXY = rewriter.create(loc, int32Type, dimX, dimY); + ValuePtr getBlockSize(Location loc, + ConversionPatternRewriter &rewriter) const { + ValuePtr dimX = rewriter.create(loc, int32Type); + ValuePtr dimY = rewriter.create(loc, int32Type); + ValuePtr dimZ = rewriter.create(loc, int32Type); + ValuePtr dimXY = rewriter.create(loc, int32Type, dimX, dimY); return rewriter.create(loc, int32Type, dimXY, dimZ); } /// Returns the number of warps in the block. - Value *getNumWarps(Location loc, Value *blockSize, - ConversionPatternRewriter &rewriter) const { + ValuePtr getNumWarps(Location loc, ValuePtr blockSize, + ConversionPatternRewriter &rewriter) const { auto warpSizeMinusOne = rewriter.create( loc, int32Type, rewriter.getI32IntegerAttr(kWarpSize - 1)); auto biasedBlockSize = rewriter.create( @@ -449,19 +450,19 @@ private: } /// Returns the number of active threads in the warp, not clamped to 32. - Value *getActiveWidth(Location loc, Value *threadIdx, Value *blockSize, - ConversionPatternRewriter &rewriter) const { - Value *threadIdxMask = rewriter.create( + ValuePtr getActiveWidth(Location loc, ValuePtr threadIdx, ValuePtr blockSize, + ConversionPatternRewriter &rewriter) const { + ValuePtr threadIdxMask = rewriter.create( loc, int32Type, rewriter.getI32IntegerAttr(~(kWarpSize - 1))); - Value *numThreadsWithSmallerWarpId = + ValuePtr numThreadsWithSmallerWarpId = rewriter.create(loc, threadIdx, threadIdxMask); return rewriter.create(loc, blockSize, numThreadsWithSmallerWarpId); } /// Returns value divided by the warp size (i.e. 32). - Value *getDivideByWarpSize(Value *value, - ConversionPatternRewriter &rewriter) const { + ValuePtr getDivideByWarpSize(ValuePtr value, + ConversionPatternRewriter &rewriter) const { auto loc = value->getLoc(); auto warpSize = rewriter.create( loc, int32Type, rewriter.getI32IntegerAttr(kWarpSize)); @@ -495,7 +496,7 @@ struct GPUShuffleOpLowering : public LLVMOpLowering { /// %shfl_pred = llvm.extractvalue %shfl[1 : index] : /// !llvm<"{ float, i1 }"> PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { Location loc = op->getLoc(); gpu::ShuffleOpOperandAdaptor adaptor(operands); @@ -506,24 +507,24 @@ struct GPUShuffleOpLowering : public LLVMOpLowering { auto predTy = LLVM::LLVMType::getInt1Ty(dialect); auto resultTy = LLVM::LLVMType::getStructTy(dialect, {valueTy, predTy}); - Value *one = rewriter.create( + ValuePtr one = rewriter.create( loc, int32Type, rewriter.getI32IntegerAttr(1)); // Bit mask of active lanes: `(1 << activeWidth) - 1`. - Value *activeMask = rewriter.create( + ValuePtr activeMask = rewriter.create( loc, int32Type, rewriter.create(loc, int32Type, one, adaptor.width()), one); // Clamp lane: `activeWidth - 1` - Value *maskAndClamp = + ValuePtr maskAndClamp = rewriter.create(loc, int32Type, adaptor.width(), one); auto returnValueAndIsValidAttr = rewriter.getUnitAttr(); - Value *shfl = rewriter.create( + ValuePtr shfl = rewriter.create( loc, resultTy, activeMask, adaptor.value(), adaptor.offset(), maskAndClamp, returnValueAndIsValidAttr); - Value *shflValue = rewriter.create( + ValuePtr shflValue = rewriter.create( loc, valueTy, shfl, rewriter.getIndexArrayAttr(0)); - Value *isActiveSrcLane = rewriter.create( + ValuePtr isActiveSrcLane = rewriter.create( loc, predTy, shfl, rewriter.getIndexArrayAttr(1)); rewriter.replaceOp(op, {shflValue, isActiveSrcLane}); @@ -538,7 +539,7 @@ struct GPUFuncOpLowering : LLVMOpLowering { typeConverter) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { assert(operands.empty() && "func op is not expected to have operands"); auto gpuFuncOp = cast(op); @@ -547,7 +548,7 @@ struct GPUFuncOpLowering : LLVMOpLowering { SmallVector workgroupBuffers; workgroupBuffers.reserve(gpuFuncOp.getNumWorkgroupAttributions()); for (auto en : llvm::enumerate(gpuFuncOp.getWorkgroupAttributions())) { - Value *attribution = en.value(); + ValuePtr attribution = en.value(); auto type = attribution->getType().dyn_cast(); assert(type && type.hasStaticShape() && "unexpected type in attribution"); @@ -604,23 +605,23 @@ struct GPUFuncOpLowering : LLVMOpLowering { unsigned numProperArguments = gpuFuncOp.getNumArguments(); auto i32Type = LLVM::LLVMType::getInt32Ty(lowering.getDialect()); - Value *zero = nullptr; + ValuePtr zero = nullptr; if (!workgroupBuffers.empty()) zero = rewriter.create(loc, i32Type, rewriter.getI32IntegerAttr(0)); for (auto en : llvm::enumerate(workgroupBuffers)) { LLVM::GlobalOp global = en.value(); - Value *address = rewriter.create(loc, global); + ValuePtr address = rewriter.create(loc, global); auto elementType = global.getType().getArrayElementType(); - Value *memory = rewriter.create( + ValuePtr memory = rewriter.create( loc, elementType.getPointerTo(global.addr_space().getZExtValue()), - address, ArrayRef{zero, zero}); + address, ArrayRef{zero, zero}); // Build a memref descriptor pointing to the buffer to plug with the // existing memref infrastructure. This may use more registers than // otherwise necessary given that memref sizes are fixed, but we can try // and canonicalize that away later. - Value *attribution = gpuFuncOp.getWorkgroupAttributions()[en.index()]; + ValuePtr attribution = gpuFuncOp.getWorkgroupAttributions()[en.index()]; auto type = attribution->getType().cast(); auto descr = MemRefDescriptor::fromStaticShape(rewriter, loc, lowering, type, memory); @@ -632,7 +633,7 @@ struct GPUFuncOpLowering : LLVMOpLowering { gpuFuncOp.getNumWorkgroupAttributions(); auto int64Ty = LLVM::LLVMType::getInt64Ty(lowering.getDialect()); for (auto en : llvm::enumerate(gpuFuncOp.getPrivateAttributions())) { - Value *attribution = en.value(); + ValuePtr attribution = en.value(); auto type = attribution->getType().cast(); assert(type && type.hasStaticShape() && "unexpected type in attribution"); @@ -643,10 +644,10 @@ struct GPUFuncOpLowering : LLVMOpLowering { auto ptrType = lowering.convertType(type.getElementType()) .cast() .getPointerTo(); - Value *numElements = rewriter.create( + ValuePtr numElements = rewriter.create( gpuFuncOp.getLoc(), int64Ty, rewriter.getI64IntegerAttr(type.getNumElements())); - Value *allocated = rewriter.create( + ValuePtr allocated = rewriter.create( gpuFuncOp.getLoc(), ptrType, numElements, /*alignment=*/0); auto descr = MemRefDescriptor::fromStaticShape(rewriter, loc, lowering, type, allocated); @@ -674,8 +675,8 @@ struct GPUFuncOpLowering : LLVMOpLowering { !en.value().isa()) continue; - BlockArgument *arg = block.getArgument(en.index()); - Value *loaded = rewriter.create(loc, arg); + BlockArgumentPtr arg = block.getArgument(en.index()); + ValuePtr loaded = rewriter.create(loc, arg); rewriter.replaceUsesOfBlockArgument(arg, loaded); } } @@ -692,7 +693,7 @@ struct GPUReturnOpLowering : public LLVMOpLowering { typeConverter) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { rewriter.replaceOpWithNewOp(op, operands, ArrayRef()); diff --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp index 42483a6e5df..0c34fc2b8e1 100644 --- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp @@ -36,7 +36,7 @@ public: using SPIRVOpLowering::SPIRVOpLowering; PatternMatchResult - matchAndRewrite(loop::ForOp forOp, ArrayRef operands, + matchAndRewrite(loop::ForOp forOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; @@ -48,7 +48,7 @@ public: using SPIRVOpLowering::SPIRVOpLowering; PatternMatchResult - matchAndRewrite(SourceOp op, ArrayRef operands, + matchAndRewrite(SourceOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; @@ -65,7 +65,7 @@ public: } PatternMatchResult - matchAndRewrite(gpu::GPUFuncOp funcOp, ArrayRef operands, + matchAndRewrite(gpu::GPUFuncOp funcOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; private: @@ -79,7 +79,7 @@ public: using SPIRVOpLowering::SPIRVOpLowering; PatternMatchResult - matchAndRewrite(ModuleOp moduleOp, ArrayRef operands, + matchAndRewrite(ModuleOp moduleOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; @@ -92,7 +92,7 @@ public: using SPIRVOpLowering::SPIRVOpLowering; PatternMatchResult - matchAndRewrite(ModuleTerminatorOp terminatorOp, ArrayRef operands, + matchAndRewrite(ModuleTerminatorOp terminatorOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; @@ -103,7 +103,7 @@ public: using SPIRVOpLowering::SPIRVOpLowering; PatternMatchResult - matchAndRewrite(gpu::ReturnOp returnOp, ArrayRef operands, + matchAndRewrite(gpu::ReturnOp returnOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; @@ -114,7 +114,7 @@ public: //===----------------------------------------------------------------------===// PatternMatchResult -ForOpConversion::matchAndRewrite(loop::ForOp forOp, ArrayRef operands, +ForOpConversion::matchAndRewrite(loop::ForOp forOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const { // loop::ForOp can be lowered to the structured control flow represented by // spirv::LoopOp by making the continue block of the spirv::LoopOp the loop @@ -135,7 +135,7 @@ ForOpConversion::matchAndRewrite(loop::ForOp forOp, ArrayRef operands, loopOp.body().getBlocks().insert(std::next(loopOp.body().begin(), 1), header); // Create the new induction variable to use. - BlockArgument *newIndVar = + BlockArgumentPtr newIndVar = header->addArgument(forOperands.lowerBound()->getType()); Block *body = forOp.getBody(); @@ -166,7 +166,7 @@ ForOpConversion::matchAndRewrite(loop::ForOp forOp, ArrayRef operands, auto cmpOp = rewriter.create( loc, rewriter.getI1Type(), newIndVar, forOperands.upperBound()); rewriter.create( - loc, cmpOp, body, ArrayRef(), mergeBlock, ArrayRef()); + loc, cmpOp, body, ArrayRef(), mergeBlock, ArrayRef()); // Generate instructions to increment the step of the induction variable and // branch to the header. @@ -174,7 +174,7 @@ ForOpConversion::matchAndRewrite(loop::ForOp forOp, ArrayRef operands, rewriter.setInsertionPointToEnd(continueBlock); // Add the step to the induction variable and branch to the header. - Value *updatedIndVar = rewriter.create( + ValuePtr updatedIndVar = rewriter.create( loc, newIndVar->getType(), newIndVar, forOperands.step()); rewriter.create(loc, header, updatedIndVar); @@ -188,7 +188,7 @@ ForOpConversion::matchAndRewrite(loop::ForOp forOp, ArrayRef operands, template PatternMatchResult LaunchConfigConversion::matchAndRewrite( - SourceOp op, ArrayRef operands, + SourceOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const { auto dimAttr = op.getOperation()->template getAttrOfType("dimension"); @@ -267,7 +267,7 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, SPIRVTypeConverter &typeConverter, PatternMatchResult KernelFnConversion::matchAndRewrite(gpu::GPUFuncOp funcOp, - ArrayRef operands, + ArrayRef operands, ConversionPatternRewriter &rewriter) const { if (!gpu::GPUDialect::isKernel(funcOp)) { return matchFailure(); @@ -297,7 +297,7 @@ KernelFnConversion::matchAndRewrite(gpu::GPUFuncOp funcOp, //===----------------------------------------------------------------------===// PatternMatchResult KernelModuleConversion::matchAndRewrite( - ModuleOp moduleOp, ArrayRef operands, + ModuleOp moduleOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const { if (!moduleOp.getAttrOfType( gpu::GPUDialect::getKernelModuleAttrName())) { @@ -327,7 +327,7 @@ PatternMatchResult KernelModuleConversion::matchAndRewrite( //===----------------------------------------------------------------------===// PatternMatchResult KernelModuleTerminatorConversion::matchAndRewrite( - ModuleTerminatorOp terminatorOp, ArrayRef operands, + ModuleTerminatorOp terminatorOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const { rewriter.replaceOpWithNewOp(terminatorOp); return matchSuccess(); @@ -338,7 +338,7 @@ PatternMatchResult KernelModuleTerminatorConversion::matchAndRewrite( //===----------------------------------------------------------------------===// PatternMatchResult GPUReturnOpConversion::matchAndRewrite( - gpu::ReturnOp returnOp, ArrayRef operands, + gpu::ReturnOp returnOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const { if (!operands.empty()) return matchFailure(); diff --git a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp index 3eb23c19dc7..8b6b9fb7930 100644 --- a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp +++ b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp @@ -120,21 +120,23 @@ public: BaseViewConversionHelper(Type type) : d(MemRefDescriptor::undef(rewriter(), loc(), type)) {} - BaseViewConversionHelper(Value *v) : d(v) {} + BaseViewConversionHelper(ValuePtr v) : d(v) {} /// Wrappers around MemRefDescriptor that use EDSC builder and location. - Value *allocatedPtr() { return d.allocatedPtr(rewriter(), loc()); } - void setAllocatedPtr(Value *v) { d.setAllocatedPtr(rewriter(), loc(), v); } - Value *alignedPtr() { return d.alignedPtr(rewriter(), loc()); } - void setAlignedPtr(Value *v) { d.setAlignedPtr(rewriter(), loc(), v); } - Value *offset() { return d.offset(rewriter(), loc()); } - void setOffset(Value *v) { d.setOffset(rewriter(), loc(), v); } - Value *size(unsigned i) { return d.size(rewriter(), loc(), i); } - void setSize(unsigned i, Value *v) { d.setSize(rewriter(), loc(), i, v); } - Value *stride(unsigned i) { return d.stride(rewriter(), loc(), i); } - void setStride(unsigned i, Value *v) { d.setStride(rewriter(), loc(), i, v); } - - operator Value *() { return d; } + ValuePtr allocatedPtr() { return d.allocatedPtr(rewriter(), loc()); } + void setAllocatedPtr(ValuePtr v) { d.setAllocatedPtr(rewriter(), loc(), v); } + ValuePtr alignedPtr() { return d.alignedPtr(rewriter(), loc()); } + void setAlignedPtr(ValuePtr v) { d.setAlignedPtr(rewriter(), loc(), v); } + ValuePtr offset() { return d.offset(rewriter(), loc()); } + void setOffset(ValuePtr v) { d.setOffset(rewriter(), loc(), v); } + ValuePtr size(unsigned i) { return d.size(rewriter(), loc(), i); } + void setSize(unsigned i, ValuePtr v) { d.setSize(rewriter(), loc(), i, v); } + ValuePtr stride(unsigned i) { return d.stride(rewriter(), loc(), i); } + void setStride(unsigned i, ValuePtr v) { + d.setStride(rewriter(), loc(), i, v); + } + + operator ValuePtr() { return d; } private: OpBuilder &rewriter() { return ScopedContext::getBuilder(); } @@ -151,7 +153,7 @@ public: : LLVMOpLowering(RangeOp::getOperationName(), context, lowering_) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto rangeOp = cast(op); auto rangeDescriptorTy = @@ -161,7 +163,7 @@ public: // Fill in an aggregate value of the descriptor. RangeOpOperandAdaptor adaptor(operands); - Value *desc = llvm_undef(rangeDescriptorTy); + ValuePtr desc = llvm_undef(rangeDescriptorTy); desc = insertvalue(desc, adaptor.min(), rewriter.getI64ArrayAttr(0)); desc = insertvalue(desc, adaptor.max(), rewriter.getI64ArrayAttr(1)); desc = insertvalue(desc, adaptor.step(), rewriter.getI64ArrayAttr(2)); @@ -184,7 +186,7 @@ public: : LLVMOpLowering(SliceOp::getOperationName(), context, lowering_) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { edsc::ScopedContext context(rewriter, op->getLoc()); SliceOpOperandAdaptor adaptor(operands); @@ -198,7 +200,7 @@ public: BaseViewConversionHelper desc(lowering.convertType(sliceOp.getViewType())); // TODO(ntv): extract sizes and emit asserts. - SmallVector strides(memRefType.getRank()); + SmallVector strides(memRefType.getRank()); for (int i = 0, e = memRefType.getRank(); i < e; ++i) strides[i] = baseDesc.stride(i); @@ -207,10 +209,10 @@ public: }; // Compute base offset. - Value *baseOffset = baseDesc.offset(); + ValuePtr baseOffset = baseDesc.offset(); for (int i = 0, e = memRefType.getRank(); i < e; ++i) { - Value *indexing = adaptor.indexings()[i]; - Value *min = indexing; + ValuePtr indexing = adaptor.indexings()[i]; + ValuePtr min = indexing; if (sliceOp.indexing(i)->getType().isa()) min = extractvalue(int64Ty, indexing, pos(0)); baseOffset = add(baseOffset, mul(min, strides[i])); @@ -227,29 +229,29 @@ public: if (sliceOp.getViewType().getRank() == 0) return rewriter.replaceOp(op, {desc}), matchSuccess(); - Value *zero = + ValuePtr zero = constant(int64Ty, rewriter.getIntegerAttr(rewriter.getIndexType(), 0)); // Compute and insert view sizes (max - min along the range) and strides. // Skip the non-range operands as they will be projected away from the view. int numNewDims = 0; for (auto en : llvm::enumerate(sliceOp.indexings())) { - Value *indexing = en.value(); + ValuePtr indexing = en.value(); if (indexing->getType().isa()) { int rank = en.index(); - Value *rangeDescriptor = adaptor.indexings()[rank]; - Value *min = extractvalue(int64Ty, rangeDescriptor, pos(0)); - Value *max = extractvalue(int64Ty, rangeDescriptor, pos(1)); - Value *step = extractvalue(int64Ty, rangeDescriptor, pos(2)); - Value *baseSize = baseDesc.size(rank); + ValuePtr rangeDescriptor = adaptor.indexings()[rank]; + ValuePtr min = extractvalue(int64Ty, rangeDescriptor, pos(0)); + ValuePtr max = extractvalue(int64Ty, rangeDescriptor, pos(1)); + ValuePtr step = extractvalue(int64Ty, rangeDescriptor, pos(2)); + ValuePtr baseSize = baseDesc.size(rank); // Bound upper by base view upper bound. max = llvm_select(llvm_icmp(ICmpPredicate::slt, max, baseSize), max, baseSize); - Value *size = sub(max, min); + ValuePtr size = sub(max, min); // Bound lower by zero. size = llvm_select(llvm_icmp(ICmpPredicate::slt, size, zero), zero, size); - Value *stride = mul(strides[rank], step); + ValuePtr stride = mul(strides[rank], step); desc.setSize(numNewDims, size); desc.setStride(numNewDims, stride); ++numNewDims; @@ -275,7 +277,7 @@ public: : LLVMOpLowering(TransposeOp::getOperationName(), context, lowering_) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { // Initialize the common boilerplate and alloca at the top of the FuncOp. edsc::ScopedContext context(rewriter, op->getLoc()); @@ -318,7 +320,7 @@ public: : LLVMOpLowering(YieldOp::getOperationName(), context, lowering_) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { rewriter.replaceOpWithNewOp(op, operands); return matchSuccess(); @@ -453,7 +455,7 @@ public: op.getLoc(), rewriter.getIntegerAttr(rewriter.getIndexType(), 0)); auto indexedGenericOp = cast(op); auto numLoops = indexedGenericOp.getNumLoops(); - SmallVector operands; + SmallVector operands; operands.reserve(numLoops + op.getNumOperands()); for (unsigned i = 0; i < numLoops; ++i) { operands.push_back(zero); @@ -477,7 +479,7 @@ public: PatternMatchResult matchAndRewrite(CopyOp op, PatternRewriter &rewriter) const override { - Value *in = op.input(), *out = op.output(); + ValuePtr in = op.input(), out = op.output(); // If either inputPerm or outputPerm are non-identities, insert transposes. auto inputPerm = op.inputPermutation(); diff --git a/mlir/lib/Conversion/LoopToStandard/ConvertLoopToStandard.cpp b/mlir/lib/Conversion/LoopToStandard/ConvertLoopToStandard.cpp index ff93ce58fd4..d8df7487e71 100644 --- a/mlir/lib/Conversion/LoopToStandard/ConvertLoopToStandard.cpp +++ b/mlir/lib/Conversion/LoopToStandard/ConvertLoopToStandard.cpp @@ -182,22 +182,22 @@ ForLowering::matchAndRewrite(ForOp forOp, PatternRewriter &rewriter) const { rewriter.splitBlock(conditionBlock, conditionBlock->begin()); auto *lastBodyBlock = &forOp.region().back(); rewriter.inlineRegionBefore(forOp.region(), endBlock); - auto *iv = conditionBlock->getArgument(0); + auto iv = conditionBlock->getArgument(0); // Append the induction variable stepping logic to the last body block and // branch back to the condition block. Construct an expression f : // (x -> x+step) and apply this expression to the induction variable. rewriter.setInsertionPointToEnd(lastBodyBlock); - auto *step = forOp.step(); - auto *stepped = rewriter.create(loc, iv, step).getResult(); + auto step = forOp.step(); + auto stepped = rewriter.create(loc, iv, step).getResult(); if (!stepped) return matchFailure(); rewriter.create(loc, conditionBlock, stepped); // Compute loop bounds before branching to the condition. rewriter.setInsertionPointToEnd(initBlock); - Value *lowerBound = forOp.lowerBound(); - Value *upperBound = forOp.upperBound(); + ValuePtr lowerBound = forOp.lowerBound(); + ValuePtr upperBound = forOp.upperBound(); if (!lowerBound || !upperBound) return matchFailure(); rewriter.create(loc, conditionBlock, lowerBound); @@ -208,8 +208,8 @@ ForLowering::matchAndRewrite(ForOp forOp, PatternRewriter &rewriter) const { rewriter.create(loc, CmpIPredicate::slt, iv, upperBound); rewriter.create(loc, comparison, firstBodyBlock, - ArrayRef(), endBlock, - ArrayRef()); + ArrayRef(), endBlock, + ArrayRef()); // Ok, we're done! rewriter.eraseOp(forOp); return matchSuccess(); @@ -248,8 +248,8 @@ IfLowering::matchAndRewrite(IfOp ifOp, PatternRewriter &rewriter) const { rewriter.setInsertionPointToEnd(condBlock); rewriter.create(loc, ifOp.condition(), thenBlock, - /*trueArgs=*/ArrayRef(), elseBlock, - /*falseArgs=*/ArrayRef()); + /*trueArgs=*/ArrayRef(), elseBlock, + /*falseArgs=*/ArrayRef()); // Ok, we're done! rewriter.eraseOp(ifOp); diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp index d663ae105f2..3cbce7caa76 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp @@ -43,7 +43,7 @@ using namespace mlir::loop; using llvm::seq; // Extract an indexed value from KernelDim3. -static Value *getDim3Value(const gpu::KernelDim3 &dim3, unsigned pos) { +static ValuePtr getDim3Value(const gpu::KernelDim3 &dim3, unsigned pos) { switch (pos) { case 0: return dim3.x; @@ -61,8 +61,8 @@ static Value *getDim3Value(const gpu::KernelDim3 &dim3, unsigned pos) { static Operation::operand_range getLowerBoundOperands(AffineForOp forOp) { return forOp.getLowerBoundOperands(); } -static SmallVector getLowerBoundOperands(ForOp forOp) { - SmallVector bounds(1, forOp.lowerBound()); +static SmallVector getLowerBoundOperands(ForOp forOp) { + SmallVector bounds(1, forOp.lowerBound()); return bounds; } @@ -70,33 +70,35 @@ static SmallVector getLowerBoundOperands(ForOp forOp) { static Operation::operand_range getUpperBoundOperands(AffineForOp forOp) { return forOp.getUpperBoundOperands(); } -static SmallVector getUpperBoundOperands(ForOp forOp) { - SmallVector bounds(1, forOp.upperBound()); +static SmallVector getUpperBoundOperands(ForOp forOp) { + SmallVector bounds(1, forOp.upperBound()); return bounds; } // Get a Value that corresponds to the loop step. If the step is an attribute, // materialize a corresponding constant using builder. -static Value *getOrCreateStep(AffineForOp forOp, OpBuilder &builder) { +static ValuePtr getOrCreateStep(AffineForOp forOp, OpBuilder &builder) { return builder.create(forOp.getLoc(), forOp.getStep()); } -static Value *getOrCreateStep(ForOp forOp, OpBuilder &) { return forOp.step(); } +static ValuePtr getOrCreateStep(ForOp forOp, OpBuilder &) { + return forOp.step(); +} // Get a Value for the loop lower bound. If the value requires computation, // materialize the instructions using builder. -static Value *getOrEmitLowerBound(AffineForOp forOp, OpBuilder &builder) { +static ValuePtr getOrEmitLowerBound(AffineForOp forOp, OpBuilder &builder) { return lowerAffineLowerBound(forOp, builder); } -static Value *getOrEmitLowerBound(ForOp forOp, OpBuilder &) { +static ValuePtr getOrEmitLowerBound(ForOp forOp, OpBuilder &) { return forOp.lowerBound(); } // Get a Value for the loop upper bound. If the value requires computation, // materialize the instructions using builder. -static Value *getOrEmitUpperBound(AffineForOp forOp, OpBuilder &builder) { +static ValuePtr getOrEmitUpperBound(AffineForOp forOp, OpBuilder &builder) { return lowerAffineUpperBound(forOp, builder); } -static Value *getOrEmitUpperBound(ForOp forOp, OpBuilder &) { +static ValuePtr getOrEmitUpperBound(ForOp forOp, OpBuilder &) { return forOp.upperBound(); } @@ -212,18 +214,18 @@ struct LoopToGpuConverter { unsigned numThreadDims); // Ranges of the loops mapped to blocks or threads. - SmallVector dims; + SmallVector dims; // Lower bounds of the loops mapped to blocks or threads. - SmallVector lbs; + SmallVector lbs; // Induction variables of the loops mapped to blocks or threads. - SmallVector ivs; + SmallVector ivs; // Steps of the loops mapped to blocks or threads. - SmallVector steps; + SmallVector steps; }; } // namespace // Return true if the value is obviously a constant "one". -static bool isConstantOne(Value *value) { +static bool isConstantOne(ValuePtr value) { if (auto def = dyn_cast_or_null(value->getDefiningOp())) return def.getValue() == 1; return false; @@ -244,15 +246,15 @@ Optional LoopToGpuConverter::collectBounds(OpTy forOp, steps.reserve(numLoops); OpTy currentLoop = forOp; for (unsigned i = 0; i < numLoops; ++i) { - Value *lowerBound = getOrEmitLowerBound(currentLoop, builder); - Value *upperBound = getOrEmitUpperBound(currentLoop, builder); + ValuePtr lowerBound = getOrEmitLowerBound(currentLoop, builder); + ValuePtr upperBound = getOrEmitUpperBound(currentLoop, builder); if (!lowerBound || !upperBound) { return llvm::None; } - Value *range = + ValuePtr range = builder.create(currentLoop.getLoc(), upperBound, lowerBound); - Value *step = getOrCreateStep(currentLoop, builder); + ValuePtr step = getOrCreateStep(currentLoop, builder); if (!isConstantOne(step)) range = builder.create(currentLoop.getLoc(), range, step); dims.push_back(range); @@ -274,8 +276,8 @@ Optional LoopToGpuConverter::collectBounds(OpTy forOp, /// `nids`. The innermost loop is mapped to the x-dimension, followed by the /// next innermost loop to y-dimension, followed by z-dimension. template -OpTy createGPULaunchLoops(OpTy rootForOp, ArrayRef ids, - ArrayRef nids) { +OpTy createGPULaunchLoops(OpTy rootForOp, ArrayRef ids, + ArrayRef nids) { auto nDims = ids.size(); assert(nDims == nids.size()); for (auto dim : llvm::seq(0, nDims)) { @@ -295,11 +297,11 @@ OpTy createGPULaunchLoops(OpTy rootForOp, ArrayRef ids, /// each workgroup/workitem and number of workgroup/workitems along a dimension /// of the launch into a container. void packIdAndNumId(gpu::KernelDim3 kernelIds, gpu::KernelDim3 kernelNids, - unsigned nDims, SmallVectorImpl &ids, - SmallVectorImpl &nids) { + unsigned nDims, SmallVectorImpl &ids, + SmallVectorImpl &nids) { assert(nDims <= 3 && "invalid number of launch dimensions"); - SmallVector allIds = {kernelIds.z, kernelIds.y, kernelIds.x}; - SmallVector allNids = {kernelNids.z, kernelNids.y, kernelNids.x}; + SmallVector allIds = {kernelIds.z, kernelIds.y, kernelIds.x}; + SmallVector allNids = {kernelNids.z, kernelNids.y, kernelNids.x}; ids.clear(); ids.append(std::next(allIds.begin(), allIds.size() - nDims), allIds.end()); nids.clear(); @@ -317,7 +319,7 @@ LogicalResult createLaunchBody(OpBuilder &builder, OpTy rootForOp, auto returnOp = builder.create(launchOp.getLoc()); rootForOp.getOperation()->moveBefore(returnOp); - SmallVector workgroupID, numWorkGroups; + SmallVector workgroupID, numWorkGroups; packIdAndNumId(launchOp.getBlockIds(), launchOp.getGridSize(), numBlockDims, workgroupID, numWorkGroups); @@ -333,7 +335,7 @@ LogicalResult createLaunchBody(OpBuilder &builder, OpTy rootForOp, } } - SmallVector workItemID, workGroupSize; + SmallVector workItemID, workGroupSize; packIdAndNumId(launchOp.getThreadIds(), launchOp.getBlockSize(), numThreadDims, workItemID, workGroupSize); for (auto &loopOp : threadRootForOps) { @@ -347,17 +349,17 @@ LogicalResult createLaunchBody(OpBuilder &builder, OpTy rootForOp, // given workgroup size and number of workgroups. template LogicalResult createLaunchFromOp(OpTy rootForOp, - ArrayRef numWorkGroups, - ArrayRef workGroupSizes) { + ArrayRef numWorkGroups, + ArrayRef workGroupSizes) { OpBuilder builder(rootForOp.getOperation()); if (numWorkGroups.size() > 3) { return rootForOp.emitError("invalid ") << numWorkGroups.size() << "-D workgroup specification"; } auto loc = rootForOp.getLoc(); - Value *one = builder.create( + ValuePtr one = builder.create( loc, builder.getIntegerAttr(builder.getIndexType(), 1)); - SmallVector numWorkGroups3D(3, one), workGroupSize3D(3, one); + SmallVector numWorkGroups3D(3, one), workGroupSize3D(3, one); for (auto numWorkGroup : enumerate(numWorkGroups)) { numWorkGroups3D[numWorkGroup.index()] = numWorkGroup.value(); } @@ -367,7 +369,7 @@ LogicalResult createLaunchFromOp(OpTy rootForOp, // Get the values used within the region of the rootForOp but defined above // it. - llvm::SetVector valuesToForwardSet; + llvm::SetVector valuesToForwardSet; getUsedValuesDefinedAbove(rootForOp.region(), rootForOp.region(), valuesToForwardSet); // Also add the values used for the lb, ub, and step of the rootForOp. @@ -387,8 +389,8 @@ LogicalResult createLaunchFromOp(OpTy rootForOp, // defined outside. They all are replaced with kernel arguments. for (const auto &pair : llvm::zip_first(valuesToForward, launchOp.getKernelArguments())) { - Value *from = std::get<0>(pair); - Value *to = std::get<1>(pair); + ValuePtr from = std::get<0>(pair); + ValuePtr to = std::get<1>(pair); replaceAllUsesInRegionWith(from, to, launchOp.body()); } return success(); @@ -408,22 +410,23 @@ void LoopToGpuConverter::createLaunch(OpTy rootForOp, OpTy innermostForOp, OpBuilder builder(rootForOp.getOperation()); // Prepare the grid and block sizes for the launch operation. If there is // no loop mapped to a specific dimension, use constant "1" as its size. - Value *constOne = (numBlockDims < 3 || numThreadDims < 3) - ? builder.create(rootForOp.getLoc(), 1) - : nullptr; - Value *gridSizeX = dims[0]; - Value *gridSizeY = numBlockDims > 1 ? dims[1] : constOne; - Value *gridSizeZ = numBlockDims > 2 ? dims[2] : constOne; - Value *blockSizeX = dims[numBlockDims]; - Value *blockSizeY = numThreadDims > 1 ? dims[numBlockDims + 1] : constOne; - Value *blockSizeZ = numThreadDims > 2 ? dims[numBlockDims + 2] : constOne; + ValuePtr constOne = + (numBlockDims < 3 || numThreadDims < 3) + ? builder.create(rootForOp.getLoc(), 1) + : nullptr; + ValuePtr gridSizeX = dims[0]; + ValuePtr gridSizeY = numBlockDims > 1 ? dims[1] : constOne; + ValuePtr gridSizeZ = numBlockDims > 2 ? dims[2] : constOne; + ValuePtr blockSizeX = dims[numBlockDims]; + ValuePtr blockSizeY = numThreadDims > 1 ? dims[numBlockDims + 1] : constOne; + ValuePtr blockSizeZ = numThreadDims > 2 ? dims[numBlockDims + 2] : constOne; // Create a launch op and move the body region of the innermost loop to the // launch op. Pass the values defined outside the outermost loop and used // inside the innermost loop and loop lower bounds as kernel data arguments. // Still assuming perfect nesting so there are no values other than induction // variables that are defined in one loop and used in deeper loops. - llvm::SetVector valuesToForwardSet; + llvm::SetVector valuesToForwardSet; getUsedValuesDefinedAbove(innermostForOp.region(), rootForOp.region(), valuesToForwardSet); auto valuesToForward = valuesToForwardSet.takeVector(); @@ -457,15 +460,15 @@ void LoopToGpuConverter::createLaunch(OpTy rootForOp, OpTy innermostForOp, originallyForwardedValues); auto stepArgumentIt = std::next(lbArgumentIt, lbs.size()); for (auto en : llvm::enumerate(ivs)) { - Value *id = + ValuePtr id = en.index() < numBlockDims ? getDim3Value(launchOp.getBlockIds(), en.index()) : getDim3Value(launchOp.getThreadIds(), en.index() - numBlockDims); - Value *step = steps[en.index()]; + ValuePtr step = steps[en.index()]; if (!isConstantOne(step)) id = builder.create(rootForOp.getLoc(), step, id); - Value *ivReplacement = + ValuePtr ivReplacement = builder.create(rootForOp.getLoc(), *lbArgumentIt, id); en.value()->replaceAllUsesWith(ivReplacement); replaceAllUsesInRegionWith(steps[en.index()], *stepArgumentIt, @@ -479,8 +482,8 @@ void LoopToGpuConverter::createLaunch(OpTy rootForOp, OpTy innermostForOp, // trailing positions, make sure we don't touch those. for (const auto &pair : llvm::zip_first(valuesToForward, launchOp.getKernelArguments())) { - Value *from = std::get<0>(pair); - Value *to = std::get<1>(pair); + ValuePtr from = std::get<0>(pair); + ValuePtr to = std::get<1>(pair); replaceAllUsesInRegionWith(from, to, launchOp.body()); } @@ -510,8 +513,8 @@ static LogicalResult convertLoopNestToGPULaunch(OpTy forOp, // nested. The workgroup size and num workgroups is provided as input template static LogicalResult convertLoopToGPULaunch(OpTy forOp, - ArrayRef numWorkGroups, - ArrayRef workGroupSize) { + ArrayRef numWorkGroups, + ArrayRef workGroupSize) { if (failed(checkLoopOpMappable(forOp, numWorkGroups.size(), workGroupSize.size()))) { return failure(); @@ -532,7 +535,7 @@ LogicalResult mlir::convertLoopNestToGPULaunch(ForOp forOp, } LogicalResult mlir::convertLoopToGPULaunch(loop::ForOp forOp, - ArrayRef numWorkGroups, - ArrayRef workGroupSizes) { + ArrayRef numWorkGroups, + ArrayRef workGroupSizes) { return ::convertLoopToGPULaunch(forOp, numWorkGroups, workGroupSizes); } diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp index 21abc3cf99b..63836883512 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp @@ -98,7 +98,7 @@ struct ImperfectlyNestedForLoopMapper // pass is only used for testing. FuncOp funcOp = getFunction(); OpBuilder builder(funcOp.getOperation()->getRegion(0)); - SmallVector numWorkGroupsVal, workGroupSizeVal; + SmallVector numWorkGroupsVal, workGroupSizeVal; for (auto val : numWorkGroups) { auto constOp = builder.create( funcOp.getLoc(), builder.getIntegerAttr(builder.getIndexType(), val)); diff --git a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp index fdc90851b64..67b545c4ec8 100644 --- a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp @@ -256,20 +256,20 @@ LLVMOpLowering::LLVMOpLowering(StringRef rootOpName, MLIRContext *context, /*============================================================================*/ /* StructBuilder implementation */ /*============================================================================*/ -StructBuilder::StructBuilder(Value *v) : value(v) { +StructBuilder::StructBuilder(ValuePtr v) : value(v) { assert(value != nullptr && "value cannot be null"); structType = value->getType().cast(); } -Value *StructBuilder::extractPtr(OpBuilder &builder, Location loc, - unsigned pos) { +ValuePtr StructBuilder::extractPtr(OpBuilder &builder, Location loc, + unsigned pos) { Type type = structType.cast().getStructElementType(pos); return builder.create(loc, type, value, builder.getI64ArrayAttr(pos)); } void StructBuilder::setPtr(OpBuilder &builder, Location loc, unsigned pos, - Value *ptr) { + ValuePtr ptr) { value = builder.create(loc, structType, value, ptr, builder.getI64ArrayAttr(pos)); } @@ -278,7 +278,7 @@ void StructBuilder::setPtr(OpBuilder &builder, Location loc, unsigned pos, /*============================================================================*/ /// Construct a helper for the given descriptor value. -MemRefDescriptor::MemRefDescriptor(Value *descriptor) +MemRefDescriptor::MemRefDescriptor(ValuePtr descriptor) : StructBuilder(descriptor) { assert(value != nullptr && "value cannot be null"); indexType = value->getType().cast().getStructElementType( @@ -289,7 +289,7 @@ MemRefDescriptor::MemRefDescriptor(Value *descriptor) MemRefDescriptor MemRefDescriptor::undef(OpBuilder &builder, Location loc, Type descriptorType) { - Value *descriptor = + ValuePtr descriptor = builder.create(loc, descriptorType.cast()); return MemRefDescriptor(descriptor); } @@ -300,7 +300,7 @@ MemRefDescriptor MemRefDescriptor::undef(OpBuilder &builder, Location loc, MemRefDescriptor MemRefDescriptor::fromStaticShape(OpBuilder &builder, Location loc, LLVMTypeConverter &typeConverter, - MemRefType type, Value *memory) { + MemRefType type, ValuePtr memory) { assert(type.hasStaticShape() && "unexpected dynamic shape"); assert(type.getAffineMaps().empty() && "unexpected layout map"); @@ -325,37 +325,37 @@ MemRefDescriptor::fromStaticShape(OpBuilder &builder, Location loc, } /// Builds IR extracting the allocated pointer from the descriptor. -Value *MemRefDescriptor::allocatedPtr(OpBuilder &builder, Location loc) { +ValuePtr MemRefDescriptor::allocatedPtr(OpBuilder &builder, Location loc) { return extractPtr(builder, loc, kAllocatedPtrPosInMemRefDescriptor); } /// Builds IR inserting the allocated pointer into the descriptor. void MemRefDescriptor::setAllocatedPtr(OpBuilder &builder, Location loc, - Value *ptr) { + ValuePtr ptr) { setPtr(builder, loc, kAllocatedPtrPosInMemRefDescriptor, ptr); } /// Builds IR extracting the aligned pointer from the descriptor. -Value *MemRefDescriptor::alignedPtr(OpBuilder &builder, Location loc) { +ValuePtr MemRefDescriptor::alignedPtr(OpBuilder &builder, Location loc) { return extractPtr(builder, loc, kAlignedPtrPosInMemRefDescriptor); } /// Builds IR inserting the aligned pointer into the descriptor. void MemRefDescriptor::setAlignedPtr(OpBuilder &builder, Location loc, - Value *ptr) { + ValuePtr ptr) { setPtr(builder, loc, kAlignedPtrPosInMemRefDescriptor, ptr); } // Creates a constant Op producing a value of `resultType` from an index-typed // integer attribute. -static Value *createIndexAttrConstant(OpBuilder &builder, Location loc, - Type resultType, int64_t value) { +static ValuePtr createIndexAttrConstant(OpBuilder &builder, Location loc, + Type resultType, int64_t value) { return builder.create( loc, resultType, builder.getIntegerAttr(builder.getIndexType(), value)); } /// Builds IR extracting the offset from the descriptor. -Value *MemRefDescriptor::offset(OpBuilder &builder, Location loc) { +ValuePtr MemRefDescriptor::offset(OpBuilder &builder, Location loc) { return builder.create( loc, indexType, value, builder.getI64ArrayAttr(kOffsetPosInMemRefDescriptor)); @@ -363,7 +363,7 @@ Value *MemRefDescriptor::offset(OpBuilder &builder, Location loc) { /// Builds IR inserting the offset into the descriptor. void MemRefDescriptor::setOffset(OpBuilder &builder, Location loc, - Value *offset) { + ValuePtr offset) { value = builder.create( loc, structType, value, offset, builder.getI64ArrayAttr(kOffsetPosInMemRefDescriptor)); @@ -377,7 +377,8 @@ void MemRefDescriptor::setConstantOffset(OpBuilder &builder, Location loc, } /// Builds IR extracting the pos-th size from the descriptor. -Value *MemRefDescriptor::size(OpBuilder &builder, Location loc, unsigned pos) { +ValuePtr MemRefDescriptor::size(OpBuilder &builder, Location loc, + unsigned pos) { return builder.create( loc, indexType, value, builder.getI64ArrayAttr({kSizePosInMemRefDescriptor, pos})); @@ -385,7 +386,7 @@ Value *MemRefDescriptor::size(OpBuilder &builder, Location loc, unsigned pos) { /// Builds IR inserting the pos-th size into the descriptor void MemRefDescriptor::setSize(OpBuilder &builder, Location loc, unsigned pos, - Value *size) { + ValuePtr size) { value = builder.create( loc, structType, value, size, builder.getI64ArrayAttr({kSizePosInMemRefDescriptor, pos})); @@ -399,8 +400,8 @@ void MemRefDescriptor::setConstantSize(OpBuilder &builder, Location loc, } /// Builds IR extracting the pos-th size from the descriptor. -Value *MemRefDescriptor::stride(OpBuilder &builder, Location loc, - unsigned pos) { +ValuePtr MemRefDescriptor::stride(OpBuilder &builder, Location loc, + unsigned pos) { return builder.create( loc, indexType, value, builder.getI64ArrayAttr({kStridePosInMemRefDescriptor, pos})); @@ -408,7 +409,7 @@ Value *MemRefDescriptor::stride(OpBuilder &builder, Location loc, /// Builds IR inserting the pos-th stride into the descriptor void MemRefDescriptor::setStride(OpBuilder &builder, Location loc, unsigned pos, - Value *stride) { + ValuePtr stride) { value = builder.create( loc, structType, value, stride, builder.getI64ArrayAttr({kStridePosInMemRefDescriptor, pos})); @@ -431,30 +432,30 @@ LLVM::LLVMType MemRefDescriptor::getElementType() { /*============================================================================*/ /// Construct a helper for the given descriptor value. -UnrankedMemRefDescriptor::UnrankedMemRefDescriptor(Value *descriptor) +UnrankedMemRefDescriptor::UnrankedMemRefDescriptor(ValuePtr descriptor) : StructBuilder(descriptor) {} /// Builds IR creating an `undef` value of the descriptor type. UnrankedMemRefDescriptor UnrankedMemRefDescriptor::undef(OpBuilder &builder, Location loc, Type descriptorType) { - Value *descriptor = + ValuePtr descriptor = builder.create(loc, descriptorType.cast()); return UnrankedMemRefDescriptor(descriptor); } -Value *UnrankedMemRefDescriptor::rank(OpBuilder &builder, Location loc) { +ValuePtr UnrankedMemRefDescriptor::rank(OpBuilder &builder, Location loc) { return extractPtr(builder, loc, kRankInUnrankedMemRefDescriptor); } void UnrankedMemRefDescriptor::setRank(OpBuilder &builder, Location loc, - Value *v) { + ValuePtr v) { setPtr(builder, loc, kRankInUnrankedMemRefDescriptor, v); } -Value *UnrankedMemRefDescriptor::memRefDescPtr(OpBuilder &builder, - Location loc) { +ValuePtr UnrankedMemRefDescriptor::memRefDescPtr(OpBuilder &builder, + Location loc) { return extractPtr(builder, loc, kPtrInUnrankedMemRefDescriptor); } void UnrankedMemRefDescriptor::setMemRefDescPtr(OpBuilder &builder, - Location loc, Value *v) { + Location loc, ValuePtr v) { setPtr(builder, loc, kPtrInUnrankedMemRefDescriptor, v); } namespace { @@ -495,8 +496,8 @@ public: } // Create an LLVM IR pseudo-operation defining the given index constant. - Value *createIndexConstant(ConversionPatternRewriter &builder, Location loc, - uint64_t value) const { + ValuePtr createIndexConstant(ConversionPatternRewriter &builder, Location loc, + uint64_t value) const { return createIndexAttrConstant(builder, loc, getIndexType(), value); } @@ -508,7 +509,7 @@ struct FuncOpConversion : public LLVMLegalizationPattern { using LLVMLegalizationPattern::LLVMLegalizationPattern; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto funcOp = cast(op); FunctionType type = funcOp.getType(); @@ -556,8 +557,8 @@ struct FuncOpConversion : public LLVMLegalizationPattern { Block *firstBlock = &newFuncOp.getBody().front(); rewriter.setInsertionPoint(firstBlock, firstBlock->begin()); for (unsigned idx : promotedArgIndices) { - BlockArgument *arg = firstBlock->getArgument(idx); - Value *loaded = rewriter.create(funcOp.getLoc(), arg); + BlockArgumentPtr arg = firstBlock->getArgument(idx); + ValuePtr loaded = rewriter.create(funcOp.getLoc(), arg); rewriter.replaceUsesOfBlockArgument(arg, loaded); } } @@ -656,7 +657,7 @@ struct OneToOneLLVMOpLowering : public LLVMLegalizationPattern { // Convert the type of the result to an LLVM type, pass operands as is, // preserve attributes. PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { unsigned numResults = op->getNumResults(); @@ -680,7 +681,7 @@ struct OneToOneLLVMOpLowering : public LLVMLegalizationPattern { // Otherwise, it had been converted to an operation producing a structure. // Extract individual results from the structure and return them as list. - SmallVector results; + SmallVector results; results.reserve(numResults); for (unsigned i = 0; i < numResults; ++i) { auto type = this->lowering.convertType(op->getResult(i)->getType()); @@ -721,7 +722,7 @@ struct NaryOpLLVMOpLowering : public LLVMLegalizationPattern { // Convert the type of the result to an LLVM type, pass operands as is, // preserve attributes. PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { ValidateOpCount(); static_assert( @@ -732,7 +733,7 @@ struct NaryOpLLVMOpLowering : public LLVMLegalizationPattern { "expected same operands and result type"); // Cannot convert ops if their operands are not of LLVM type. - for (Value *operand : operands) { + for (ValuePtr operand : operands) { if (!operand || !operand->getType().isa()) return this->matchFailure(); } @@ -755,16 +756,16 @@ struct NaryOpLLVMOpLowering : public LLVMLegalizationPattern { if (!llvmVectorTy || llvmArrayTy != vectorTypeInfo.llvmArrayTy) return this->matchFailure(); - Value *desc = rewriter.create(loc, llvmArrayTy); + ValuePtr desc = rewriter.create(loc, llvmArrayTy); nDVectorIterate(vectorTypeInfo, rewriter, [&](ArrayAttr position) { // For this unrolled `position` corresponding to the `linearIndex`^th // element, extract operand vectors - SmallVector extractedOperands; + SmallVector extractedOperands; for (unsigned i = 0; i < OpCount; ++i) { extractedOperands.push_back(rewriter.create( loc, llvmVectorTy, operands[i], position)); } - Value *newVal = rewriter.create( + ValuePtr newVal = rewriter.create( loc, llvmVectorTy, extractedOperands, op->getAttrs()); desc = rewriter.create(loc, llvmArrayTy, desc, newVal, position); @@ -927,7 +928,7 @@ struct AllocOpLowering : public LLVMLegalizationPattern { return matchSuccess(); } - void rewrite(Operation *op, ArrayRef operands, + void rewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto loc = op->getLoc(); auto allocOp = cast(op); @@ -936,7 +937,7 @@ struct AllocOpLowering : public LLVMLegalizationPattern { // Get actual sizes of the memref as values: static sizes are constant // values and dynamic sizes are passed to 'alloc' as operands. In case of // zero-dimensional memref, assume a scalar (size 1). - SmallVector sizes; + SmallVector sizes; sizes.reserve(type.getRank()); unsigned i = 0; for (int64_t s : type.getShape()) @@ -946,10 +947,10 @@ struct AllocOpLowering : public LLVMLegalizationPattern { sizes.push_back(createIndexConstant(rewriter, loc, 1)); // Compute the total number of memref elements. - Value *cumulativeSize = sizes.front(); + ValuePtr cumulativeSize = sizes.front(); for (unsigned i = 1, e = sizes.size(); i < e; ++i) cumulativeSize = rewriter.create( - loc, getIndexType(), ArrayRef{cumulativeSize, sizes[i]}); + loc, getIndexType(), ArrayRef{cumulativeSize, sizes[i]}); // Compute the size of an individual element. This emits the MLIR equivalent // of the following sizeof(...) implementation in LLVM IR: @@ -962,17 +963,17 @@ struct AllocOpLowering : public LLVMLegalizationPattern { auto nullPtr = rewriter.create(loc, convertedPtrType); auto one = createIndexConstant(rewriter, loc, 1); auto gep = rewriter.create(loc, convertedPtrType, - ArrayRef{nullPtr, one}); + ArrayRef{nullPtr, one}); auto elementSize = rewriter.create(loc, getIndexType(), gep); cumulativeSize = rewriter.create( - loc, getIndexType(), ArrayRef{cumulativeSize, elementSize}); + loc, getIndexType(), ArrayRef{cumulativeSize, elementSize}); // Allocate the underlying buffer and store a pointer to it in the MemRef // descriptor. - Value *allocated = nullptr; + ValuePtr allocated = nullptr; int alignment = 0; - Value *alignmentValue = nullptr; + ValuePtr alignmentValue = nullptr; if (auto alignAttr = allocOp.alignment()) alignment = alignAttr.getValue().getSExtValue(); @@ -1008,8 +1009,8 @@ struct AllocOpLowering : public LLVMLegalizationPattern { auto structElementType = lowering.convertType(elementType); auto elementPtrType = structElementType.cast().getPointerTo( type.getMemorySpace()); - Value *bitcastAllocated = rewriter.create( - loc, elementPtrType, ArrayRef(allocated)); + ValuePtr bitcastAllocated = rewriter.create( + loc, elementPtrType, ArrayRef(allocated)); int64_t offset; SmallVector strides; @@ -1031,22 +1032,22 @@ struct AllocOpLowering : public LLVMLegalizationPattern { memRefDescriptor.setAllocatedPtr(rewriter, loc, bitcastAllocated); // Field 2: Actual aligned pointer to payload. - Value *bitcastAligned = bitcastAllocated; + ValuePtr bitcastAligned = bitcastAllocated; if (!useAlloca && alignment != 0) { assert(alignmentValue); // offset = (align - (ptr % align))% align - Value *intVal = rewriter.create( + ValuePtr intVal = rewriter.create( loc, this->getIndexType(), allocated); - Value *ptrModAlign = + ValuePtr ptrModAlign = rewriter.create(loc, intVal, alignmentValue); - Value *subbed = + ValuePtr subbed = rewriter.create(loc, alignmentValue, ptrModAlign); - Value *offset = + ValuePtr offset = rewriter.create(loc, subbed, alignmentValue); - Value *aligned = rewriter.create(loc, allocated->getType(), - allocated, offset); + ValuePtr aligned = rewriter.create(loc, allocated->getType(), + allocated, offset); bitcastAligned = rewriter.create( - loc, elementPtrType, ArrayRef(aligned)); + loc, elementPtrType, ArrayRef(aligned)); } memRefDescriptor.setAlignedPtr(rewriter, loc, bitcastAligned); @@ -1061,10 +1062,10 @@ struct AllocOpLowering : public LLVMLegalizationPattern { // Fields 4 and 5: Sizes and strides of the strided MemRef. // Store all sizes in the descriptor. Only dynamic sizes are passed in as // operands to AllocOp. - Value *runningStride = nullptr; + ValuePtr runningStride = nullptr; // Iterate strides in reverse order, compute runningStride and strideValues. auto nStrides = strides.size(); - SmallVector strideValues(nStrides, nullptr); + SmallVector strideValues(nStrides, nullptr); for (auto indexedStride : llvm::enumerate(llvm::reverse(strides))) { int64_t index = nStrides - 1 - indexedStride.index(); if (strides[index] == MemRefType::getDynamicStrideOrOffset()) @@ -1101,7 +1102,7 @@ struct CallOpInterfaceLowering : public LLVMLegalizationPattern { using Base = LLVMLegalizationPattern; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { OperandAdaptor transformed(operands); auto callOp = cast(op); @@ -1139,7 +1140,7 @@ struct CallOpInterfaceLowering : public LLVMLegalizationPattern { // TODO(aminim, ntv, riverriddle, zinenko): this seems like patching around // a particular interaction between MemRefType and CallOp lowering. Find a // way to avoid special casing. - SmallVector results; + SmallVector results; results.reserve(numResults); for (unsigned i = 0; i < numResults; ++i) { auto type = this->lowering.convertType(op->getResult(i)->getType()); @@ -1173,7 +1174,7 @@ struct DeallocOpLowering : public LLVMLegalizationPattern { useAlloca(useAlloca) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { if (useAlloca) return rewriter.eraseOp(op), matchSuccess(); @@ -1193,7 +1194,7 @@ struct DeallocOpLowering : public LLVMLegalizationPattern { } MemRefDescriptor memref(transformed.memref()); - Value *casted = rewriter.create( + ValuePtr casted = rewriter.create( op->getLoc(), getVoidPtrType(), memref.allocatedPtr(rewriter, op->getLoc())); rewriter.replaceOpWithNewOp( @@ -1209,7 +1210,7 @@ struct TanhOpLowering : public LLVMLegalizationPattern { using LLVMLegalizationPattern::LLVMLegalizationPattern; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { using LLVMFuncOpT = LLVM::LLVMFuncOp; @@ -1283,7 +1284,7 @@ struct MemRefCastOpLowering : public LLVMLegalizationPattern { : matchFailure(); } - void rewrite(Operation *op, ArrayRef operands, + void rewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto memRefCastOp = cast(op); OperandAdaptor transformed(operands); @@ -1324,7 +1325,7 @@ struct MemRefCastOpLowering : public LLVMLegalizationPattern { memRefDesc.setRank(rewriter, loc, rankVal); // d2 = InsertValueOp d1, voidptr, 1 memRefDesc.setMemRefDescPtr(rewriter, loc, voidPtr); - rewriter.replaceOp(op, (Value *)memRefDesc); + rewriter.replaceOp(op, (ValuePtr)memRefDesc); } else if (srcType.isa() && dstType.isa()) { // Casting from unranked type to ranked. @@ -1355,7 +1356,7 @@ struct DimOpLowering : public LLVMLegalizationPattern { using LLVMLegalizationPattern::LLVMLegalizationPattern; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto dimOp = cast(op); OperandAdaptor transformed(operands); @@ -1397,43 +1398,45 @@ struct LoadStoreOpLowering : public LLVMLegalizationPattern { // by accumulating the running linearized value. // Note that `indices` and `allocSizes` are passed in the same order as they // appear in load/store operations and memref type declarations. - Value *linearizeSubscripts(ConversionPatternRewriter &builder, Location loc, - ArrayRef indices, - ArrayRef allocSizes) const { + ValuePtr linearizeSubscripts(ConversionPatternRewriter &builder, Location loc, + ArrayRef indices, + ArrayRef allocSizes) const { assert(indices.size() == allocSizes.size() && "mismatching number of indices and allocation sizes"); assert(!indices.empty() && "cannot linearize a 0-dimensional access"); - Value *linearized = indices.front(); + ValuePtr linearized = indices.front(); for (int i = 1, nSizes = allocSizes.size(); i < nSizes; ++i) { linearized = builder.create( loc, this->getIndexType(), - ArrayRef{linearized, allocSizes[i]}); + ArrayRef{linearized, allocSizes[i]}); linearized = builder.create( - loc, this->getIndexType(), ArrayRef{linearized, indices[i]}); + loc, this->getIndexType(), + ArrayRef{linearized, indices[i]}); } return linearized; } // This is a strided getElementPtr variant that linearizes subscripts as: // `base_offset + index_0 * stride_0 + ... + index_n * stride_n`. - Value *getStridedElementPtr(Location loc, Type elementTypePtr, - Value *descriptor, ArrayRef indices, - ArrayRef strides, int64_t offset, - ConversionPatternRewriter &rewriter) const { + ValuePtr getStridedElementPtr(Location loc, Type elementTypePtr, + ValuePtr descriptor, ArrayRef indices, + ArrayRef strides, int64_t offset, + ConversionPatternRewriter &rewriter) const { MemRefDescriptor memRefDescriptor(descriptor); - Value *base = memRefDescriptor.alignedPtr(rewriter, loc); - Value *offsetValue = offset == MemRefType::getDynamicStrideOrOffset() - ? memRefDescriptor.offset(rewriter, loc) - : this->createIndexConstant(rewriter, loc, offset); + ValuePtr base = memRefDescriptor.alignedPtr(rewriter, loc); + ValuePtr offsetValue = + offset == MemRefType::getDynamicStrideOrOffset() + ? memRefDescriptor.offset(rewriter, loc) + : this->createIndexConstant(rewriter, loc, offset); for (int i = 0, e = indices.size(); i < e; ++i) { - Value *stride = + ValuePtr stride = strides[i] == MemRefType::getDynamicStrideOrOffset() ? memRefDescriptor.stride(rewriter, loc, i) : this->createIndexConstant(rewriter, loc, strides[i]); - Value *additionalOffset = + ValuePtr additionalOffset = rewriter.create(loc, indices[i], stride); offsetValue = rewriter.create(loc, offsetValue, additionalOffset); @@ -1441,10 +1444,10 @@ struct LoadStoreOpLowering : public LLVMLegalizationPattern { return rewriter.create(loc, elementTypePtr, base, offsetValue); } - Value *getDataPtr(Location loc, MemRefType type, Value *memRefDesc, - ArrayRef indices, - ConversionPatternRewriter &rewriter, - llvm::Module &module) const { + ValuePtr getDataPtr(Location loc, MemRefType type, ValuePtr memRefDesc, + ArrayRef indices, + ConversionPatternRewriter &rewriter, + llvm::Module &module) const { LLVM::LLVMType ptrType = MemRefDescriptor(memRefDesc).getElementType(); int64_t offset; SmallVector strides; @@ -1462,14 +1465,14 @@ struct LoadOpLowering : public LoadStoreOpLowering { using Base::Base; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto loadOp = cast(op); OperandAdaptor transformed(operands); auto type = loadOp.getMemRefType(); - Value *dataPtr = getDataPtr(op->getLoc(), type, transformed.memref(), - transformed.indices(), rewriter, getModule()); + ValuePtr dataPtr = getDataPtr(op->getLoc(), type, transformed.memref(), + transformed.indices(), rewriter, getModule()); rewriter.replaceOpWithNewOp(op, dataPtr); return matchSuccess(); } @@ -1481,13 +1484,13 @@ struct StoreOpLowering : public LoadStoreOpLowering { using Base::Base; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto type = cast(op).getMemRefType(); OperandAdaptor transformed(operands); - Value *dataPtr = getDataPtr(op->getLoc(), type, transformed.memref(), - transformed.indices(), rewriter, getModule()); + ValuePtr dataPtr = getDataPtr(op->getLoc(), type, transformed.memref(), + transformed.indices(), rewriter, getModule()); rewriter.replaceOpWithNewOp(op, transformed.value(), dataPtr); return matchSuccess(); @@ -1500,14 +1503,14 @@ struct PrefetchOpLowering : public LoadStoreOpLowering { using Base::Base; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto prefetchOp = cast(op); OperandAdaptor transformed(operands); auto type = prefetchOp.getMemRefType(); - Value *dataPtr = getDataPtr(op->getLoc(), type, transformed.memref(), - transformed.indices(), rewriter, getModule()); + ValuePtr dataPtr = getDataPtr(op->getLoc(), type, transformed.memref(), + transformed.indices(), rewriter, getModule()); // Replace with llvm.prefetch. auto llvmI32Type = lowering.convertType(rewriter.getIntegerType(32)); @@ -1535,7 +1538,7 @@ struct IndexCastOpLowering : public LLVMLegalizationPattern { using LLVMLegalizationPattern::LLVMLegalizationPattern; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { IndexCastOpOperandAdaptor transformed(operands); auto indexCastOp = cast(op); @@ -1570,7 +1573,7 @@ struct CmpIOpLowering : public LLVMLegalizationPattern { using LLVMLegalizationPattern::LLVMLegalizationPattern; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto cmpiOp = cast(op); CmpIOpOperandAdaptor transformed(operands); @@ -1589,7 +1592,7 @@ struct CmpFOpLowering : public LLVMLegalizationPattern { using LLVMLegalizationPattern::LLVMLegalizationPattern; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto cmpfOp = cast(op); CmpFOpOperandAdaptor transformed(operands); @@ -1641,9 +1644,9 @@ struct OneToOneLLVMTerminatorLowering using Super = OneToOneLLVMTerminatorLowering; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef properOperands, + matchAndRewrite(Operation *op, ArrayRef properOperands, ArrayRef destinations, - ArrayRef> operands, + ArrayRef> operands, ConversionPatternRewriter &rewriter) const override { SmallVector operandRanges(operands.begin(), operands.end()); rewriter.replaceOpWithNewOp(op, properOperands, destinations, @@ -1662,19 +1665,19 @@ struct ReturnOpLowering : public LLVMLegalizationPattern { using LLVMLegalizationPattern::LLVMLegalizationPattern; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { unsigned numArguments = op->getNumOperands(); // If ReturnOp has 0 or 1 operand, create it and return immediately. if (numArguments == 0) { rewriter.replaceOpWithNewOp( - op, ArrayRef(), ArrayRef(), op->getAttrs()); + op, ArrayRef(), ArrayRef(), op->getAttrs()); return matchSuccess(); } if (numArguments == 1) { rewriter.replaceOpWithNewOp( - op, ArrayRef(operands.front()), ArrayRef(), + op, ArrayRef(operands.front()), ArrayRef(), op->getAttrs()); return matchSuccess(); } @@ -1684,7 +1687,7 @@ struct ReturnOpLowering : public LLVMLegalizationPattern { auto packedType = lowering.packFunctionResults(llvm::to_vector<4>(op->getOperandTypes())); - Value *packed = rewriter.create(op->getLoc(), packedType); + ValuePtr packed = rewriter.create(op->getLoc(), packedType); for (unsigned i = 0; i < numArguments; ++i) { packed = rewriter.create( op->getLoc(), packedType, packed, operands[i], @@ -1712,7 +1715,7 @@ struct SplatOpLowering : public LLVMLegalizationPattern { using LLVMLegalizationPattern::LLVMLegalizationPattern; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto splatOp = cast(op); VectorType resultType = splatOp.getType().dyn_cast(); @@ -1721,7 +1724,7 @@ struct SplatOpLowering : public LLVMLegalizationPattern { // First insert it into an undef vector so we can shuffle it. auto vectorType = lowering.convertType(splatOp.getType()); - Value *undef = rewriter.create(op->getLoc(), vectorType); + ValuePtr undef = rewriter.create(op->getLoc(), vectorType); auto zero = rewriter.create( op->getLoc(), lowering.convertType(rewriter.getIntegerType(32)), rewriter.getZeroAttr(rewriter.getIntegerType(32))); @@ -1746,7 +1749,7 @@ struct SplatNdOpLowering : public LLVMLegalizationPattern { using LLVMLegalizationPattern::LLVMLegalizationPattern; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto splatOp = cast(op); OperandAdaptor adaptor(operands); @@ -1763,16 +1766,16 @@ struct SplatNdOpLowering : public LLVMLegalizationPattern { return matchFailure(); // Construct returned value. - Value *desc = rewriter.create(loc, llvmArrayTy); + ValuePtr desc = rewriter.create(loc, llvmArrayTy); // Construct a 1-D vector with the splatted value that we insert in all the // places within the returned descriptor. - Value *vdesc = rewriter.create(loc, llvmVectorTy); + ValuePtr vdesc = rewriter.create(loc, llvmVectorTy); auto zero = rewriter.create( loc, lowering.convertType(rewriter.getIntegerType(32)), rewriter.getZeroAttr(rewriter.getIntegerType(32))); - Value *v = rewriter.create(loc, llvmVectorTy, vdesc, - adaptor.input(), zero); + ValuePtr v = rewriter.create( + loc, llvmVectorTy, vdesc, adaptor.input(), zero); // Shuffle the value across the desired number of elements. int64_t width = resultType.getDimSize(resultType.getRank() - 1); @@ -1800,21 +1803,21 @@ struct SubViewOpLowering : public LLVMLegalizationPattern { using LLVMLegalizationPattern::LLVMLegalizationPattern; PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto loc = op->getLoc(); auto viewOp = cast(op); // TODO(b/144779634, ravishankarm) : After Tblgen is adapted to support // having multiple variadic operands where each operand can have different // number of entries, clean all of this up. - SmallVector dynamicOffsets( + SmallVector dynamicOffsets( std::next(operands.begin()), std::next(operands.begin(), 1 + viewOp.getNumOffsets())); - SmallVector dynamicSizes( + SmallVector dynamicSizes( std::next(operands.begin(), 1 + viewOp.getNumOffsets()), std::next(operands.begin(), 1 + viewOp.getNumOffsets() + viewOp.getNumSizes())); - SmallVector dynamicStrides( + SmallVector dynamicStrides( std::next(operands.begin(), 1 + viewOp.getNumOffsets() + viewOp.getNumSizes()), operands.end()); @@ -1851,8 +1854,8 @@ struct SubViewOpLowering : public LLVMLegalizationPattern { auto targetMemRef = MemRefDescriptor::undef(rewriter, loc, targetDescTy); // Copy the buffer pointer from the old descriptor to the new one. - Value *extracted = sourceMemRef.allocatedPtr(rewriter, loc); - Value *bitcastPtr = rewriter.create( + ValuePtr extracted = sourceMemRef.allocatedPtr(rewriter, loc); + ValuePtr bitcastPtr = rewriter.create( loc, targetElementTy.getPointerTo(), extracted); targetMemRef.setAllocatedPtr(rewriter, loc, bitcastPtr); @@ -1862,7 +1865,7 @@ struct SubViewOpLowering : public LLVMLegalizationPattern { targetMemRef.setAlignedPtr(rewriter, loc, bitcastPtr); // Extract strides needed to compute offset. - SmallVector strideValues; + SmallVector strideValues; strideValues.reserve(viewMemRefType.getRank()); for (int i = 0, e = viewMemRefType.getRank(); i < e; ++i) strideValues.push_back(sourceMemRef.stride(rewriter, loc, i)); @@ -1879,9 +1882,9 @@ struct SubViewOpLowering : public LLVMLegalizationPattern { } // Offset. - Value *baseOffset = sourceMemRef.offset(rewriter, loc); + ValuePtr baseOffset = sourceMemRef.offset(rewriter, loc); for (int i = 0, e = viewMemRefType.getRank(); i < e; ++i) { - Value *min = dynamicOffsets[i]; + ValuePtr min = dynamicOffsets[i]; baseOffset = rewriter.create( loc, baseOffset, rewriter.create(loc, min, strideValues[i])); @@ -1891,7 +1894,7 @@ struct SubViewOpLowering : public LLVMLegalizationPattern { // Update sizes and strides. for (int i = viewMemRefType.getRank() - 1; i >= 0; --i) { targetMemRef.setSize(rewriter, loc, i, dynamicSizes[i]); - Value *newStride; + ValuePtr newStride; if (dynamicStrides.empty()) newStride = rewriter.create( loc, llvmIndexType, rewriter.getI64IntegerAttr(strides[i])); @@ -1916,9 +1919,9 @@ struct ViewOpLowering : public LLVMLegalizationPattern { // Build and return the value for the idx^th shape dimension, either by // returning the constant shape dimension or counting the proper dynamic size. - Value *getSize(ConversionPatternRewriter &rewriter, Location loc, - ArrayRef shape, ArrayRef dynamicSizes, - unsigned idx) const { + ValuePtr getSize(ConversionPatternRewriter &rewriter, Location loc, + ArrayRef shape, ArrayRef dynamicSizes, + unsigned idx) const { assert(idx < shape.size()); if (!ShapedType::isDynamic(shape[idx])) return createIndexConstant(rewriter, loc, shape[idx]); @@ -1933,9 +1936,9 @@ struct ViewOpLowering : public LLVMLegalizationPattern { // or by computing the dynamic stride from the current `runningStride` and // `nextSize`. The caller should keep a running stride and update it with the // result returned by this function. - Value *getStride(ConversionPatternRewriter &rewriter, Location loc, - ArrayRef strides, Value *nextSize, - Value *runningStride, unsigned idx) const { + ValuePtr getStride(ConversionPatternRewriter &rewriter, Location loc, + ArrayRef strides, ValuePtr nextSize, + ValuePtr runningStride, unsigned idx) const { assert(idx < strides.size()); if (strides[idx] != MemRefType::getDynamicStrideOrOffset()) return createIndexConstant(rewriter, loc, strides[idx]); @@ -1948,7 +1951,7 @@ struct ViewOpLowering : public LLVMLegalizationPattern { } PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto loc = op->getLoc(); auto viewOp = cast(op); @@ -1975,8 +1978,8 @@ struct ViewOpLowering : public LLVMLegalizationPattern { auto targetMemRef = MemRefDescriptor::undef(rewriter, loc, targetDescTy); // Field 1: Copy the allocated pointer, used for malloc/free. - Value *extracted = sourceMemRef.allocatedPtr(rewriter, loc); - Value *bitcastPtr = rewriter.create( + ValuePtr extracted = sourceMemRef.allocatedPtr(rewriter, loc); + ValuePtr bitcastPtr = rewriter.create( loc, targetElementTy.getPointerTo(), extracted); targetMemRef.setAllocatedPtr(rewriter, loc, bitcastPtr); @@ -1993,10 +1996,10 @@ struct ViewOpLowering : public LLVMLegalizationPattern { auto sizeAndOffsetOperands = adaptor.operands(); assert(llvm::size(sizeAndOffsetOperands) == numDynamicSizes + (hasDynamicOffset ? 1 : 0)); - Value *baseOffset = !hasDynamicOffset - ? createIndexConstant(rewriter, loc, offset) - // TODO(ntv): better adaptor. - : sizeAndOffsetOperands.front(); + ValuePtr baseOffset = !hasDynamicOffset + ? createIndexConstant(rewriter, loc, offset) + // TODO(ntv): better adaptor. + : sizeAndOffsetOperands.front(); targetMemRef.setOffset(rewriter, loc, baseOffset); // Early exit for 0-D corner case. @@ -2007,14 +2010,14 @@ struct ViewOpLowering : public LLVMLegalizationPattern { if (strides.back() != 1) return op->emitWarning("cannot cast to non-contiguous shape"), matchFailure(); - Value *stride = nullptr, *nextSize = nullptr; + ValuePtr stride = nullptr, nextSize = nullptr; // Drop the dynamic stride from the operand list, if present. - ArrayRef sizeOperands(sizeAndOffsetOperands); + ArrayRef sizeOperands(sizeAndOffsetOperands); if (hasDynamicOffset) sizeOperands = sizeOperands.drop_front(); for (int i = viewMemRefType.getRank() - 1; i >= 0; --i) { // Update size. - Value *size = + ValuePtr size = getSize(rewriter, loc, viewMemRefType.getShape(), sizeOperands, i); targetMemRef.setSize(rewriter, loc, i, size); // Update stride. @@ -2058,7 +2061,7 @@ static void ensureDistinctSuccessors(Block &bb) { auto *dummyBlock = new Block(); bb.getParent()->push_back(dummyBlock); auto builder = OpBuilder(dummyBlock); - SmallVector operands( + SmallVector operands( terminator->getSuccessorOperands(*position)); builder.create(terminator->getLoc(), successor.first, operands); terminator->setSuccessor(dummyBlock, *position); @@ -2179,33 +2182,33 @@ Type LLVMTypeConverter::packFunctionResults(ArrayRef types) { return LLVM::LLVMType::getStructTy(llvmDialect, resultTypes); } -Value *LLVMTypeConverter::promoteOneMemRefDescriptor(Location loc, - Value *operand, - OpBuilder &builder) { +ValuePtr LLVMTypeConverter::promoteOneMemRefDescriptor(Location loc, + ValuePtr operand, + OpBuilder &builder) { auto *context = builder.getContext(); auto int64Ty = LLVM::LLVMType::getInt64Ty(getDialect()); auto indexType = IndexType::get(context); // Alloca with proper alignment. We do not expect optimizations of this // alloca op and so we omit allocating at the entry block. auto ptrType = operand->getType().cast().getPointerTo(); - Value *one = builder.create(loc, int64Ty, - IntegerAttr::get(indexType, 1)); - Value *allocated = + ValuePtr one = builder.create( + loc, int64Ty, IntegerAttr::get(indexType, 1)); + ValuePtr allocated = builder.create(loc, ptrType, one, /*alignment=*/0); // Store into the alloca'ed descriptor. builder.create(loc, operand, allocated); return allocated; } -SmallVector +SmallVector LLVMTypeConverter::promoteMemRefDescriptors(Location loc, ValueRange opOperands, ValueRange operands, OpBuilder &builder) { - SmallVector promotedOperands; + SmallVector promotedOperands; promotedOperands.reserve(operands.size()); for (auto it : llvm::zip(opOperands, operands)) { - auto *operand = std::get<0>(it); - auto *llvmOperand = std::get<1>(it); + auto operand = std::get<0>(it); + auto llvmOperand = std::get<1>(it); if (!operand->getType().isa() && !operand->getType().isa()) { promotedOperands.push_back(operand); diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp index a14271efbb6..f7b0c9cb9bc 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp @@ -44,7 +44,7 @@ public: using SPIRVOpLowering::SPIRVOpLowering; PatternMatchResult - matchAndRewrite(ConstantOp constIndexOp, ArrayRef operands, + matchAndRewrite(ConstantOp constIndexOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; @@ -54,7 +54,7 @@ public: using SPIRVOpLowering::SPIRVOpLowering; PatternMatchResult - matchAndRewrite(CmpIOp cmpIOp, ArrayRef operands, + matchAndRewrite(CmpIOp cmpIOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; @@ -70,7 +70,7 @@ public: using SPIRVOpLowering::SPIRVOpLowering; PatternMatchResult - matchAndRewrite(StdOp operation, ArrayRef operands, + matchAndRewrite(StdOp operation, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto resultType = this->typeConverter.convertType(operation.getResult()->getType()); @@ -89,7 +89,7 @@ public: using SPIRVOpLowering::SPIRVOpLowering; PatternMatchResult - matchAndRewrite(LoadOp loadOp, ArrayRef operands, + matchAndRewrite(LoadOp loadOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; @@ -100,7 +100,7 @@ public: using SPIRVOpLowering::SPIRVOpLowering; PatternMatchResult - matchAndRewrite(ReturnOp returnOp, ArrayRef operands, + matchAndRewrite(ReturnOp returnOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; @@ -110,7 +110,7 @@ class SelectOpConversion final : public SPIRVOpLowering { public: using SPIRVOpLowering::SPIRVOpLowering; PatternMatchResult - matchAndRewrite(SelectOp op, ArrayRef operands, + matchAndRewrite(SelectOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; @@ -123,7 +123,7 @@ public: using SPIRVOpLowering::SPIRVOpLowering; PatternMatchResult - matchAndRewrite(StoreOp storeOp, ArrayRef operands, + matchAndRewrite(StoreOp storeOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; @@ -141,7 +141,8 @@ public: spirv::AccessChainOp getElementPtr(OpBuilder &builder, SPIRVTypeConverter &typeConverter, Location loc, MemRefType origBaseType, - Value *basePtr, ArrayRef indices) { + ValuePtr basePtr, + ArrayRef indices) { // Get base and offset of the MemRefType and verify they are static. int64_t offset; SmallVector strides; @@ -152,18 +153,18 @@ spirv::AccessChainOp getElementPtr(OpBuilder &builder, auto indexType = typeConverter.getIndexType(builder.getContext()); - Value *ptrLoc = nullptr; + ValuePtr ptrLoc = nullptr; assert(indices.size() == strides.size()); for (auto index : enumerate(indices)) { - Value *strideVal = builder.create( + ValuePtr strideVal = builder.create( loc, indexType, IntegerAttr::get(indexType, strides[index.index()])); - Value *update = + ValuePtr update = builder.create(loc, strideVal, index.value()); ptrLoc = (ptrLoc ? builder.create(loc, ptrLoc, update).getResult() : update); } - SmallVector linearizedIndices; + SmallVector linearizedIndices; // Add a '0' at the start to index into the struct. linearizedIndices.push_back(builder.create( loc, indexType, IntegerAttr::get(indexType, 0))); @@ -176,7 +177,7 @@ spirv::AccessChainOp getElementPtr(OpBuilder &builder, //===----------------------------------------------------------------------===// PatternMatchResult ConstantIndexOpConversion::matchAndRewrite( - ConstantOp constIndexOp, ArrayRef operands, + ConstantOp constIndexOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const { if (!constIndexOp.getResult()->getType().isa()) { return matchFailure(); @@ -210,7 +211,7 @@ PatternMatchResult ConstantIndexOpConversion::matchAndRewrite( //===----------------------------------------------------------------------===// PatternMatchResult -CmpIOpConversion::matchAndRewrite(CmpIOp cmpIOp, ArrayRef operands, +CmpIOpConversion::matchAndRewrite(CmpIOp cmpIOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const { CmpIOpOperandAdaptor cmpIOpOperands(operands); @@ -242,7 +243,7 @@ CmpIOpConversion::matchAndRewrite(CmpIOp cmpIOp, ArrayRef operands, //===----------------------------------------------------------------------===// PatternMatchResult -LoadOpConversion::matchAndRewrite(LoadOp loadOp, ArrayRef operands, +LoadOpConversion::matchAndRewrite(LoadOp loadOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const { LoadOpOperandAdaptor loadOperands(operands); auto loadPtr = getElementPtr(rewriter, typeConverter, loadOp.getLoc(), @@ -260,7 +261,7 @@ LoadOpConversion::matchAndRewrite(LoadOp loadOp, ArrayRef operands, PatternMatchResult ReturnOpConversion::matchAndRewrite(ReturnOp returnOp, - ArrayRef operands, + ArrayRef operands, ConversionPatternRewriter &rewriter) const { if (returnOp.getNumOperands()) { return matchFailure(); @@ -274,7 +275,7 @@ ReturnOpConversion::matchAndRewrite(ReturnOp returnOp, //===----------------------------------------------------------------------===// PatternMatchResult -SelectOpConversion::matchAndRewrite(SelectOp op, ArrayRef operands, +SelectOpConversion::matchAndRewrite(SelectOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const { SelectOpOperandAdaptor selectOperands(operands); rewriter.replaceOpWithNewOp(op, selectOperands.condition(), @@ -288,7 +289,7 @@ SelectOpConversion::matchAndRewrite(SelectOp op, ArrayRef operands, //===----------------------------------------------------------------------===// PatternMatchResult -StoreOpConversion::matchAndRewrite(StoreOp storeOp, ArrayRef operands, +StoreOpConversion::matchAndRewrite(StoreOp storeOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const { StoreOpOperandAdaptor storeOperands(operands); auto storePtr = diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp index c0c56a3b0b2..113789abe8a 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp @@ -37,7 +37,7 @@ public: using SPIRVOpLowering::SPIRVOpLowering; PatternMatchResult - matchAndRewrite(FuncOp funcOp, ArrayRef operands, + matchAndRewrite(FuncOp funcOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; @@ -49,7 +49,7 @@ class ConvertStandardToSPIRVPass } // namespace PatternMatchResult -FuncOpConversion::matchAndRewrite(FuncOp funcOp, ArrayRef operands, +FuncOpConversion::matchAndRewrite(FuncOp funcOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const { auto fnType = funcOp.getType(); if (fnType.getNumResults()) { diff --git a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp index 4469c2802a8..2e1a7f09ff8 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp @@ -69,7 +69,7 @@ public: static LogicalResult resolveSourceIndices(Location loc, PatternRewriter &rewriter, SubViewOp subViewOp, ValueRange indices, - SmallVectorImpl &sourceIndices) { + SmallVectorImpl &sourceIndices) { // TODO: Aborting when the offsets are static. There might be a way to fold // the subview op with load even if the offsets have been canonicalized // away. @@ -77,7 +77,7 @@ resolveSourceIndices(Location loc, PatternRewriter &rewriter, return failure(); ValueRange opOffsets = subViewOp.offsets(); - SmallVector opStrides; + SmallVector opStrides; if (subViewOp.getNumStrides()) { // If the strides are dynamic, get the stride operands. opStrides = llvm::to_vector<2>(subViewOp.strides()); @@ -124,7 +124,7 @@ LoadOpOfSubViewFolder::matchAndRewrite(LoadOp loadOp, if (!subViewOp) { return matchFailure(); } - SmallVector sourceIndices; + SmallVector sourceIndices; if (failed(resolveSourceIndices(loadOp.getLoc(), rewriter, subViewOp, loadOp.indices(), sourceIndices))) return matchFailure(); @@ -146,7 +146,7 @@ StoreOpOfSubViewFolder::matchAndRewrite(StoreOp storeOp, if (!subViewOp) { return matchFailure(); } - SmallVector sourceIndices; + SmallVector sourceIndices; if (failed(resolveSourceIndices(storeOp.getLoc(), rewriter, subViewOp, storeOp.indices(), sourceIndices))) return matchFailure(); diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp index 9ec8ec6f88d..5099cb01bbc 100644 --- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp @@ -62,9 +62,10 @@ static VectorType reducedVectorTypeBack(VectorType tp) { } // Helper that picks the proper sequence for inserting. -static Value *insertOne(ConversionPatternRewriter &rewriter, - LLVMTypeConverter &lowering, Location loc, Value *val1, - Value *val2, Type llvmType, int64_t rank, int64_t pos) { +static ValuePtr insertOne(ConversionPatternRewriter &rewriter, + LLVMTypeConverter &lowering, Location loc, + ValuePtr val1, ValuePtr val2, Type llvmType, + int64_t rank, int64_t pos) { if (rank == 1) { auto idxType = rewriter.getIndexType(); auto constant = rewriter.create( @@ -78,9 +79,10 @@ static Value *insertOne(ConversionPatternRewriter &rewriter, } // Helper that picks the proper sequence for extracting. -static Value *extractOne(ConversionPatternRewriter &rewriter, - LLVMTypeConverter &lowering, Location loc, Value *val, - Type llvmType, int64_t rank, int64_t pos) { +static ValuePtr extractOne(ConversionPatternRewriter &rewriter, + LLVMTypeConverter &lowering, Location loc, + ValuePtr val, Type llvmType, int64_t rank, + int64_t pos) { if (rank == 1) { auto idxType = rewriter.getIndexType(); auto constant = rewriter.create( @@ -101,7 +103,7 @@ public: typeConverter) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto broadcastOp = cast(op); VectorType dstVectorType = broadcastOp.getVectorType(); @@ -129,9 +131,9 @@ private: // ops once all insert/extract/shuffle operations // are available with lowering implemention. // - Value *expandRanks(Value *value, Location loc, VectorType srcVectorType, - VectorType dstVectorType, - ConversionPatternRewriter &rewriter) const { + ValuePtr expandRanks(ValuePtr value, Location loc, VectorType srcVectorType, + VectorType dstVectorType, + ConversionPatternRewriter &rewriter) const { assert((dstVectorType != nullptr) && "invalid result type in broadcast"); // Determine rank of source and destination. int64_t srcRank = srcVectorType ? srcVectorType.getRank() : 0; @@ -168,23 +170,24 @@ private: // becomes: // x = [s,s] // v = [x,x,x,x] - Value *duplicateOneRank(Value *value, Location loc, VectorType srcVectorType, - VectorType dstVectorType, int64_t rank, int64_t dim, - ConversionPatternRewriter &rewriter) const { + ValuePtr duplicateOneRank(ValuePtr value, Location loc, + VectorType srcVectorType, VectorType dstVectorType, + int64_t rank, int64_t dim, + ConversionPatternRewriter &rewriter) const { Type llvmType = lowering.convertType(dstVectorType); assert((llvmType != nullptr) && "unlowerable vector type"); if (rank == 1) { - Value *undef = rewriter.create(loc, llvmType); - Value *expand = + ValuePtr undef = rewriter.create(loc, llvmType); + ValuePtr expand = insertOne(rewriter, lowering, loc, undef, value, llvmType, rank, 0); SmallVector zeroValues(dim, 0); return rewriter.create( loc, expand, undef, rewriter.getI32ArrayAttr(zeroValues)); } - Value *expand = + ValuePtr expand = expandRanks(value, loc, srcVectorType, reducedVectorTypeFront(dstVectorType), rewriter); - Value *result = rewriter.create(loc, llvmType); + ValuePtr result = rewriter.create(loc, llvmType); for (int64_t d = 0; d < dim; ++d) { result = insertOne(rewriter, lowering, loc, result, expand, llvmType, rank, d); @@ -209,19 +212,20 @@ private: // y = broadcast w[1][0] : vector<2xf32> to vector <2x2xf32> // a = [x, y] // etc. - Value *stretchOneRank(Value *value, Location loc, VectorType srcVectorType, - VectorType dstVectorType, int64_t rank, int64_t dim, - ConversionPatternRewriter &rewriter) const { + ValuePtr stretchOneRank(ValuePtr value, Location loc, + VectorType srcVectorType, VectorType dstVectorType, + int64_t rank, int64_t dim, + ConversionPatternRewriter &rewriter) const { Type llvmType = lowering.convertType(dstVectorType); assert((llvmType != nullptr) && "unlowerable vector type"); - Value *result = rewriter.create(loc, llvmType); + ValuePtr result = rewriter.create(loc, llvmType); bool atStretch = dim != srcVectorType.getDimSize(0); if (rank == 1) { assert(atStretch); Type redLlvmType = lowering.convertType(dstVectorType.getElementType()); - Value *one = + ValuePtr one = extractOne(rewriter, lowering, loc, value, redLlvmType, rank, 0); - Value *expand = + ValuePtr expand = insertOne(rewriter, lowering, loc, result, one, llvmType, rank, 0); SmallVector zeroValues(dim, 0); return rewriter.create( @@ -232,9 +236,9 @@ private: Type redLlvmType = lowering.convertType(redSrcType); for (int64_t d = 0; d < dim; ++d) { int64_t pos = atStretch ? 0 : d; - Value *one = + ValuePtr one = extractOne(rewriter, lowering, loc, value, redLlvmType, rank, pos); - Value *expand = expandRanks(one, loc, redSrcType, redDstType, rewriter); + ValuePtr expand = expandRanks(one, loc, redSrcType, redDstType, rewriter); result = insertOne(rewriter, lowering, loc, result, expand, llvmType, rank, d); } @@ -250,7 +254,7 @@ public: typeConverter) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto loc = op->getLoc(); auto adaptor = vector::ShuffleOpOperandAdaptor(operands); @@ -274,23 +278,23 @@ public: // For rank 1, where both operands have *exactly* the same vector type, // there is direct shuffle support in LLVM. Use it! if (rank == 1 && v1Type == v2Type) { - Value *shuffle = rewriter.create( + ValuePtr shuffle = rewriter.create( loc, adaptor.v1(), adaptor.v2(), maskArrayAttr); rewriter.replaceOp(op, shuffle); return matchSuccess(); } // For all other cases, insert the individual values individually. - Value *insert = rewriter.create(loc, llvmType); + ValuePtr insert = rewriter.create(loc, llvmType); int64_t insPos = 0; for (auto en : llvm::enumerate(maskArrayAttr)) { int64_t extPos = en.value().cast().getInt(); - Value *value = adaptor.v1(); + ValuePtr value = adaptor.v1(); if (extPos >= v1Dim) { extPos -= v1Dim; value = adaptor.v2(); } - Value *extract = + ValuePtr extract = extractOne(rewriter, lowering, loc, value, llvmType, rank, extPos); insert = insertOne(rewriter, lowering, loc, insert, extract, llvmType, rank, insPos++); @@ -308,7 +312,7 @@ public: typeConverter) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto adaptor = vector::ExtractElementOpOperandAdaptor(operands); auto extractEltOp = cast(op); @@ -333,7 +337,7 @@ public: typeConverter) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto loc = op->getLoc(); auto adaptor = vector::ExtractOpOperandAdaptor(operands); @@ -349,7 +353,7 @@ public: // One-shot extraction of vector from array (only requires extractvalue). if (resultType.isa()) { - Value *extracted = rewriter.create( + ValuePtr extracted = rewriter.create( loc, llvmResultType, adaptor.vector(), positionArrayAttr); rewriter.replaceOp(op, extracted); return matchSuccess(); @@ -357,7 +361,7 @@ public: // Potential extraction of 1-D vector from array. auto *context = op->getContext(); - Value *extracted = adaptor.vector(); + ValuePtr extracted = adaptor.vector(); auto positionAttrs = positionArrayAttr.getValue(); if (positionAttrs.size() > 1) { auto oneDVectorType = reducedVectorTypeBack(vectorType); @@ -388,7 +392,7 @@ public: typeConverter) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto adaptor = vector::InsertElementOpOperandAdaptor(operands); auto insertEltOp = cast(op); @@ -413,7 +417,7 @@ public: typeConverter) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto loc = op->getLoc(); auto adaptor = vector::InsertOpOperandAdaptor(operands); @@ -429,7 +433,7 @@ public: // One-shot insertion of a vector into an array (only requires insertvalue). if (sourceType.isa()) { - Value *inserted = rewriter.create( + ValuePtr inserted = rewriter.create( loc, llvmResultType, adaptor.dest(), adaptor.source(), positionArrayAttr); rewriter.replaceOp(op, inserted); @@ -438,7 +442,7 @@ public: // Potential extraction of 1-D vector from array. auto *context = op->getContext(); - Value *extracted = adaptor.dest(); + ValuePtr extracted = adaptor.dest(); auto positionAttrs = positionArrayAttr.getValue(); auto position = positionAttrs.back().cast(); auto oneDVectorType = destVectorType; @@ -454,7 +458,7 @@ public: // Insertion of an element into a 1-D LLVM vector. auto i64Type = LLVM::LLVMType::getInt64Ty(lowering.getDialect()); auto constant = rewriter.create(loc, i64Type, position); - Value *inserted = rewriter.create( + ValuePtr inserted = rewriter.create( loc, lowering.convertType(oneDVectorType), extracted, adaptor.source(), constant); @@ -480,7 +484,7 @@ public: typeConverter) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto loc = op->getLoc(); auto adaptor = vector::OuterProductOpOperandAdaptor(operands); @@ -491,10 +495,10 @@ public: auto rankRHS = vRHS.getUnderlyingType()->getVectorNumElements(); auto llvmArrayOfVectType = lowering.convertType( cast(op).getResult()->getType()); - Value *desc = rewriter.create(loc, llvmArrayOfVectType); - Value *a = adaptor.lhs(), *b = adaptor.rhs(); - Value *acc = adaptor.acc().empty() ? nullptr : adaptor.acc().front(); - SmallVector lhs, accs; + ValuePtr desc = rewriter.create(loc, llvmArrayOfVectType); + ValuePtr a = adaptor.lhs(), b = adaptor.rhs(); + ValuePtr acc = adaptor.acc().empty() ? nullptr : adaptor.acc().front(); + SmallVector lhs, accs; lhs.reserve(rankLHS); accs.reserve(rankLHS); for (unsigned d = 0, e = rankLHS; d < e; ++d) { @@ -502,7 +506,7 @@ public: auto attr = rewriter.getI32IntegerAttr(d); SmallVector bcastAttr(rankRHS, attr); auto bcastArrayAttr = ArrayAttr::get(bcastAttr, ctx); - Value *aD = nullptr, *accD = nullptr; + ValuePtr aD = nullptr, accD = nullptr; // 1. Broadcast the element a[d] into vector aD. aD = rewriter.create(loc, a, a, bcastArrayAttr); // 2. If acc is present, extract 1-d vector acc[d] into accD. @@ -510,7 +514,7 @@ public: accD = rewriter.create( loc, vRHS, acc, rewriter.getI64ArrayAttr(d)); // 3. Compute aD outer b (plus accD, if relevant). - Value *aOuterbD = + ValuePtr aOuterbD = accD ? rewriter.create(loc, vRHS, aD, b, accD) .getResult() : rewriter.create(loc, aD, b).getResult(); @@ -532,7 +536,7 @@ public: typeConverter) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto loc = op->getLoc(); vector::TypeCastOp castOp = cast(op); @@ -581,12 +585,12 @@ public: auto desc = MemRefDescriptor::undef(rewriter, loc, llvmTargetDescriptorTy); Type llvmTargetElementTy = desc.getElementType(); // Set allocated ptr. - Value *allocated = sourceMemRef.allocatedPtr(rewriter, loc); + ValuePtr allocated = sourceMemRef.allocatedPtr(rewriter, loc); allocated = rewriter.create(loc, llvmTargetElementTy, allocated); desc.setAllocatedPtr(rewriter, loc, allocated); // Set aligned ptr. - Value *ptr = sourceMemRef.alignedPtr(rewriter, loc); + ValuePtr ptr = sourceMemRef.alignedPtr(rewriter, loc); ptr = rewriter.create(loc, llvmTargetElementTy, ptr); desc.setAlignedPtr(rewriter, loc, ptr); // Fill offset 0. @@ -632,7 +636,7 @@ public: // TODO(ajcbik): rely solely on libc in future? something else? // PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto printOp = cast(op); auto adaptor = vector::PrintOpOperandAdaptor(operands); @@ -662,7 +666,7 @@ public: private: void emitRanks(ConversionPatternRewriter &rewriter, Operation *op, - Value *value, VectorType vectorType, Operation *printer, + ValuePtr value, VectorType vectorType, Operation *printer, int64_t rank) const { Location loc = op->getLoc(); if (rank == 0) { @@ -678,7 +682,7 @@ private: rank > 1 ? reducedVectorTypeFront(vectorType) : nullptr; auto llvmType = lowering.convertType( rank > 1 ? reducedType : vectorType.getElementType()); - Value *nestedVal = + ValuePtr nestedVal = extractOne(rewriter, lowering, loc, value, llvmType, rank, d); emitRanks(rewriter, op, nestedVal, reducedType, printer, rank - 1); if (d != dim - 1) diff --git a/mlir/lib/Dialect/AffineOps/AffineOps.cpp b/mlir/lib/Dialect/AffineOps/AffineOps.cpp index ef4060d4302..3a21de389c7 100644 --- a/mlir/lib/Dialect/AffineOps/AffineOps.cpp +++ b/mlir/lib/Dialect/AffineOps/AffineOps.cpp @@ -115,8 +115,8 @@ static bool isFunctionRegion(Region *region) { /// A utility function to check if a value is defined at the top level of a /// function. A value of index type defined at the top level is always a valid /// symbol. -bool mlir::isTopLevelValue(Value *value) { - if (auto *arg = dyn_cast(value)) +bool mlir::isTopLevelValue(ValuePtr value) { + if (auto arg = dyn_cast(value)) return isFunctionRegion(arg->getOwner()->getParent()); return isFunctionRegion(value->getDefiningOp()->getParentRegion()); } @@ -124,7 +124,7 @@ bool mlir::isTopLevelValue(Value *value) { // Value can be used as a dimension id if it is valid as a symbol, or // it is an induction variable, or it is a result of affine apply operation // with dimension id arguments. -bool mlir::isValidDim(Value *value) { +bool mlir::isValidDim(ValuePtr value) { // The value must be an index type. if (!value->getType().isIndex()) return false; @@ -184,7 +184,7 @@ static bool isDimOpValidSymbol(DimOp dimOp) { // the top level, or it is a result of affine apply operation with symbol // arguments, or a result of the dim op on a memref satisfying certain // constraints. -bool mlir::isValidSymbol(Value *value) { +bool mlir::isValidSymbol(ValuePtr value) { // The value must be an index type. if (!value->getType().isIndex()) return false; @@ -207,7 +207,7 @@ bool mlir::isValidSymbol(Value *value) { // Returns true if 'value' is a valid index to an affine operation (e.g. // affine.load, affine.store, affine.dma_start, affine.dma_wait). // Returns false otherwise. -static bool isValidAffineIndexOperand(Value *value) { +static bool isValidAffineIndexOperand(ValuePtr value) { return isValidDim(value) || isValidSymbol(value); } @@ -221,7 +221,7 @@ static LogicalResult verifyDimAndSymbolIdentifiers(OpTy &op, Operation::operand_range operands, unsigned numDims) { unsigned opIt = 0; - for (auto *operand : operands) { + for (auto operand : operands) { if (opIt++ < numDims) { if (!isValidDim(operand)) return op.emitOpError("operand cannot be used as a dimension id"); @@ -306,14 +306,14 @@ LogicalResult AffineApplyOp::verify() { // its operands are valid dimension ids. bool AffineApplyOp::isValidDim() { return llvm::all_of(getOperands(), - [](Value *op) { return mlir::isValidDim(op); }); + [](ValuePtr op) { return mlir::isValidDim(op); }); } // The result of the affine apply operation can be used as a symbol if all its // operands are symbols. bool AffineApplyOp::isValidSymbol() { return llvm::all_of(getOperands(), - [](Value *op) { return mlir::isValidSymbol(op); }); + [](ValuePtr op) { return mlir::isValidSymbol(op); }); } OpFoldResult AffineApplyOp::fold(ArrayRef operands) { @@ -333,8 +333,8 @@ OpFoldResult AffineApplyOp::fold(ArrayRef operands) { return result[0]; } -AffineDimExpr AffineApplyNormalizer::renumberOneDim(Value *v) { - DenseMap::iterator iterPos; +AffineDimExpr AffineApplyNormalizer::renumberOneDim(ValuePtr v) { + DenseMap::iterator iterPos; bool inserted = false; std::tie(iterPos, inserted) = dimValueToPosition.insert(std::make_pair(v, dimValueToPosition.size())); @@ -347,7 +347,7 @@ AffineDimExpr AffineApplyNormalizer::renumberOneDim(Value *v) { AffineMap AffineApplyNormalizer::renumber(const AffineApplyNormalizer &other) { SmallVector dimRemapping; - for (auto *v : other.reorderedDims) { + for (auto v : other.reorderedDims) { auto kvp = other.dimValueToPosition.find(v); if (dimRemapping.size() <= kvp->second) dimRemapping.resize(kvp->second + 1); @@ -371,7 +371,7 @@ AffineMap AffineApplyNormalizer::renumber(const AffineApplyNormalizer &other) { // Gather the positions of the operands that are produced by an AffineApplyOp. static llvm::SetVector -indicesFromAffineApplyOp(ArrayRef operands) { +indicesFromAffineApplyOp(ArrayRef operands) { llvm::SetVector res; for (auto en : llvm::enumerate(operands)) if (isa_and_nonnull(en.value()->getDefiningOp())) @@ -393,13 +393,13 @@ indicesFromAffineApplyOp(ArrayRef operands) { // results in better simplifications and foldings. But we should evaluate // whether this behavior is what we really want after using more. static AffineMap promoteComposedSymbolsAsDims(AffineMap map, - ArrayRef symbols) { + ArrayRef symbols) { if (symbols.empty()) { return map; } // Sanity check on symbols. - for (auto *sym : symbols) { + for (auto sym : symbols) { assert(isValidSymbol(sym) && "Expected only valid symbols"); (void)sym; } @@ -446,7 +446,7 @@ static AffineMap promoteComposedSymbolsAsDims(AffineMap map, /// `(d0)[s0, s1] -> (d0 + s0 + s1)`. /// /// The result is only equivalent to `(d0)[s0] -> (d0 + 2 * s0)` when -/// applied to the same mlir::Value* for both s0 and s1. +/// applied to the same mlir::Value for both s0 and s1. /// As a consequence mathematical composition of AffineMap always concatenates /// symbols. /// @@ -462,7 +462,7 @@ static AffineMap promoteComposedSymbolsAsDims(AffineMap map, /// benefit potentially big: simpler and more maintainable code for a /// non-trivial, recursive, procedure. AffineApplyNormalizer::AffineApplyNormalizer(AffineMap map, - ArrayRef operands) + ArrayRef operands) : AffineApplyNormalizer() { static_assert(kMaxAffineApplyDepth > 0, "kMaxAffineApplyDepth must be > 0"); assert(map.getNumInputs() == operands.size() && @@ -495,7 +495,7 @@ AffineApplyNormalizer::AffineApplyNormalizer(AffineMap map, if (!furtherCompose) { // 1. Only dispatch dims or symbols. for (auto en : llvm::enumerate(operands)) { - auto *t = en.value(); + auto t = en.value(); assert(t->getType().isIndex()); bool isDim = (en.index() < map.getNumDims()); if (isDim) { @@ -511,14 +511,14 @@ AffineApplyNormalizer::AffineApplyNormalizer(AffineMap map, assert(numDimsBeforeRewrite <= operands.size()); // 2. Compose AffineApplyOps and dispatch dims or symbols. for (unsigned i = 0, e = operands.size(); i < e; ++i) { - auto *t = operands[i]; + auto t = operands[i]; auto affineApply = dyn_cast_or_null(t->getDefiningOp()); if (affineApply) { // a. Compose affine.apply operations. LLVM_DEBUG(affineApply.getOperation()->print( dbgs() << "\nCompose AffineApplyOp recursively: ")); AffineMap affineApplyMap = affineApply.getAffineMap(); - SmallVector affineApplyOperands( + SmallVector affineApplyOperands( affineApply.getOperands().begin(), affineApply.getOperands().end()); AffineApplyNormalizer normalizer(affineApplyMap, affineApplyOperands); @@ -569,8 +569,8 @@ AffineApplyNormalizer::AffineApplyNormalizer(AffineMap map, LLVM_DEBUG(dbgs() << "\n"); } -void AffineApplyNormalizer::normalize(AffineMap *otherMap, - SmallVectorImpl *otherOperands) { +void AffineApplyNormalizer::normalize( + AffineMap *otherMap, SmallVectorImpl *otherOperands) { AffineApplyNormalizer other(*otherMap, *otherOperands); *otherMap = renumber(other); @@ -584,7 +584,7 @@ void AffineApplyNormalizer::normalize(AffineMap *otherMap, /// on `map` and `operands` without creating an AffineApplyOp that needs to be /// immediately deleted. static void composeAffineMapAndOperands(AffineMap *map, - SmallVectorImpl *operands) { + SmallVectorImpl *operands) { AffineApplyNormalizer normalizer(*map, *operands); auto normalizedMap = normalizer.getAffineMap(); auto normalizedOperands = normalizer.getOperands(); @@ -595,8 +595,8 @@ static void composeAffineMapAndOperands(AffineMap *map, } void mlir::fullyComposeAffineMapAndOperands( - AffineMap *map, SmallVectorImpl *operands) { - while (llvm::any_of(*operands, [](Value *v) { + AffineMap *map, SmallVectorImpl *operands) { + while (llvm::any_of(*operands, [](ValuePtr v) { return isa_and_nonnull(v->getDefiningOp()); })) { composeAffineMapAndOperands(map, operands); @@ -605,9 +605,9 @@ void mlir::fullyComposeAffineMapAndOperands( AffineApplyOp mlir::makeComposedAffineApply(OpBuilder &b, Location loc, AffineMap map, - ArrayRef operands) { + ArrayRef operands) { AffineMap normalizedMap = map; - SmallVector normalizedOperands(operands.begin(), operands.end()); + SmallVector normalizedOperands(operands.begin(), operands.end()); composeAffineMapAndOperands(&normalizedMap, &normalizedOperands); assert(normalizedMap); return b.create(loc, normalizedMap, normalizedOperands); @@ -617,7 +617,7 @@ AffineApplyOp mlir::makeComposedAffineApply(OpBuilder &b, Location loc, // canonicalizes dims that are valid symbols into actual symbols. template static void canonicalizePromotedSymbols(MapOrSet *mapOrSet, - SmallVectorImpl *operands) { + SmallVectorImpl *operands) { if (!mapOrSet || operands->empty()) return; @@ -625,9 +625,9 @@ static void canonicalizePromotedSymbols(MapOrSet *mapOrSet, "map/set inputs must match number of operands"); auto *context = mapOrSet->getContext(); - SmallVector resultOperands; + SmallVector resultOperands; resultOperands.reserve(operands->size()); - SmallVector remappedSymbols; + SmallVector remappedSymbols; remappedSymbols.reserve(operands->size()); unsigned nextDim = 0; unsigned nextSym = 0; @@ -661,7 +661,7 @@ static void canonicalizePromotedSymbols(MapOrSet *mapOrSet, template static void canonicalizeMapOrSetAndOperands(MapOrSet *mapOrSet, - SmallVectorImpl *operands) { + SmallVectorImpl *operands) { static_assert(std::is_same::value || std::is_same::value, "Argument must be either of AffineMap or IntegerSet type"); @@ -686,10 +686,10 @@ canonicalizeMapOrSetAndOperands(MapOrSet *mapOrSet, auto *context = mapOrSet->getContext(); - SmallVector resultOperands; + SmallVector resultOperands; resultOperands.reserve(operands->size()); - llvm::SmallDenseMap seenDims; + llvm::SmallDenseMap seenDims; SmallVector dimRemapping(mapOrSet->getNumDims()); unsigned nextDim = 0; for (unsigned i = 0, e = mapOrSet->getNumDims(); i != e; ++i) { @@ -705,7 +705,7 @@ canonicalizeMapOrSetAndOperands(MapOrSet *mapOrSet, } } } - llvm::SmallDenseMap seenSymbols; + llvm::SmallDenseMap seenSymbols; SmallVector symRemapping(mapOrSet->getNumSymbols()); unsigned nextSym = 0; for (unsigned i = 0, e = mapOrSet->getNumSymbols(); i != e; ++i) { @@ -738,12 +738,12 @@ canonicalizeMapOrSetAndOperands(MapOrSet *mapOrSet, } void mlir::canonicalizeMapAndOperands(AffineMap *map, - SmallVectorImpl *operands) { + SmallVectorImpl *operands) { canonicalizeMapOrSetAndOperands(map, operands); } void mlir::canonicalizeSetAndOperands(IntegerSet *set, - SmallVectorImpl *operands) { + SmallVectorImpl *operands) { canonicalizeMapOrSetAndOperands(set, operands); } @@ -758,7 +758,7 @@ struct SimplifyAffineOp : public OpRewritePattern { /// Replace the affine op with another instance of it with the supplied /// map and mapOperands. void replaceAffineOp(PatternRewriter &rewriter, AffineOpTy affineOp, - AffineMap map, ArrayRef mapOperands) const; + AffineMap map, ArrayRef mapOperands) const; PatternMatchResult matchAndRewrite(AffineOpTy affineOp, PatternRewriter &rewriter) const override { @@ -770,7 +770,7 @@ struct SimplifyAffineOp : public OpRewritePattern { auto map = affineOp.getAffineMap(); AffineMap oldMap = map; auto oldOperands = affineOp.getMapOperands(); - SmallVector resultOperands(oldOperands); + SmallVector resultOperands(oldOperands); composeAffineMapAndOperands(&map, &resultOperands); if (map == oldMap && std::equal(oldOperands.begin(), oldOperands.end(), resultOperands.begin())) @@ -786,14 +786,14 @@ struct SimplifyAffineOp : public OpRewritePattern { template <> void SimplifyAffineOp::replaceAffineOp( PatternRewriter &rewriter, AffineLoadOp load, AffineMap map, - ArrayRef mapOperands) const { + ArrayRef mapOperands) const { rewriter.replaceOpWithNewOp(load, load.getMemRef(), map, mapOperands); } template <> void SimplifyAffineOp::replaceAffineOp( PatternRewriter &rewriter, AffinePrefetchOp prefetch, AffineMap map, - ArrayRef mapOperands) const { + ArrayRef mapOperands) const { rewriter.replaceOpWithNewOp( prefetch, prefetch.memref(), map, mapOperands, prefetch.localityHint().getZExtValue(), prefetch.isWrite(), @@ -802,14 +802,14 @@ void SimplifyAffineOp::replaceAffineOp( template <> void SimplifyAffineOp::replaceAffineOp( PatternRewriter &rewriter, AffineStoreOp store, AffineMap map, - ArrayRef mapOperands) const { + ArrayRef mapOperands) const { rewriter.replaceOpWithNewOp( store, store.getValueToStore(), store.getMemRef(), map, mapOperands); } template <> void SimplifyAffineOp::replaceAffineOp( PatternRewriter &rewriter, AffineApplyOp apply, AffineMap map, - ArrayRef mapOperands) const { + ArrayRef mapOperands) const { rewriter.replaceOpWithNewOp(apply, map, mapOperands); } } // end anonymous namespace. @@ -844,12 +844,12 @@ static LogicalResult foldMemRefCast(Operation *op) { // TODO(b/133776335) Check that map operands are loop IVs or symbols. void AffineDmaStartOp::build(Builder *builder, OperationState &result, - Value *srcMemRef, AffineMap srcMap, - ValueRange srcIndices, Value *destMemRef, + ValuePtr srcMemRef, AffineMap srcMap, + ValueRange srcIndices, ValuePtr destMemRef, AffineMap dstMap, ValueRange destIndices, - Value *tagMemRef, AffineMap tagMap, - ValueRange tagIndices, Value *numElements, - Value *stride, Value *elementsPerStride) { + ValuePtr tagMemRef, AffineMap tagMap, + ValueRange tagIndices, ValuePtr numElements, + ValuePtr stride, ValuePtr elementsPerStride) { result.addOperands(srcMemRef); result.addAttribute(getSrcMapAttrName(), AffineMapAttr::get(srcMap)); result.addOperands(srcIndices); @@ -980,19 +980,19 @@ LogicalResult AffineDmaStartOp::verify() { return emitOpError("incorrect number of operands"); } - for (auto *idx : getSrcIndices()) { + for (auto idx : getSrcIndices()) { if (!idx->getType().isIndex()) return emitOpError("src index to dma_start must have 'index' type"); if (!isValidAffineIndexOperand(idx)) return emitOpError("src index must be a dimension or symbol identifier"); } - for (auto *idx : getDstIndices()) { + for (auto idx : getDstIndices()) { if (!idx->getType().isIndex()) return emitOpError("dst index to dma_start must have 'index' type"); if (!isValidAffineIndexOperand(idx)) return emitOpError("dst index must be a dimension or symbol identifier"); } - for (auto *idx : getTagIndices()) { + for (auto idx : getTagIndices()) { if (!idx->getType().isIndex()) return emitOpError("tag index to dma_start must have 'index' type"); if (!isValidAffineIndexOperand(idx)) @@ -1013,8 +1013,8 @@ LogicalResult AffineDmaStartOp::fold(ArrayRef cstOperands, // TODO(b/133776335) Check that map operands are loop IVs or symbols. void AffineDmaWaitOp::build(Builder *builder, OperationState &result, - Value *tagMemRef, AffineMap tagMap, - ValueRange tagIndices, Value *numElements) { + ValuePtr tagMemRef, AffineMap tagMap, + ValueRange tagIndices, ValuePtr numElements) { result.addOperands(tagMemRef); result.addAttribute(getTagMapAttrName(), AffineMapAttr::get(tagMap)); result.addOperands(tagIndices); @@ -1023,7 +1023,7 @@ void AffineDmaWaitOp::build(Builder *builder, OperationState &result, void AffineDmaWaitOp::print(OpAsmPrinter &p) { p << "affine.dma_wait " << *getTagMemRef() << '['; - SmallVector operands(getTagIndices()); + SmallVector operands(getTagIndices()); p.printAffineMapOfSSAIds(getTagMapAttr(), operands); p << "], "; p.printOperand(getNumElements()); @@ -1068,7 +1068,7 @@ ParseResult AffineDmaWaitOp::parse(OpAsmParser &parser, LogicalResult AffineDmaWaitOp::verify() { if (!getOperand(0)->getType().isa()) return emitOpError("expected DMA tag to be of memref type"); - for (auto *idx : getTagIndices()) { + for (auto idx : getTagIndices()) { if (!idx->getType().isIndex()) return emitOpError("index to dma_wait must have 'index' type"); if (!isValidAffineIndexOperand(idx)) @@ -1368,7 +1368,7 @@ static LogicalResult foldLoopBounds(AffineForOp forOp) { SmallVector operandConstants; auto boundOperands = lower ? forOp.getLowerBoundOperands() : forOp.getUpperBoundOperands(); - for (auto *operand : boundOperands) { + for (auto operand : boundOperands) { Attribute operandCst; matchPattern(operand, m_Constant(&operandCst)); operandConstants.push_back(operandCst); @@ -1408,8 +1408,8 @@ static LogicalResult foldLoopBounds(AffineForOp forOp) { /// Canonicalize the bounds of the given loop. static LogicalResult canonicalizeLoopBounds(AffineForOp forOp) { - SmallVector lbOperands(forOp.getLowerBoundOperands()); - SmallVector ubOperands(forOp.getUpperBoundOperands()); + SmallVector lbOperands(forOp.getLowerBoundOperands()); + SmallVector ubOperands(forOp.getUpperBoundOperands()); auto lbMap = forOp.getLowerBoundMap(); auto ubMap = forOp.getUpperBoundMap(); @@ -1474,7 +1474,7 @@ void AffineForOp::setLowerBound(ValueRange lbOperands, AffineMap map) { assert(lbOperands.size() == map.getNumInputs()); assert(map.getNumResults() >= 1 && "bound map has at least one result"); - SmallVector newOperands(lbOperands.begin(), lbOperands.end()); + SmallVector newOperands(lbOperands.begin(), lbOperands.end()); auto ubOperands = getUpperBoundOperands(); newOperands.append(ubOperands.begin(), ubOperands.end()); @@ -1487,7 +1487,7 @@ void AffineForOp::setUpperBound(ValueRange ubOperands, AffineMap map) { assert(ubOperands.size() == map.getNumInputs()); assert(map.getNumResults() >= 1 && "bound map has at least one result"); - SmallVector newOperands(getLowerBoundOperands()); + SmallVector newOperands(getLowerBoundOperands()); newOperands.append(ubOperands.begin(), ubOperands.end()); getOperation()->setOperands(newOperands); @@ -1553,7 +1553,7 @@ bool AffineForOp::matchingBoundOperandList() { unsigned numOperands = lbMap.getNumInputs(); for (unsigned i = 0, e = lbMap.getNumInputs(); i < e; i++) { - // Compare Value *'s. + // Compare ValuePtr 's. if (getOperand(i) != getOperand(numOperands + i)) return false; } @@ -1562,7 +1562,7 @@ bool AffineForOp::matchingBoundOperandList() { Region &AffineForOp::getLoopBody() { return region(); } -bool AffineForOp::isDefinedOutsideOfLoop(Value *value) { +bool AffineForOp::isDefinedOutsideOfLoop(ValuePtr value) { return !region().isAncestor(value->getParentRegion()); } @@ -1573,14 +1573,14 @@ LogicalResult AffineForOp::moveOutOfLoop(ArrayRef ops) { } /// Returns if the provided value is the induction variable of a AffineForOp. -bool mlir::isForInductionVar(Value *val) { +bool mlir::isForInductionVar(ValuePtr val) { return getForInductionVarOwner(val) != AffineForOp(); } /// Returns the loop parent of an induction variable. If the provided value is /// not an induction variable, then return nullptr. -AffineForOp mlir::getForInductionVarOwner(Value *val) { - auto *ivArg = dyn_cast(val); +AffineForOp mlir::getForInductionVarOwner(ValuePtr val) { + auto ivArg = dyn_cast(val); if (!ivArg || !ivArg->getOwner()) return AffineForOp(); auto *containingInst = ivArg->getOwner()->getParent()->getParentOp(); @@ -1590,7 +1590,7 @@ AffineForOp mlir::getForInductionVarOwner(Value *val) { /// Extracts the induction variables from a list of AffineForOps and returns /// them. void mlir::extractForInductionVars(ArrayRef forInsts, - SmallVectorImpl *ivs) { + SmallVectorImpl *ivs) { ivs->reserve(forInsts.size()); for (auto forInst : forInsts) ivs->push_back(forInst.getInductionVar()); @@ -1729,7 +1729,7 @@ void AffineIfOp::build(Builder *builder, OperationState &result, IntegerSet set, LogicalResult AffineIfOp::fold(ArrayRef, SmallVectorImpl &) { auto set = getIntegerSet(); - SmallVector operands(getOperands()); + SmallVector operands(getOperands()); canonicalizeSetAndOperands(&set, &operands); // Any canonicalization change always leads to either a reduction in the @@ -1759,7 +1759,8 @@ void AffineLoadOp::build(Builder *builder, OperationState &result, } void AffineLoadOp::build(Builder *builder, OperationState &result, - Value *memref, AffineMap map, ValueRange mapOperands) { + ValuePtr memref, AffineMap map, + ValueRange mapOperands) { assert(map.getNumInputs() == mapOperands.size() && "inconsistent index info"); result.addOperands(memref); result.addOperands(mapOperands); @@ -1769,7 +1770,7 @@ void AffineLoadOp::build(Builder *builder, OperationState &result, } void AffineLoadOp::build(Builder *builder, OperationState &result, - Value *memref, ValueRange indices) { + ValuePtr memref, ValueRange indices) { auto memrefType = memref->getType().cast(); auto rank = memrefType.getRank(); // Create identity map for memrefs with at least one dimension or () -> () @@ -1825,7 +1826,7 @@ LogicalResult AffineLoadOp::verify() { "expects the number of subscripts to be equal to memref rank"); } - for (auto *idx : getMapOperands()) { + for (auto idx : getMapOperands()) { if (!idx->getType().isIndex()) return emitOpError("index to load must have 'index' type"); if (!isValidAffineIndexOperand(idx)) @@ -1851,7 +1852,7 @@ OpFoldResult AffineLoadOp::fold(ArrayRef cstOperands) { //===----------------------------------------------------------------------===// void AffineStoreOp::build(Builder *builder, OperationState &result, - Value *valueToStore, Value *memref, AffineMap map, + ValuePtr valueToStore, ValuePtr memref, AffineMap map, ValueRange mapOperands) { assert(map.getNumInputs() == mapOperands.size() && "inconsistent index info"); result.addOperands(valueToStore); @@ -1862,7 +1863,7 @@ void AffineStoreOp::build(Builder *builder, OperationState &result, // Use identity map. void AffineStoreOp::build(Builder *builder, OperationState &result, - Value *valueToStore, Value *memref, + ValuePtr valueToStore, ValuePtr memref, ValueRange indices) { auto memrefType = memref->getType().cast(); auto rank = memrefType.getRank(); @@ -1923,7 +1924,7 @@ LogicalResult AffineStoreOp::verify() { "expects the number of subscripts to be equal to memref rank"); } - for (auto *idx : getMapOperands()) { + for (auto idx : getMapOperands()) { if (!idx->getType().isIndex()) return emitOpError("index to store must have 'index' type"); if (!isValidAffineIndexOperand(idx)) @@ -2072,7 +2073,7 @@ void print(OpAsmPrinter &p, AffinePrefetchOp op) { p << AffinePrefetchOp::getOperationName() << " " << *op.memref() << '['; AffineMapAttr mapAttr = op.getAttrOfType(op.getMapAttrName()); if (mapAttr) { - SmallVector operands(op.getMapOperands()); + SmallVector operands(op.getMapOperands()); p.printAffineMapOfSSAIds(mapAttr, operands); } p << ']' << ", " << (op.isWrite() ? "write" : "read") << ", " @@ -2099,7 +2100,7 @@ LogicalResult verify(AffinePrefetchOp op) { return op.emitOpError("too few operands"); } - for (auto *idx : op.getMapOperands()) { + for (auto idx : op.getMapOperands()) { if (!isValidAffineIndexOperand(idx)) return op.emitOpError("index must be a dimension or symbol identifier"); } diff --git a/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp b/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp index 3982a6a4713..e1951ff900b 100644 --- a/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp +++ b/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp @@ -46,9 +46,9 @@ struct LowerUniformCastsPass : public FunctionPass { // Dequantize //===----------------------------------------------------------------------===// -static Value *emitUniformPerLayerDequantize(Location loc, Value *input, - UniformQuantizedType elementType, - PatternRewriter &rewriter) { +static ValuePtr emitUniformPerLayerDequantize(Location loc, ValuePtr input, + UniformQuantizedType elementType, + PatternRewriter &rewriter) { // Pre-conditions. if (!elementType.isSigned()) { // TODO: Support unsigned storage type. @@ -71,7 +71,7 @@ static Value *emitUniformPerLayerDequantize(Location loc, Value *input, // Apply zero-point offset. if (elementType.getZeroPoint() != 0) { - Value *negZeroPointConst = rewriter.create( + ValuePtr negZeroPointConst = rewriter.create( loc, broadcastScalarConstIntValue(intermediateType, -elementType.getZeroPoint())); input = rewriter.create(loc, input, negZeroPointConst); @@ -81,14 +81,14 @@ static Value *emitUniformPerLayerDequantize(Location loc, Value *input, input = rewriter.create(loc, realType, input); // Mul by scale. - Value *scaleConst = rewriter.create( + ValuePtr scaleConst = rewriter.create( loc, broadcastScalarConstFloatValue(realType, APFloat(elementType.getScale()))); return rewriter.create(loc, input, scaleConst); } -static Value * -emitUniformPerAxisDequantize(Location loc, Value *input, +static ValuePtr +emitUniformPerAxisDequantize(Location loc, ValuePtr input, UniformQuantizedPerAxisType elementType, PatternRewriter &rewriter) { // TODO: Support per-axis dequantize. @@ -97,8 +97,8 @@ emitUniformPerAxisDequantize(Location loc, Value *input, return nullptr; } -static Value *emitDequantize(Location loc, Value *input, - PatternRewriter &rewriter) { +static ValuePtr emitDequantize(Location loc, ValuePtr input, + PatternRewriter &rewriter) { Type inputType = input->getType(); QuantizedType qElementType = QuantizedType::getQuantizedElementType(inputType); @@ -133,7 +133,7 @@ struct UniformDequantizePattern : public OpRewritePattern { return matchFailure(); } - Value *dequantizedValue = emitDequantize(op.getLoc(), op.arg(), rewriter); + ValuePtr dequantizedValue = emitDequantize(op.getLoc(), op.arg(), rewriter); if (!dequantizedValue) { return matchFailure(); } @@ -170,14 +170,14 @@ tryRewriteAffineAddEwIsomorphicSigned(const UniformBinaryOpInfo &info, castElementType(info.resultStorageType, intermediateElementType); // Cast operands to storage type. - Value *lhsValue = rewriter - .create(info.op->getLoc(), - info.lhsStorageType, info.lhs) - .getResult(); - Value *rhsValue = rewriter - .create(info.op->getLoc(), - info.rhsStorageType, info.rhs) - .getResult(); + ValuePtr lhsValue = rewriter + .create(info.op->getLoc(), + info.lhsStorageType, info.lhs) + .getResult(); + ValuePtr rhsValue = rewriter + .create(info.op->getLoc(), + info.rhsStorageType, info.rhs) + .getResult(); // Cast to the intermediate sized type. lhsValue = rewriter.create(info.op->getLoc(), intermediateType, @@ -186,7 +186,7 @@ tryRewriteAffineAddEwIsomorphicSigned(const UniformBinaryOpInfo &info, rhsValue); // Add. - Value *resultValue = + ValuePtr resultValue = rewriter.create(info.op->getLoc(), lhsValue, rhsValue); // Zero point offset adjustment. @@ -194,7 +194,7 @@ tryRewriteAffineAddEwIsomorphicSigned(const UniformBinaryOpInfo &info, // zpOffset = -zp int zpOffset = -1 * info.resultType.getZeroPoint(); if (zpOffset != 0) { - Value *zpOffsetConst = rewriter.create( + ValuePtr zpOffsetConst = rewriter.create( info.op->getLoc(), broadcastScalarConstIntValue(intermediateType, zpOffset)); resultValue = @@ -246,14 +246,14 @@ tryRewriteAffineMulEwSigned(const UniformBinaryOpInfo &info, castElementType(info.resultStorageType, intermediateElementType); // Cast operands to storage type. - Value *lhsValue = rewriter - .create(info.op->getLoc(), - info.lhsStorageType, info.lhs) - .getResult(); - Value *rhsValue = rewriter - .create(info.op->getLoc(), - info.rhsStorageType, info.rhs) - .getResult(); + ValuePtr lhsValue = rewriter + .create(info.op->getLoc(), + info.lhsStorageType, info.lhs) + .getResult(); + ValuePtr rhsValue = rewriter + .create(info.op->getLoc(), + info.rhsStorageType, info.rhs) + .getResult(); // Cast to the intermediate sized type. lhsValue = rewriter.create(info.op->getLoc(), intermediateType, @@ -263,7 +263,7 @@ tryRewriteAffineMulEwSigned(const UniformBinaryOpInfo &info, // Apply argument zeroPoints. if (info.lhsType.getZeroPoint() != 0) { - Value *zpOffsetConst = rewriter.create( + ValuePtr zpOffsetConst = rewriter.create( info.op->getLoc(), broadcastScalarConstIntValue( intermediateType, -info.lhsType.getZeroPoint())); lhsValue = @@ -271,7 +271,7 @@ tryRewriteAffineMulEwSigned(const UniformBinaryOpInfo &info, } if (info.rhsType.getZeroPoint() != 0) { - Value *zpOffsetConst = rewriter.create( + ValuePtr zpOffsetConst = rewriter.create( info.op->getLoc(), broadcastScalarConstIntValue( intermediateType, -info.rhsType.getZeroPoint())); rhsValue = @@ -279,7 +279,7 @@ tryRewriteAffineMulEwSigned(const UniformBinaryOpInfo &info, } // Mul. - Value *resultValue = + ValuePtr resultValue = rewriter.create(info.op->getLoc(), lhsValue, rhsValue); // Scale output. @@ -293,7 +293,7 @@ tryRewriteAffineMulEwSigned(const UniformBinaryOpInfo &info, // Zero point offset adjustment. if (info.resultType.getZeroPoint() != 0) { - Value *zpOffsetConst = rewriter.create( + ValuePtr zpOffsetConst = rewriter.create( info.op->getLoc(), broadcastScalarConstIntValue(intermediateType, info.resultType.getZeroPoint())); diff --git a/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h b/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h index 955e2ecc88c..57a8422b362 100644 --- a/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h +++ b/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h @@ -59,7 +59,7 @@ template bool integralLog2(F x, int &log2Result) { /// Helper class for operating on binary operations where all operands /// and the result are a UniformQuantizedType. struct UniformBinaryOpInfo { - UniformBinaryOpInfo(Operation *op, Value *lhs, Value *rhs, + UniformBinaryOpInfo(Operation *op, ValuePtr lhs, ValuePtr rhs, Optional clampMin, Optional clampMax) : op(op), lhs(lhs), rhs(rhs), clampMin(clampMin), clampMax(clampMax), lhsType(getUniformElementType(lhs->getType())), @@ -128,8 +128,8 @@ struct UniformBinaryOpInfo { } Operation *op; - Value *lhs; - Value *rhs; + ValuePtr lhs; + ValuePtr rhs; Optional clampMin; Optional clampMax; diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp index 9c0183eb90f..349c1fa4644 100644 --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -145,7 +145,7 @@ static LogicalResult verifyAllReduce(gpu::AllReduceOp allReduce) { if (!allReduce.body().empty()) { if (allReduce.body().front().getNumArguments() != 2) return allReduce.emitError("expected two region arguments"); - for (auto *argument : allReduce.body().front().getArguments()) { + for (auto argument : allReduce.body().front().getArguments()) { if (argument->getType() != allReduce.getType()) return allReduce.emitError("incorrect region argument type"); } @@ -213,15 +213,15 @@ static ParseResult parseShuffleOp(OpAsmParser &parser, OperationState &state) { static SmallVector getValueTypes(ValueRange values) { SmallVector types; types.reserve(values.size()); - for (Value *v : values) + for (ValuePtr v : values) types.push_back(v->getType()); return types; } -void LaunchOp::build(Builder *builder, OperationState &result, Value *gridSizeX, - Value *gridSizeY, Value *gridSizeZ, Value *blockSizeX, - Value *blockSizeY, Value *blockSizeZ, - ValueRange operands) { +void LaunchOp::build(Builder *builder, OperationState &result, + ValuePtr gridSizeX, ValuePtr gridSizeY, ValuePtr gridSizeZ, + ValuePtr blockSizeX, ValuePtr blockSizeY, + ValuePtr blockSizeZ, ValueRange operands) { // Add grid and block sizes as op operands, followed by the data operands. result.addOperands( {gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ}); @@ -489,22 +489,22 @@ class PropagateConstantBounds : public OpRewritePattern { // and use it instead of passing the value from the parent region. Perform // the traversal in the inverse order to simplify index arithmetics when // dropping arguments. - SmallVector operands(launchOp.getKernelOperandValues().begin(), - launchOp.getKernelOperandValues().end()); - SmallVector kernelArgs(launchOp.getKernelArguments().begin(), - launchOp.getKernelArguments().end()); + SmallVector operands(launchOp.getKernelOperandValues().begin(), + launchOp.getKernelOperandValues().end()); + SmallVector kernelArgs(launchOp.getKernelArguments().begin(), + launchOp.getKernelArguments().end()); bool found = false; for (unsigned i = operands.size(); i > 0; --i) { unsigned index = i - 1; - Value *operand = operands[index]; + ValuePtr operand = operands[index]; if (!isa_and_nonnull(operand->getDefiningOp())) { continue; } found = true; - Value *internalConstant = + ValuePtr internalConstant = rewriter.clone(*operand->getDefiningOp())->getResult(0); - Value *kernelArg = kernelArgs[index]; + ValuePtr kernelArg = kernelArgs[index]; kernelArg->replaceAllUsesWith(internalConstant); launchOp.eraseKernelArgument(index); } @@ -529,10 +529,10 @@ void LaunchOp::getCanonicalizationPatterns(OwningRewritePatternList &results, //===----------------------------------------------------------------------===// void LaunchFuncOp::build(Builder *builder, OperationState &result, - GPUFuncOp kernelFunc, Value *gridSizeX, - Value *gridSizeY, Value *gridSizeZ, Value *blockSizeX, - Value *blockSizeY, Value *blockSizeZ, - ValueRange kernelOperands) { + GPUFuncOp kernelFunc, ValuePtr gridSizeX, + ValuePtr gridSizeY, ValuePtr gridSizeZ, + ValuePtr blockSizeX, ValuePtr blockSizeY, + ValuePtr blockSizeZ, ValueRange kernelOperands) { // Add grid and block sizes as op operands, followed by the data operands. result.addOperands( {gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ}); @@ -565,7 +565,7 @@ StringRef LaunchFuncOp::getKernelModuleName() { .getRootReference(); } -Value *LaunchFuncOp::getKernelOperand(unsigned i) { +ValuePtr LaunchFuncOp::getKernelOperand(unsigned i) { return getOperation()->getOperand(i + kNumConfigOperands); } @@ -728,13 +728,14 @@ static ParseResult parseGPUFuncOp(OpAsmParser &parser, OperationState &result) { } static void printAttributions(OpAsmPrinter &p, StringRef keyword, - ArrayRef values) { + ArrayRef values) { if (values.empty()) return; p << ' ' << keyword << '('; - interleaveComma(values, p, - [&p](BlockArgument *v) { p << *v << " : " << v->getType(); }); + interleaveComma(values, p, [&p](BlockArgumentPtr v) { + p << *v << " : " << v->getType(); + }); p << ')'; } @@ -781,9 +782,9 @@ LogicalResult GPUFuncOp::verifyType() { } static LogicalResult verifyAttributions(Operation *op, - ArrayRef attributions, + ArrayRef attributions, unsigned memorySpace) { - for (Value *v : attributions) { + for (ValuePtr v : attributions) { auto type = v->getType().dyn_cast(); if (!type) return op->emitOpError() << "expected memref type in attribution"; diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp index 0a6a5915633..8f5f50e4909 100644 --- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp @@ -31,10 +31,10 @@ using namespace mlir; template static void createForAllDimensions(OpBuilder &builder, Location loc, - SmallVectorImpl &values) { + SmallVectorImpl &values) { for (StringRef dim : {"x", "y", "z"}) { - Value *v = builder.create(loc, builder.getIndexType(), - builder.getStringAttr(dim)); + ValuePtr v = builder.create(loc, builder.getIndexType(), + builder.getStringAttr(dim)); values.push_back(v); } } @@ -46,7 +46,7 @@ static void injectGpuIndexOperations(Location loc, Region &body) { OpBuilder builder(loc->getContext()); Block &firstBlock = body.front(); builder.setInsertionPointToStart(&firstBlock); - SmallVector indexOps; + SmallVector indexOps; createForAllDimensions(builder, loc, indexOps); createForAllDimensions(builder, loc, indexOps); createForAllDimensions(builder, loc, indexOps); @@ -69,7 +69,7 @@ static gpu::LaunchFuncOp inlineBeneficiaryOps(gpu::GPUFuncOp kernelFunc, gpu::LaunchFuncOp launch) { OpBuilder kernelBuilder(kernelFunc.getBody()); auto &firstBlock = kernelFunc.getBody().front(); - SmallVector newLaunchArgs; + SmallVector newLaunchArgs; BlockAndValueMapping map; for (int i = 0, e = launch.getNumKernelOperands(); i < e; ++i) { map.map(launch.getKernelOperand(i), kernelFunc.getArgument(i)); @@ -82,7 +82,7 @@ static gpu::LaunchFuncOp inlineBeneficiaryOps(gpu::GPUFuncOp kernelFunc, } // Only inline operations that do not create new arguments. if (!llvm::all_of(operandOp->getOperands(), - [map](Value *value) { return map.contains(value); })) { + [map](ValuePtr value) { return map.contains(value); })) { continue; } auto clone = kernelBuilder.clone(*operandOp, map); diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index 1813b30165f..b94ee335bd2 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -415,7 +415,7 @@ static ParseResult parseCallOp(OpAsmParser &parser, OperationState &result) { // Expects vector to be of wrapped LLVM vector type and position to be of // wrapped LLVM i32 type. void LLVM::ExtractElementOp::build(Builder *b, OperationState &result, - Value *vector, Value *position, + ValuePtr vector, ValuePtr position, ArrayRef attrs) { auto wrappedVectorType = vector->getType().cast(); auto llvmType = wrappedVectorType.getVectorElementType(); @@ -681,7 +681,7 @@ static void printBrOp(OpAsmPrinter &p, BrOp &op) { // attribute-dict? static ParseResult parseBrOp(OpAsmParser &parser, OperationState &result) { Block *dest; - SmallVector operands; + SmallVector operands; if (parser.parseSuccessorAndUseList(dest, operands) || parser.parseOptionalAttrDict(result.attributes)) return failure(); @@ -708,8 +708,8 @@ static void printCondBrOp(OpAsmPrinter &p, CondBrOp &op) { static ParseResult parseCondBrOp(OpAsmParser &parser, OperationState &result) { Block *trueDest; Block *falseDest; - SmallVector trueOperands; - SmallVector falseOperands; + SmallVector trueOperands; + SmallVector falseOperands; OpAsmParser::OperandType condition; Builder &builder = parser.getBuilder(); @@ -1066,8 +1066,8 @@ static LogicalResult verify(GlobalOp op) { //===----------------------------------------------------------------------===// // Expects vector to be of wrapped LLVM vector type and position to be of // wrapped LLVM i32 type. -void LLVM::ShuffleVectorOp::build(Builder *b, OperationState &result, Value *v1, - Value *v2, ArrayAttr mask, +void LLVM::ShuffleVectorOp::build(Builder *b, OperationState &result, + ValuePtr v1, ValuePtr v2, ArrayAttr mask, ArrayRef attrs) { auto wrappedContainerType1 = v1->getType().cast(); auto vType = LLVMType::getVectorTy( @@ -1664,10 +1664,10 @@ LLVMType LLVMType::getVoidTy(LLVMDialect *dialect) { // Utility functions. //===----------------------------------------------------------------------===// -Value *mlir::LLVM::createGlobalString(Location loc, OpBuilder &builder, - StringRef name, StringRef value, - LLVM::Linkage linkage, - LLVM::LLVMDialect *llvmDialect) { +ValuePtr mlir::LLVM::createGlobalString(Location loc, OpBuilder &builder, + StringRef name, StringRef value, + LLVM::Linkage linkage, + LLVM::LLVMDialect *llvmDialect) { assert(builder.getInsertionBlock() && builder.getInsertionBlock()->getParentOp() && "expected builder to point to a block constrained in an op"); @@ -1684,13 +1684,13 @@ Value *mlir::LLVM::createGlobalString(Location loc, OpBuilder &builder, builder.getStringAttr(value)); // Get the pointer to the first character in the global string. - Value *globalPtr = builder.create(loc, global); - Value *cst0 = builder.create( + ValuePtr globalPtr = builder.create(loc, global); + ValuePtr cst0 = builder.create( loc, LLVM::LLVMType::getInt64Ty(llvmDialect), builder.getIntegerAttr(builder.getIndexType(), 0)); return builder.create( loc, LLVM::LLVMType::getInt8PtrTy(llvmDialect), globalPtr, - ArrayRef({cst0, cst0})); + ArrayRef({cst0, cst0})); } bool mlir::LLVM::satisfiesLLVMModule(Operation *op) { diff --git a/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp b/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp index d7e4d08527d..ee122e16037 100644 --- a/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp +++ b/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp @@ -49,7 +49,7 @@ static StringRef toStringRef(LinalgDependenceGraph::DependenceType dt) { llvm_unreachable("Unexpected DependenceType"); } -Value *Aliases::find(Value *v) { +ValuePtr Aliases::find(ValuePtr v) { if (isa(v)) return v; @@ -147,9 +147,9 @@ LinalgDependenceGraph::getDependencesInto( } void LinalgDependenceGraph::addDependencesBetween(LinalgOp src, LinalgOp dst) { - for (auto *srcView : src.getOutputs()) { // W + for (auto srcView : src.getOutputs()) { // W // RAW graph - for (auto *dstView : dst.getInputs()) { // R + for (auto dstView : dst.getInputs()) { // R if (aliases.alias(srcView, dstView)) { // if alias, fill RAW addDependenceElem(DependenceType::RAW, LinalgOpView{src.getOperation(), srcView}, @@ -157,7 +157,7 @@ void LinalgDependenceGraph::addDependencesBetween(LinalgOp src, LinalgOp dst) { } } // WAW graph - for (auto *dstView : dst.getOutputs()) { // W + for (auto dstView : dst.getOutputs()) { // W if (aliases.alias(srcView, dstView)) { // if alias, fill WAW addDependenceElem(DependenceType::WAW, LinalgOpView{src.getOperation(), srcView}, @@ -165,9 +165,9 @@ void LinalgDependenceGraph::addDependencesBetween(LinalgOp src, LinalgOp dst) { } } } - for (auto *srcView : src.getInputs()) { // R + for (auto srcView : src.getInputs()) { // R // RAR graph - for (auto *dstView : dst.getInputs()) { // R + for (auto dstView : dst.getInputs()) { // R if (aliases.alias(srcView, dstView)) { // if alias, fill RAR addDependenceElem(DependenceType::RAR, LinalgOpView{src.getOperation(), srcView}, @@ -175,7 +175,7 @@ void LinalgDependenceGraph::addDependencesBetween(LinalgOp src, LinalgOp dst) { } } // WAR graph - for (auto *dstView : dst.getOutputs()) { // W + for (auto dstView : dst.getOutputs()) { // W if (aliases.alias(srcView, dstView)) { // if alias, fill WAR addDependenceElem(DependenceType::WAR, LinalgOpView{src.getOperation(), srcView}, @@ -194,14 +194,14 @@ LinalgDependenceGraph::findCoveringDependences(LinalgOp srcLinalgOp, } SmallVector LinalgDependenceGraph::findCoveringWrites( - LinalgOp srcLinalgOp, LinalgOp dstLinalgOp, Value *view) const { + LinalgOp srcLinalgOp, LinalgOp dstLinalgOp, ValuePtr view) const { return findOperationsWithCoveringDependences( srcLinalgOp, dstLinalgOp, view, {DependenceType::WAW, DependenceType::WAR}); } SmallVector LinalgDependenceGraph::findCoveringReads( - LinalgOp srcLinalgOp, LinalgOp dstLinalgOp, Value *view) const { + LinalgOp srcLinalgOp, LinalgOp dstLinalgOp, ValuePtr view) const { return findOperationsWithCoveringDependences( srcLinalgOp, dstLinalgOp, view, {DependenceType::RAR, DependenceType::RAW}); @@ -209,7 +209,7 @@ SmallVector LinalgDependenceGraph::findCoveringReads( SmallVector LinalgDependenceGraph::findOperationsWithCoveringDependences( - LinalgOp srcLinalgOp, LinalgOp dstLinalgOp, Value *view, + LinalgOp srcLinalgOp, LinalgOp dstLinalgOp, ValuePtr view, ArrayRef types) const { auto *src = srcLinalgOp.getOperation(); auto *dst = dstLinalgOp.getOperation(); diff --git a/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp b/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp index ba96186da38..7b530d7f0df 100644 --- a/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp +++ b/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp @@ -44,8 +44,8 @@ static void getMaxDimIndex(ArrayRef structuredIndices, Operation *mlir::edsc::makeLinalgGenericOp( ArrayRef iteratorTypes, ArrayRef inputs, ArrayRef outputs, - function_ref)> regionBuilder, - ArrayRef otherValues, ArrayRef otherAttributes) { + function_ref)> regionBuilder, + ArrayRef otherValues, ArrayRef otherAttributes) { auto &builder = edsc::ScopedContext::getBuilder(); auto *ctx = builder.getContext(); unsigned nInputs = inputs.size(); @@ -66,7 +66,7 @@ Operation *mlir::edsc::makeLinalgGenericOp( AffineMap::get(/*dimCount=*/nDims, /*symbolCount=*/0, out.getExprs())); unsigned nViews = nInputs + nOutputs; - SmallVector values; + SmallVector values; values.reserve(nViews); values.append(inputs.begin(), inputs.end()); values.append(outputs.begin(), outputs.end()); @@ -109,7 +109,7 @@ Operation *mlir::edsc::makeLinalgGenericOp( return op; } -void mlir::edsc::ops::macRegionBuilder(ArrayRef args) { +void mlir::edsc::ops::macRegionBuilder(ArrayRef args) { using edsc::op::operator+; using edsc::op::operator*; assert(args.size() == 3 && "expected 3 block arguments"); @@ -122,7 +122,7 @@ Operation *mlir::edsc::ops::linalg_pointwise(UnaryPointwiseOpBuilder unaryOp, StructuredIndexed O) { SmallVector iterTypes(O.getExprs().size(), edsc::IterType::Parallel); - auto fun = [&unaryOp](ArrayRef args) { + auto fun = [&unaryOp](ArrayRef args) { assert(args.size() == 2 && "expected 2 block arguments"); ValueHandle a(args[0]); linalg_yield(unaryOp(a)); @@ -135,7 +135,7 @@ Operation *mlir::edsc::ops::linalg_pointwise_tanh(StructuredIndexed I, ; using edsc::intrinsics::tanh; UnaryPointwiseOpBuilder unOp( - [](ValueHandle a) -> Value * { return tanh(a); }); + [](ValueHandle a) -> ValuePtr { return tanh(a); }); return linalg_pointwise(unOp, I, O); } @@ -146,7 +146,7 @@ Operation *mlir::edsc::ops::linalg_pointwise(BinaryPointwiseOpBuilder binaryOp, StructuredIndexed O) { SmallVector iterTypes(O.getExprs().size(), edsc::IterType::Parallel); - auto fun = [&binaryOp](ArrayRef args) { + auto fun = [&binaryOp](ArrayRef args) { assert(args.size() == 3 && "expected 3 block arguments"); ValueHandle a(args[0]), b(args[1]); linalg_yield(binaryOp(a, b)); @@ -159,14 +159,14 @@ Operation *mlir::edsc::ops::linalg_pointwise_add(StructuredIndexed I1, StructuredIndexed O) { using edsc::op::operator+; BinaryPointwiseOpBuilder binOp( - [](ValueHandle a, ValueHandle b) -> Value * { return a + b; }); + [](ValueHandle a, ValueHandle b) -> ValuePtr { return a + b; }); return linalg_pointwise(binOp, I1, I2, O); } Operation *mlir::edsc::ops::linalg_pointwise_max(StructuredIndexed I1, StructuredIndexed I2, StructuredIndexed O) { - BinaryPointwiseOpBuilder binOp([](ValueHandle a, ValueHandle b) -> Value * { + BinaryPointwiseOpBuilder binOp([](ValueHandle a, ValueHandle b) -> ValuePtr { using edsc::intrinsics::select; using edsc::op::operator>; return select(a > b, a, b).getValue(); diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp index 6eca181e9b4..c5f30b7e10b 100644 --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -318,7 +318,7 @@ static ParseResult parseRangeOp(OpAsmParser &parser, OperationState &result) { // SliceOp //===----------------------------------------------------------------------===// void mlir::linalg::SliceOp::build(Builder *b, OperationState &result, - Value *base, ValueRange indexings) { + ValuePtr base, ValueRange indexings) { result.addOperands(base); result.addOperands(indexings); @@ -394,7 +394,7 @@ static LogicalResult verify(SliceOp op) { // TransposeOp //===----------------------------------------------------------------------===// void mlir::linalg::TransposeOp::build(Builder *b, OperationState &result, - Value *view, AffineMapAttr permutation, + ValuePtr view, AffineMapAttr permutation, ArrayRef attrs) { auto permutationMap = permutation.getValue(); assert(permutationMap); diff --git a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp index 453daba204c..49cea7e4170 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp @@ -77,16 +77,16 @@ static llvm::cl::list clTileSizes( static LinalgOp cloneWithLoopRanges(OpBuilder &b, Location loc, LinalgOp op, ArrayRef loopRanges) { auto maps = loopToOperandRangesMaps(op); - SmallVector clonedViews; + SmallVector clonedViews; clonedViews.reserve(op.getNumInputsAndOutputs()); // Iterate over the inputs and outputs in order. // Extract the subranges from the linearized ranges. - SmallVector ios(op.getInputsAndOutputs()); + SmallVector ios(op.getInputsAndOutputs()); for (auto en : llvm::enumerate(ios)) { unsigned idx = en.index(); auto map = maps[idx]; LLVM_DEBUG(dbgs() << "map: " << map << "\n"); - Value *view = en.value(); + ValuePtr view = en.value(); SmallVector viewRanges(map.getNumResults()); for (auto en2 : llvm::enumerate(map.getResults())) { unsigned d = en2.index(); @@ -99,7 +99,7 @@ static LinalgOp cloneWithLoopRanges(OpBuilder &b, Location loc, LinalgOp op, } // Construct a new subview for the tile. unsigned rank = viewRanges.size(); - SmallVector offsets, sizes, strides; + SmallVector offsets, sizes, strides; offsets.reserve(rank); sizes.reserve(rank); strides.reserve(rank); @@ -117,7 +117,7 @@ static LinalgOp cloneWithLoopRanges(OpBuilder &b, Location loc, LinalgOp op, } struct ViewDimension { - Value *view; + ValuePtr view; unsigned dimension; }; @@ -130,14 +130,14 @@ static ViewDimension getViewDefiningLoopRange(LinalgOp op, unsigned loopDepth) { auto maps = loopToOperandRangesMaps(op); // Iterate over the inputs and outputs in order. // Extract the subranges from the linearized ranges. - SmallVector ios(op.getInputsAndOutputs()); + SmallVector ios(op.getInputsAndOutputs()); for (auto en : llvm::enumerate(ios)) { unsigned idx = en.index(); auto map = maps[idx]; LLVM_DEBUG(dbgs() << "getViewDefiningLoopRange I/O idx: " << idx << "\n"); LLVM_DEBUG(dbgs() << "getViewDefiningLoopRange map: " << map << "\n"); - Value *view = en.value(); - SmallVector viewRanges(map.getNumResults(), nullptr); + ValuePtr view = en.value(); + SmallVector viewRanges(map.getNumResults(), nullptr); for (auto en2 : llvm::enumerate(map.getResults())) { if (loopDepth == en2.value().cast().getPosition()) { LLVM_DEBUG(dbgs() << "getViewDefiningLoopRange loopDepth: " << loopDepth @@ -151,9 +151,9 @@ static ViewDimension getViewDefiningLoopRange(LinalgOp op, unsigned loopDepth) { llvm_unreachable("Expect to be able to extract a view defining loop range"); } -static LinalgOp fuse(Value *producedView, LinalgOp producer, LinalgOp consumer, - unsigned consumerIdx, unsigned producerIdx, - OperationFolder *folder) { +static LinalgOp fuse(ValuePtr producedView, LinalgOp producer, + LinalgOp consumer, unsigned consumerIdx, + unsigned producerIdx, OperationFolder *folder) { auto subView = dyn_cast_or_null( consumer.getInput(consumerIdx)->getDefiningOp()); auto slice = dyn_cast_or_null( @@ -206,7 +206,7 @@ static LinalgOp fuse(Value *producedView, LinalgOp producer, LinalgOp consumer, // Encode structural fusion safety preconditions. // Some of these will be lifted in the future with better analysis. static bool isStructurallyFusableProducer(LinalgOp producer, - Value *consumedView, + ValuePtr consumedView, LinalgOp consumer) { if (producer.getNumOutputs() != 1) { LLVM_DEBUG(dbgs() << "\nNot structurally fusable (multi-output)"); @@ -226,7 +226,7 @@ static bool isStructurallyFusableProducer(LinalgOp producer, bool mlir::linalg::isProducerLastWriteOfView(const LinalgDependenceGraph &graph, LinalgOp consumer, - Value *consumedView, + ValuePtr consumedView, LinalgOp producer) { // Make some simple structural checks that alleviate the need for more // complex analyses. @@ -245,7 +245,7 @@ bool mlir::linalg::isProducerLastWriteOfView(const LinalgDependenceGraph &graph, } bool mlir::linalg::isFusableInto(const LinalgDependenceGraph &graph, - LinalgOp consumer, Value *consumedView, + LinalgOp consumer, ValuePtr consumedView, LinalgOp producer) { if (!isProducerLastWriteOfView(graph, consumer, consumedView, producer)) return false; @@ -272,13 +272,13 @@ Optional mlir::linalg::fuseProducerOf( auto producer = cast(dependence.dependentOpView.op); // Check that the dependence is indeed on the input `consumerIdx` view. - auto *consumedView = dependence.indexingView; + auto consumedView = dependence.indexingView; if (consumer.getInput(consumerIdx) != consumedView) continue; // Consumer consumes this view, `isStructurallyFusableProducer` also checks // whether it is a strict subview of the producer view. - auto *producedView = dependence.dependentOpView.view; + auto producedView = dependence.dependentOpView.view; auto producerIdx = producer.getIndexOfOutput(producedView).getValue(); // `consumerIdx` and `producerIdx` exist by construction. LLVM_DEBUG(dbgs() << "\nRAW producer: " << *producer.getOperation() diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp index c50c495750f..e468c19a0b4 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp @@ -49,7 +49,7 @@ using edsc::op::operator==; static SmallVector makeCanonicalAffineApplies(OpBuilder &b, Location loc, AffineMap map, - ArrayRef vals) { + ArrayRef vals) { assert(map.getNumSymbols() == 0); assert(map.getNumInputs() == vals.size()); SmallVector res; @@ -57,35 +57,35 @@ makeCanonicalAffineApplies(OpBuilder &b, Location loc, AffineMap map, auto dims = map.getNumDims(); for (auto e : map.getResults()) { auto exprMap = AffineMap::get(dims, 0, e); - SmallVector operands(vals.begin(), vals.end()); + SmallVector operands(vals.begin(), vals.end()); canonicalizeMapAndOperands(&exprMap, &operands); res.push_back(affine_apply(exprMap, operands)); } return res; } -static SmallVector permuteIvs(ArrayRef ivs, - Optional permutation) { +static SmallVector permuteIvs(ArrayRef ivs, + Optional permutation) { return permutation ? applyMapToValues(ScopedContext::getBuilder(), ScopedContext::getLocation(), permutation.getValue(), ivs) - : SmallVector(ivs.begin(), ivs.end()); + : SmallVector(ivs.begin(), ivs.end()); } // Creates a number of ranges equal to the number of results in `map`. // The returned ranges correspond to the loop ranges, in the proper order, for // which new loops will be created. -static SmallVector emitLoopRanges(OpBuilder &b, Location loc, - AffineMap map, - ArrayRef allViewSizes); -SmallVector emitLoopRanges(OpBuilder &b, Location loc, - AffineMap map, - ArrayRef allViewSizes) { +static SmallVector emitLoopRanges(OpBuilder &b, Location loc, + AffineMap map, + ArrayRef allViewSizes); +SmallVector emitLoopRanges(OpBuilder &b, Location loc, + AffineMap map, + ArrayRef allViewSizes) { // Apply `map` to get view sizes in loop order. auto sizes = applyMapToValues(b, loc, map, allViewSizes); // Create a new range with the applied tile sizes. ScopedContext scope(b, loc); - SmallVector res; + SmallVector res; for (unsigned idx = 0, e = map.getNumResults(); idx < e; ++idx) { res.push_back(range(constant_index(0), sizes[idx], constant_index(1))); } @@ -98,7 +98,7 @@ class LinalgScopedEmitter {}; template class LinalgScopedEmitter { public: - static void emitScalarImplementation(ArrayRef allIvs, + static void emitScalarImplementation(ArrayRef allIvs, CopyOp copyOp) { auto nPar = copyOp.getNumParallelLoops(); assert(nPar == allIvs.size()); @@ -121,7 +121,7 @@ public: template class LinalgScopedEmitter { public: - static void emitScalarImplementation(ArrayRef allIvs, + static void emitScalarImplementation(ArrayRef allIvs, FillOp fillOp) { auto nPar = fillOp.getNumParallelLoops(); assert(nPar == allIvs.size()); @@ -138,7 +138,7 @@ public: template class LinalgScopedEmitter { public: - static void emitScalarImplementation(ArrayRef allIvs, DotOp dotOp) { + static void emitScalarImplementation(ArrayRef allIvs, DotOp dotOp) { assert(allIvs.size() == 1); IndexHandle r_i(allIvs[0]); IndexedValueType A(dotOp.getInput(0)), B(dotOp.getInput(1)), @@ -151,7 +151,7 @@ public: template class LinalgScopedEmitter { public: - static void emitScalarImplementation(ArrayRef allIvs, + static void emitScalarImplementation(ArrayRef allIvs, MatvecOp matvecOp) { assert(allIvs.size() == 2); IndexHandle i(allIvs[0]), r_j(allIvs[1]); @@ -165,7 +165,7 @@ public: template class LinalgScopedEmitter { public: - static void emitScalarImplementation(ArrayRef allIvs, + static void emitScalarImplementation(ArrayRef allIvs, MatmulOp matmulOp) { assert(allIvs.size() == 3); IndexHandle i(allIvs[0]), j(allIvs[1]), r_k(allIvs[2]); @@ -179,7 +179,7 @@ public: template class LinalgScopedEmitter { public: - static void emitScalarImplementation(ArrayRef allIvs, + static void emitScalarImplementation(ArrayRef allIvs, ConvOp convOp) { auto b = ScopedContext::getBuilder(); auto loc = ScopedContext::getLocation(); @@ -229,14 +229,14 @@ public: template class LinalgScopedEmitter { public: - static void emitScalarImplementation(ArrayRef allIvs, + static void emitScalarImplementation(ArrayRef allIvs, GenericOp genericOp) { auto b = ScopedContext::getBuilder(); auto loc = ScopedContext::getLocation(); using edsc::intrinsics::detail::ValueHandleArray; unsigned nInputs = genericOp.getNumInputs(); unsigned nOutputs = genericOp.getNumOutputs(); - SmallVector indexedValues(nInputs + nOutputs); + SmallVector indexedValues(nInputs + nOutputs); // 1.a. Emit std_load from input views. for (unsigned i = 0; i < nInputs; ++i) { @@ -324,7 +324,7 @@ public: template class LinalgScopedEmitter { public: - static void emitScalarImplementation(ArrayRef allIvs, + static void emitScalarImplementation(ArrayRef allIvs, IndexedGenericOp indexedGenericOp) { auto b = ScopedContext::getBuilder(); auto loc = ScopedContext::getLocation(); @@ -332,7 +332,7 @@ public: unsigned nInputs = indexedGenericOp.getNumInputs(); unsigned nOutputs = indexedGenericOp.getNumOutputs(); unsigned nLoops = allIvs.size(); - SmallVector indexedValues(nLoops + nInputs + nOutputs); + SmallVector indexedValues(nLoops + nInputs + nOutputs); for (unsigned i = 0; i < nLoops; ++i) { indexedValues[i] = allIvs[i]; diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp index f4364928af8..999406e05cf 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp @@ -99,7 +99,7 @@ LogicalResult mlir::linalg::tileAndFuseLinalgOpAndSetMarker( } bool mlir::linalg::detail::isProducedByOpOfTypeImpl( - Operation *consumerOp, Value *consumedView, + Operation *consumerOp, ValuePtr consumedView, function_ref isaOpType) { LinalgOp consumer = dyn_cast(consumerOp); if (!consumer) @@ -175,7 +175,7 @@ LogicalResult mlir::linalg::vectorizeGenericOp(PatternRewriter &rewriter, return failure(); // TODO(ntv): non-identity layout. - auto isStaticMemRefWithIdentityLayout = [](Value *v) { + auto isStaticMemRefWithIdentityLayout = [](ValuePtr v) { auto m = v->getType().dyn_cast(); if (!m || !m.hasStaticShape() || !m.getAffineMaps().empty()) return false; @@ -235,7 +235,7 @@ mlir::linalg::permuteGenericLinalgOp(PatternRewriter &rewriter, Operation *op, LogicalResult mlir::linalg::linalgOpPromoteSubviews(PatternRewriter &rewriter, Operation *op) { LinalgOp linOp = dyn_cast(op); - SetVector subViews; + SetVector subViews; for (auto it : linOp.getInputsAndOutputs()) if (auto sv = dyn_cast_or_null(it->getDefiningOp())) subViews.insert(sv); diff --git a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp index c7fbebce383..b1dae455194 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp @@ -55,14 +55,15 @@ static llvm::cl::opt clPromoteDynamic( llvm::cl::desc("Test generation of dynamic promoted buffers"), llvm::cl::cat(clOptionsCategory), llvm::cl::init(false)); -static Value *allocBuffer(Type elementType, Value *size, bool dynamicBuffers) { +static ValuePtr allocBuffer(Type elementType, ValuePtr size, + bool dynamicBuffers) { auto *ctx = size->getContext(); auto width = llvm::divideCeil(elementType.getIntOrFloatBitWidth(), 8); if (!dynamicBuffers) if (auto cst = dyn_cast_or_null(size->getDefiningOp())) return alloc( MemRefType::get(width * cst.getValue(), IntegerType::get(8, ctx))); - Value *mul = muli(constant_index(width), size); + ValuePtr mul = muli(constant_index(width), size); return alloc(MemRefType::get(-1, IntegerType::get(8, ctx)), mul); } @@ -92,20 +93,20 @@ static PromotionInfo promoteFullTileBuffer(OpBuilder &b, Location loc, auto viewType = subView.getType(); auto rank = viewType.getRank(); - Value *allocSize = one; - SmallVector fullRanges, partialRanges; + ValuePtr allocSize = one; + SmallVector fullRanges, partialRanges; fullRanges.reserve(rank); partialRanges.reserve(rank); for (auto en : llvm::enumerate(subView.getRanges())) { auto rank = en.index(); auto rangeValue = en.value(); - Value *d = rangeValue.size; + ValuePtr d = rangeValue.size; allocSize = muli(folder, allocSize, d).getValue(); fullRanges.push_back(d); partialRanges.push_back(range(folder, zero, dim(subView, rank), one)); } SmallVector dynSizes(fullRanges.size(), -1); - auto *buffer = + auto buffer = allocBuffer(viewType.getElementType(), allocSize, dynamicBuffers); auto fullLocalView = view( MemRefType::get(dynSizes, viewType.getElementType()), buffer, fullRanges); @@ -115,7 +116,7 @@ static PromotionInfo promoteFullTileBuffer(OpBuilder &b, Location loc, SmallVector mlir::linalg::promoteSubViews(OpBuilder &b, Location loc, - ArrayRef subViews, bool dynamicBuffers, + ArrayRef subViews, bool dynamicBuffers, OperationFolder *folder) { if (subViews.empty()) return {}; @@ -123,8 +124,8 @@ mlir::linalg::promoteSubViews(OpBuilder &b, Location loc, ScopedContext scope(b, loc); SmallVector res; res.reserve(subViews.size()); - DenseMap promotionInfoMap; - for (auto *v : subViews) { + DenseMap promotionInfoMap; + for (auto v : subViews) { SubViewOp subView = cast(v->getDefiningOp()); auto viewType = subView.getType(); // TODO(ntv): support more cases than just float. @@ -136,7 +137,7 @@ mlir::linalg::promoteSubViews(OpBuilder &b, Location loc, res.push_back(promotionInfo); } - for (auto *v : subViews) { + for (auto v : subViews) { SubViewOp subView = cast(v->getDefiningOp()); auto info = promotionInfoMap.find(v); if (info == promotionInfoMap.end()) @@ -144,14 +145,14 @@ mlir::linalg::promoteSubViews(OpBuilder &b, Location loc, // TODO(ntv): value to fill with should be related to the operation. // For now, just use APFloat(0.0f). auto t = subView.getType().getElementType().cast(); - Value *fillVal = constant_float(folder, APFloat(0.0f), t); + ValuePtr fillVal = constant_float(folder, APFloat(0.0f), t); // TODO(ntv): fill is only necessary if `promotionInfo` has a full local // view that is different from the partial local view and we are on the // boundary. fill(info->second.fullLocalView, fillVal); } - for (auto *v : subViews) { + for (auto v : subViews) { auto info = promotionInfoMap.find(v); if (info == promotionInfoMap.end()) continue; @@ -161,19 +162,19 @@ mlir::linalg::promoteSubViews(OpBuilder &b, Location loc, } LinalgOp mlir::linalg::promoteSubViewOperands(OpBuilder &b, LinalgOp op, - SetVector subViews, + SetVector subViews, bool dynamicBuffers, OperationFolder *folder) { // 1. Promote the specified views and use them in the new op. ScopedContext scope(b, op.getLoc()); auto promotedBufferAndViews = promoteSubViews( b, op.getLoc(), subViews.getArrayRef(), dynamicBuffers, folder); - SmallVector opViews; + SmallVector opViews; opViews.reserve(op.getNumInputsAndOutputs()); - SmallVector, 8> writebackViews; + SmallVector, 8> writebackViews; writebackViews.reserve(subViews.size()); unsigned promotedIdx = 0; - for (auto *view : op.getInputsAndOutputs()) { + for (auto view : op.getInputsAndOutputs()) { if (subViews.count(view) != 0) { opViews.push_back(promotedBufferAndViews[promotedIdx].fullLocalView); writebackViews.emplace_back(std::make_pair( @@ -214,7 +215,7 @@ static void promoteSubViews(FuncOp f, bool dynamicBuffers) { f.walk([dynamicBuffers, &folder, &toErase](LinalgOp op) { // TODO(ntv) some heuristic here to decide what to promote. Atm it is all or // nothing. - SetVector subViews; + SetVector subViews; OpBuilder b(op); for (auto it : op.getInputsAndOutputs()) if (auto sv = dyn_cast_or_null(it->getDefiningOp())) diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp index 4d8a24cb6cb..07d559918cf 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -53,7 +53,7 @@ static llvm::cl::list llvm::cl::ZeroOrMore, llvm::cl::MiscFlags::CommaSeparated, llvm::cl::cat(clOptionsCategory)); -static bool isZero(Value *v) { +static bool isZero(ValuePtr v) { return isa_and_nonnull(v->getDefiningOp()) && cast(v->getDefiningOp()).getValue() == 0; } @@ -71,12 +71,12 @@ using LoopIndexToRangeIndexMap = DenseMap; // indices of newly created loops. static std::tuple, LoopIndexToRangeIndexMap> makeTiledLoopRanges(OpBuilder &b, Location loc, AffineMap map, - ArrayRef allViewSizes, - ArrayRef allTileSizes, OperationFolder *folder) { + ArrayRef allViewSizes, + ArrayRef allTileSizes, OperationFolder *folder) { assert(allTileSizes.size() == map.getNumResults()); // Apply `map` to get view sizes in loop order. auto viewSizes = applyMapToValues(b, loc, map, allViewSizes, folder); - SmallVector tileSizes(allTileSizes.begin(), allTileSizes.end()); + SmallVector tileSizes(allTileSizes.begin(), allTileSizes.end()); // Traverse the tile sizes, which are in loop order, erase zeros everywhere. LoopIndexToRangeIndexMap loopIndexToRangeIndex; @@ -110,7 +110,7 @@ namespace { // `d0 + 2 * d1 + d3` is tiled by [0, 0, 0, 2] but not by [0, 0, 2, 0] // struct TileCheck : public AffineExprVisitor { - TileCheck(ArrayRef tileSizes) + TileCheck(ArrayRef tileSizes) : isTiled(false), tileSizes(tileSizes) {} void visitDimExpr(AffineDimExpr expr) { @@ -124,7 +124,7 @@ struct TileCheck : public AffineExprVisitor { "nonpositive multiplying coefficient"); } bool isTiled; - ArrayRef tileSizes; + ArrayRef tileSizes; }; } // namespace @@ -206,11 +206,11 @@ void transformIndexedGenericOpIndices( auto rangeIndex = loopIndexToRangeIndex.find(i); if (rangeIndex == loopIndexToRangeIndex.end()) continue; - Value *oldIndex = block.getArgument(i); + ValuePtr oldIndex = block.getArgument(i); // Offset the index argument `i` by the value of the corresponding induction // variable and replace all uses of the previous value. - Value *newIndex = b.create(indexedGenericOp.getLoc(), oldIndex, - pivs[rangeIndex->second]->getValue()); + ValuePtr newIndex = b.create(indexedGenericOp.getLoc(), oldIndex, + pivs[rangeIndex->second]->getValue()); for (auto &use : oldIndex->getUses()) { if (use.getOwner() == newIndex->getDefiningOp()) continue; @@ -219,7 +219,7 @@ void transformIndexedGenericOpIndices( } } -static bool isTiled(AffineExpr expr, ArrayRef tileSizes) { +static bool isTiled(AffineExpr expr, ArrayRef tileSizes) { if (!expr) return false; TileCheck t(tileSizes); @@ -229,7 +229,7 @@ static bool isTiled(AffineExpr expr, ArrayRef tileSizes) { // Checks whether the view with index `viewIndex` within `linalgOp` varies with // respect to a non-zero `tileSize`. -static bool isTiled(AffineMap map, ArrayRef tileSizes) { +static bool isTiled(AffineMap map, ArrayRef tileSizes) { if (!map) return false; for (unsigned r = 0; r < map.getNumResults(); ++r) @@ -238,13 +238,13 @@ static bool isTiled(AffineMap map, ArrayRef tileSizes) { return false; } -static SmallVector +static SmallVector makeTiledViews(OpBuilder &b, Location loc, LinalgOp linalgOp, - ArrayRef ivs, ArrayRef tileSizes, - ArrayRef viewSizes, OperationFolder *folder) { + ArrayRef ivs, ArrayRef tileSizes, + ArrayRef viewSizes, OperationFolder *folder) { assert(ivs.size() == static_cast(llvm::count_if( llvm::make_range(tileSizes.begin(), tileSizes.end()), - [](Value *v) { return !isZero(v); })) && + [](ValuePtr v) { return !isZero(v); })) && "expected as many ivs as non-zero sizes"); using edsc::intrinsics::select; @@ -253,21 +253,22 @@ makeTiledViews(OpBuilder &b, Location loc, LinalgOp linalgOp, // Construct (potentially temporary) mins and maxes on which to apply maps // that define tile subviews. - SmallVector lbs, subViewSizes; + SmallVector lbs, subViewSizes; for (unsigned idx = 0, idxIvs = 0, e = tileSizes.size(); idx < e; ++idx) { bool isTiled = !isZero(tileSizes[idx]); - lbs.push_back(isTiled ? ivs[idxIvs++] : (Value *)constant_index(folder, 0)); + lbs.push_back(isTiled ? ivs[idxIvs++] + : (ValuePtr)constant_index(folder, 0)); subViewSizes.push_back(isTiled ? tileSizes[idx] : viewSizes[idx]); } auto *op = linalgOp.getOperation(); - SmallVector res; + SmallVector res; res.reserve(op->getNumOperands()); auto viewIteratorBegin = linalgOp.getInputsAndOutputs().begin(); for (unsigned viewIndex = 0; viewIndex < linalgOp.getNumInputsAndOutputs(); ++viewIndex) { - Value *view = *(viewIteratorBegin + viewIndex); + ValuePtr view = *(viewIteratorBegin + viewIndex); unsigned rank = view->getType().cast().getRank(); auto map = loopToOperandRangesMaps(linalgOp)[viewIndex]; // If the view is not tiled, we can use it as is. @@ -277,7 +278,7 @@ makeTiledViews(OpBuilder &b, Location loc, LinalgOp linalgOp, } // Construct a new subview for the tile. - SmallVector offsets, sizes, strides; + SmallVector offsets, sizes, strides; offsets.reserve(rank); sizes.reserve(rank); strides.reserve(rank); @@ -292,9 +293,9 @@ makeTiledViews(OpBuilder &b, Location loc, LinalgOp linalgOp, // Tiling creates a new slice at the proper index, the slice step is 1 // (i.e. the slice view does not subsample, stepping occurs in the loop). auto m = map.getSubMap({r}); - auto *offset = applyMapToValues(b, loc, m, lbs, folder).front(); + auto offset = applyMapToValues(b, loc, m, lbs, folder).front(); offsets.push_back(offset); - auto *size = applyMapToValues(b, loc, m, subViewSizes, folder).front(); + auto size = applyMapToValues(b, loc, m, subViewSizes, folder).front(); sizes.push_back(size); strides.push_back(constant_index(folder, 1)); } @@ -308,7 +309,7 @@ makeTiledViews(OpBuilder &b, Location loc, LinalgOp linalgOp, // This is a special type of folding that we only apply when `folder` is // defined. if (folder) - for (auto *v : llvm::concat(lbs, subViewSizes)) + for (auto v : llvm::concat(lbs, subViewSizes)) if (v->use_empty()) v->getDefiningOp()->erase(); @@ -316,7 +317,7 @@ makeTiledViews(OpBuilder &b, Location loc, LinalgOp linalgOp, } Optional mlir::linalg::tileLinalgOp( - OpBuilder &b, LinalgOp op, ArrayRef tileSizes, + OpBuilder &b, LinalgOp op, ArrayRef tileSizes, ArrayRef permutation, OperationFolder *folder) { // 1. Enforce the convention that "tiling by zero" skips tiling a particular // dimension. This convention is significantly simpler to handle instead of @@ -360,7 +361,7 @@ Optional mlir::linalg::tileLinalgOp( LoopNestRangeBuilder(pivs, loopRanges)([&] { auto b = ScopedContext::getBuilder(); auto loc = ScopedContext::getLocation(); - SmallVector ivValues(ivs.begin(), ivs.end()); + SmallVector ivValues(ivs.begin(), ivs.end()); // If we have to apply a permutation to the tiled loop nest, we have to // reorder the induction variables This permutation is the right one @@ -411,7 +412,7 @@ Optional mlir::linalg::tileLinalgOp( ScopedContext scope(b, op.getLoc()); // Materialize concrete tile size values to pass the generic tiling function. - SmallVector tileSizeValues; + SmallVector tileSizeValues; tileSizeValues.reserve(tileSizes.size()); for (auto ts : tileSizes) tileSizeValues.push_back(constant_index(folder, ts)); diff --git a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp index eb501f9b5b5..125937807f4 100644 --- a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp @@ -92,7 +92,7 @@ mlir::edsc::LoopNestRangeBuilder::LoopNestRangeBuilder( } mlir::edsc::LoopNestRangeBuilder::LoopNestRangeBuilder( - ArrayRef ivs, ArrayRef ranges) + ArrayRef ivs, ArrayRef ranges) : LoopNestRangeBuilder( ivs, SmallVector(ranges.begin(), ranges.end())) {} @@ -106,26 +106,26 @@ ValueHandle LoopNestRangeBuilder::LoopNestRangeBuilder::operator()( return ValueHandle::null(); } -static Value *emitOrFoldComposedAffineApply(OpBuilder &b, Location loc, - AffineMap map, - ArrayRef operandsRef, - OperationFolder *folder) { - SmallVector operands(operandsRef.begin(), operandsRef.end()); +static ValuePtr emitOrFoldComposedAffineApply(OpBuilder &b, Location loc, + AffineMap map, + ArrayRef operandsRef, + OperationFolder *folder) { + SmallVector operands(operandsRef.begin(), operandsRef.end()); fullyComposeAffineMapAndOperands(&map, &operands); canonicalizeMapAndOperands(&map, &operands); return folder ? folder->create(b, loc, map, operands) : b.create(loc, map, operands); } -SmallVector +SmallVector mlir::linalg::applyMapToValues(OpBuilder &b, Location loc, AffineMap map, - ArrayRef values, + ArrayRef values, OperationFolder *folder) { - SmallVector res; + SmallVector res; res.reserve(map.getNumResults()); unsigned numDims = map.getNumDims(); // For each `expr` in `map`, applies the `expr` to the values extracted from - // ranges. If the resulting application can be folded into a Value*, the + // ranges. If the resulting application can be folded into a Value, the // folding occurs eagerly. Otherwise, an affine.apply operation is emitted. for (auto expr : map.getResults()) { AffineMap map = AffineMap::get(numDims, 0, expr); @@ -137,12 +137,12 @@ mlir::linalg::applyMapToValues(OpBuilder &b, Location loc, AffineMap map, /// Returns all the operands of `linalgOp` that are not views. /// Asserts that these operands are value types to allow transformations like /// tiling to just use the values when cloning `linalgOp`. -SmallVector +SmallVector mlir::linalg::getAssumedNonViewOperands(LinalgOp linalgOp) { auto *op = linalgOp.getOperation(); unsigned numViews = linalgOp.getNumInputsAndOutputs(); unsigned nOperands = op->getNumOperands() - numViews; - SmallVector res; + SmallVector res; res.reserve(nOperands); for (unsigned i = 0; i < nOperands; ++i) { res.push_back(op->getOperand(numViews + i)); diff --git a/mlir/lib/Dialect/LoopOps/LoopOps.cpp b/mlir/lib/Dialect/LoopOps/LoopOps.cpp index fc8832e9a46..9610a1ac270 100644 --- a/mlir/lib/Dialect/LoopOps/LoopOps.cpp +++ b/mlir/lib/Dialect/LoopOps/LoopOps.cpp @@ -69,8 +69,8 @@ LoopOpsDialect::LoopOpsDialect(MLIRContext *context) // ForOp //===----------------------------------------------------------------------===// -void ForOp::build(Builder *builder, OperationState &result, Value *lb, - Value *ub, Value *step) { +void ForOp::build(Builder *builder, OperationState &result, ValuePtr lb, + ValuePtr ub, ValuePtr step) { result.addOperands({lb, ub, step}); Region *bodyRegion = result.addRegion(); ForOp::ensureTerminator(*bodyRegion, *builder, result.location); @@ -134,7 +134,7 @@ static ParseResult parseForOp(OpAsmParser &parser, OperationState &result) { Region &ForOp::getLoopBody() { return region(); } -bool ForOp::isDefinedOutsideOfLoop(Value *value) { +bool ForOp::isDefinedOutsideOfLoop(ValuePtr value) { return !region().isAncestor(value->getParentRegion()); } @@ -144,8 +144,8 @@ LogicalResult ForOp::moveOutOfLoop(ArrayRef ops) { return success(); } -ForOp mlir::loop::getForInductionVarOwner(Value *val) { - auto *ivArg = dyn_cast(val); +ForOp mlir::loop::getForInductionVarOwner(ValuePtr val) { + auto ivArg = dyn_cast(val); if (!ivArg) return ForOp(); assert(ivArg->getOwner() && "unlinked block argument"); @@ -157,7 +157,7 @@ ForOp mlir::loop::getForInductionVarOwner(Value *val) { // IfOp //===----------------------------------------------------------------------===// -void IfOp::build(Builder *builder, OperationState &result, Value *cond, +void IfOp::build(Builder *builder, OperationState &result, ValuePtr cond, bool withElseRegion) { result.addOperands(cond); Region *thenRegion = result.addRegion(); diff --git a/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp index def8ee810fe..4416e1e6b04 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp @@ -94,7 +94,7 @@ struct SPIRVInlinerInterface : public DialectInlinerInterface { /// Handle the given inlined terminator by replacing it with a new operation /// as necessary. void handleTerminator(Operation *op, - ArrayRef valuesToRepl) const final { + ArrayRef valuesToRepl) const final { // Only spv.ReturnValue needs to be handled here. auto retValOp = dyn_cast(op); if (!retValOp) diff --git a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp index 284fe915029..ca9b883a703 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp @@ -229,9 +229,9 @@ getOrInsertBuiltinVariable(spirv::ModuleOp &moduleOp, Location loc, /// Gets the global variable associated with a builtin and add /// it if it doesn't exist. -Value *mlir::spirv::getBuiltinVariableValue(Operation *op, - spirv::BuiltIn builtin, - OpBuilder &builder) { +ValuePtr mlir::spirv::getBuiltinVariableValue(Operation *op, + spirv::BuiltIn builtin, + OpBuilder &builder) { auto moduleOp = op->getParentOfType(); if (!moduleOp) { op->emitError("expected operation to be within a SPIR-V module"); @@ -239,7 +239,7 @@ Value *mlir::spirv::getBuiltinVariableValue(Operation *op, } spirv::GlobalVariableOp varOp = getOrInsertBuiltinVariable(moduleOp, op->getLoc(), builtin, builder); - Value *ptr = builder.create(op->getLoc(), varOp); + ValuePtr ptr = builder.create(op->getLoc(), varOp); return builder.create(op->getLoc(), ptr, /*memory_access =*/nullptr, /*alignment =*/nullptr); diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp index 0df4525bac6..a20c18056e1 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp @@ -273,8 +273,8 @@ static LogicalResult verifyMemorySemantics(BarrierOp op) { } template -static LogicalResult verifyLoadStorePtrAndValTypes(LoadStoreOpTy op, Value *ptr, - Value *val) { +static LogicalResult verifyLoadStorePtrAndValTypes(LoadStoreOpTy op, + ValuePtr ptr, ValuePtr val) { // ODS already checks ptr is spirv::PointerType. Just check that the pointee // type of the pointer and the type of the value are the same // @@ -664,8 +664,8 @@ static ParseResult parseShiftOp(OpAsmParser &parser, OperationState &state) { } static void printShiftOp(Operation *op, OpAsmPrinter &printer) { - Value *base = op->getOperand(0); - Value *shift = op->getOperand(1); + ValuePtr base = op->getOperand(0); + ValuePtr shift = op->getOperand(1); printer << op->getName() << ' ' << *base << ", " << *shift << " : " << base->getType() << ", " << shift->getType(); } @@ -742,7 +742,7 @@ static Type getElementPtrType(Type type, ValueRange indices, Location baseLoc) { } void spirv::AccessChainOp::build(Builder *builder, OperationState &state, - Value *basePtr, ValueRange indices) { + ValuePtr basePtr, ValueRange indices) { auto type = getElementPtrType(basePtr->getType(), indices, state.location); assert(type && "Unable to deduce return type based on basePtr and indices"); build(builder, state, type, basePtr, indices); @@ -782,8 +782,8 @@ static void print(spirv::AccessChainOp op, OpAsmPrinter &printer) { } static LogicalResult verify(spirv::AccessChainOp accessChainOp) { - SmallVector indices(accessChainOp.indices().begin(), - accessChainOp.indices().end()); + SmallVector indices(accessChainOp.indices().begin(), + accessChainOp.indices().end()); auto resultType = getElementPtrType(accessChainOp.base_ptr()->getType(), indices, accessChainOp.getLoc()); if (!resultType) { @@ -824,7 +824,7 @@ struct CombineChainedAccessChain } // Combine indices. - SmallVector indices(parentAccessChainOp.indices()); + SmallVector indices(parentAccessChainOp.indices()); indices.append(accessChainOp.indices().begin(), accessChainOp.indices().end()); @@ -1060,7 +1060,7 @@ static LogicalResult verify(spirv::BitFieldInsertOp bitFieldOp) { static ParseResult parseBranchOp(OpAsmParser &parser, OperationState &state) { Block *dest; - SmallVector destOperands; + SmallVector destOperands; if (parser.parseSuccessorAndUseList(dest, destOperands)) return failure(); state.addSuccessor(dest, destOperands); @@ -1089,7 +1089,7 @@ static ParseResult parseBranchConditionalOp(OpAsmParser &parser, auto &builder = parser.getBuilder(); OpAsmParser::OperandType condInfo; Block *dest; - SmallVector destOperands; + SmallVector destOperands; // Parse the condition. Type boolTy = builder.getI1Type(); @@ -1214,7 +1214,7 @@ static void print(spirv::CompositeConstructOp compositeConstructOp, static LogicalResult verify(spirv::CompositeConstructOp compositeConstructOp) { auto cType = compositeConstructOp.getType().cast(); - SmallVector constituents(compositeConstructOp.constituents()); + SmallVector constituents(compositeConstructOp.constituents()); if (constituents.size() != cType.getNumElements()) { return compositeConstructOp.emitError( "has incorrect number of operands: expected ") @@ -1239,7 +1239,7 @@ static LogicalResult verify(spirv::CompositeConstructOp compositeConstructOp) { //===----------------------------------------------------------------------===// void spirv::CompositeExtractOp::build(Builder *builder, OperationState &state, - Value *composite, + ValuePtr composite, ArrayRef indices) { auto indexAttr = builder->getI32ArrayAttr(indices); auto elementType = @@ -1963,7 +1963,7 @@ OpFoldResult spirv::ISubOp::fold(ArrayRef operands) { //===----------------------------------------------------------------------===// void spirv::LoadOp::build(Builder *builder, OperationState &state, - Value *basePtr, IntegerAttr memory_access, + ValuePtr basePtr, IntegerAttr memory_access, IntegerAttr alignment) { auto ptrType = basePtr->getType().cast(); build(builder, state, ptrType.getPointeeType(), basePtr, memory_access, @@ -2497,7 +2497,8 @@ static LogicalResult verify(spirv::ReturnValueOp retValOp) { //===----------------------------------------------------------------------===// void spirv::SelectOp::build(Builder *builder, OperationState &state, - Value *cond, Value *trueValue, Value *falseValue) { + ValuePtr cond, ValuePtr trueValue, + ValuePtr falseValue) { build(builder, state, trueValue->getType(), cond, trueValue, falseValue); } @@ -2698,9 +2699,9 @@ struct ConvertSelectionOpToSelect return matchFailure(); } - auto *trueValue = getSrcValue(trueBlock); - auto *falseValue = getSrcValue(falseBlock); - auto *ptrValue = getDstPtr(trueBlock); + auto trueValue = getSrcValue(trueBlock); + auto falseValue = getSrcValue(falseBlock); + auto ptrValue = getDstPtr(trueBlock); auto storeOpAttributes = cast(trueBlock->front()).getOperation()->getAttrs(); @@ -2747,13 +2748,13 @@ private: } // Returns a soruce value for the given block. - Value *getSrcValue(Block *block) const { + ValuePtr getSrcValue(Block *block) const { auto storeOp = cast(block->front()); return storeOp.value(); } // Returns a destination value for the given block. - Value *getDstPtr(Block *block) const { + ValuePtr getDstPtr(Block *block) const { auto storeOp = cast(block->front()); return storeOp.ptr(); } diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp index df9cb47a562..799828cb629 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp @@ -327,7 +327,7 @@ private: /// This method materializes normal constants and inserts "casting" ops /// (`spv._address_of` and `spv._reference_of`) to turn an symbol into a SSA /// value for handling uses of module scope constants/variables in functions. - Value *getValue(uint32_t id); + ValuePtr getValue(uint32_t id); /// Slices the first instruction out of `binary` and returns its opcode and /// operands via `opcode` and `operands` respectively. Returns failure if @@ -446,7 +446,7 @@ private: DenseMap blockPhiInfo; // Result to value mapping. - DenseMap valueMap; + DenseMap valueMap; // Mapping from result to undef value of a type. DenseMap undefMap; @@ -1520,7 +1520,7 @@ Deserializer::processBranchConditional(ArrayRef operands) { "false label, and optionally two branch weights"); } - auto *condition = getValue(operands[0]); + auto condition = getValue(operands[0]); auto *trueBlock = getOrCreateBlock(operands[1]); auto *falseBlock = getOrCreateBlock(operands[2]); @@ -1531,8 +1531,8 @@ Deserializer::processBranchConditional(ArrayRef operands) { opBuilder.create( unknownLoc, condition, trueBlock, - /*trueArguments=*/ArrayRef(), falseBlock, - /*falseArguments=*/ArrayRef(), weights); + /*trueArguments=*/ArrayRef(), falseBlock, + /*falseArguments=*/ArrayRef(), weights); return success(); } @@ -1626,7 +1626,7 @@ LogicalResult Deserializer::processPhi(ArrayRef operands) { // Create a block argument for this OpPhi instruction. Type blockArgType = getType(operands[0]); - BlockArgument *blockArg = curBlock->addArgument(blockArgType); + BlockArgumentPtr blockArg = curBlock->addArgument(blockArgType); valueMap[operands[1]] = blockArg; LLVM_DEBUG(llvm::dbgs() << "[phi] created block argument " << blockArg << " id = " << operands[1] << " of type " @@ -1783,8 +1783,8 @@ LogicalResult ControlFlowStructurizer::structurizeImpl() { LLVM_DEBUG(llvm::dbgs() << "[cf] cloned block " << newBlock << " from block " << block << "\n"); if (!isFnEntryBlock(block)) { - for (BlockArgument *blockArg : block->getArguments()) { - auto *newArg = newBlock->addArgument(blockArg->getType()); + for (BlockArgumentPtr blockArg : block->getArguments()) { + auto newArg = newBlock->addArgument(blockArg->getType()); mapper.map(blockArg, newArg); LLVM_DEBUG(llvm::dbgs() << "[cf] remapped block argument " << blockArg << " to " << newArg << '\n'); @@ -1801,10 +1801,10 @@ LogicalResult ControlFlowStructurizer::structurizeImpl() { // Go through all ops and remap the operands. auto remapOperands = [&](Operation *op) { for (auto &operand : op->getOpOperands()) - if (auto *mappedOp = mapper.lookupOrNull(operand.get())) + if (auto mappedOp = mapper.lookupOrNull(operand.get())) operand.set(mappedOp); for (auto &succOp : op->getBlockOperands()) - if (auto *mappedOp = mapper.lookupOrNull(succOp.get())) + if (auto mappedOp = mapper.lookupOrNull(succOp.get())) succOp.set(mappedOp); }; for (auto &block : body) { @@ -1824,13 +1824,13 @@ LogicalResult ControlFlowStructurizer::structurizeImpl() { // we place the selection/loop op inside the old merge block, we need to // make sure the old merge block has the same block argument list. assert(mergeBlock->args_empty() && "OpPhi in loop merge block unsupported"); - for (BlockArgument *blockArg : headerBlock->getArguments()) { + for (BlockArgumentPtr blockArg : headerBlock->getArguments()) { mergeBlock->addArgument(blockArg->getType()); } // If the loop header block has block arguments, make sure the spv.branch op // matches. - SmallVector blockArgs; + SmallVector blockArgs; if (!headerBlock->args_empty()) blockArgs = {mergeBlock->args_begin(), mergeBlock->args_end()}; @@ -1838,7 +1838,7 @@ LogicalResult ControlFlowStructurizer::structurizeImpl() { // loop header block. builder.setInsertionPointToEnd(&body.front()); builder.create(location, mapper.lookupOrNull(headerBlock), - ArrayRef(blockArgs)); + ArrayRef(blockArgs)); } // All the blocks cloned into the SelectionOp/LoopOp's region can now be @@ -1924,10 +1924,10 @@ LogicalResult Deserializer::wireUpBlockArgument() { auto *op = block->getTerminator(); opBuilder.setInsertionPoint(op); - SmallVector blockArgs; + SmallVector blockArgs; blockArgs.reserve(phiInfo.size()); for (uint32_t valueId : phiInfo) { - if (Value *value = getValue(valueId)) { + if (ValuePtr value = getValue(valueId)) { blockArgs.push_back(value); LLVM_DEBUG(llvm::dbgs() << "[phi] block argument " << value << " id = " << valueId << '\n'); @@ -1996,7 +1996,7 @@ LogicalResult Deserializer::structurizeControlFlow() { // Instruction //===----------------------------------------------------------------------===// -Value *Deserializer::getValue(uint32_t id) { +ValuePtr Deserializer::getValue(uint32_t id) { if (auto constInfo = getConstant(id)) { // Materialize a `spv.constant` op at every use site. return opBuilder.create(unknownLoc, constInfo->second, @@ -2192,7 +2192,7 @@ LogicalResult Deserializer::processBitcast(ArrayRef words) { } } valueID = words[wordIndex++]; - SmallVector operands; + SmallVector operands; SmallVector attributes; if (wordIndex < words.size()) { auto arg = getValue(words[wordIndex]); @@ -2366,9 +2366,9 @@ Deserializer::processOp(ArrayRef operands) { auto functionName = getFunctionSymbol(functionID); - SmallVector arguments; + SmallVector arguments; for (auto operand : llvm::drop_begin(operands, 3)) { - auto *value = getValue(operand); + auto value = getValue(operand); if (!value) { return emitError(unknownLoc, "unknown ") << operand << " used by OpFunctionCall"; diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp index 4baac53b89f..9b47045ea61 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp @@ -323,7 +323,7 @@ private: uint32_t opcode, ArrayRef operands); - uint32_t getValueID(Value *val) const { return valueIDMap.lookup(val); } + uint32_t getValueID(ValuePtr val) const { return valueIDMap.lookup(val); } LogicalResult processAddressOfOp(spirv::AddressOfOp addressOfOp); @@ -414,7 +414,7 @@ private: DenseMap undefValIDMap; /// Map from results of normal operations to their s. - DenseMap valueIDMap; + DenseMap valueIDMap; /// Map from extended instruction set name to s. llvm::StringMap extendedInstSetIDMap; @@ -457,7 +457,7 @@ private: /// placed inside `functions`) here. And then after emitting all blocks, we /// replace the dummy 0 with the real result by overwriting /// `functions[offset]`. - DenseMap> deferredPhiValues; + DenseMap> deferredPhiValues; }; } // namespace @@ -513,12 +513,12 @@ void Serializer::collect(SmallVectorImpl &binary) { void Serializer::printValueIDMap(raw_ostream &os) { os << "\n= Value Map =\n\n"; for (auto valueIDPair : valueIDMap) { - Value *val = valueIDPair.first; + ValuePtr val = valueIDPair.first; os << " " << val << " " << "id = " << valueIDPair.second << ' '; if (auto *op = val->getDefiningOp()) { os << "from op '" << op->getName() << "'"; - } else if (auto *arg = dyn_cast(val)) { + } else if (auto arg = dyn_cast(val)) { Block *block = arg->getOwner(); os << "from argument of block " << block << ' '; os << " in op '" << block->getParentOp()->getName() << "'"; @@ -752,7 +752,7 @@ LogicalResult Serializer::processFuncOp(FuncOp op) { // There might be OpPhi instructions who have value references needing to fix. for (auto deferredValue : deferredPhiValues) { - Value *value = deferredValue.first; + ValuePtr value = deferredValue.first; uint32_t id = getValueID(value); LLVM_DEBUG(llvm::dbgs() << "[phi] fix reference of value " << value << " to id = " << id << '\n'); @@ -1402,7 +1402,7 @@ LogicalResult Serializer::emitPhiForBlockArguments(Block *block) { // Then create OpPhi instruction for each of the block argument. for (auto argIndex : llvm::seq(0, block->getNumArguments())) { - BlockArgument *arg = block->getArgument(argIndex); + BlockArgumentPtr arg = block->getArgument(argIndex); // Get the type and result for this OpPhi instruction. uint32_t phiTypeID = 0; @@ -1418,7 +1418,7 @@ LogicalResult Serializer::emitPhiForBlockArguments(Block *block) { phiArgs.push_back(phiID); for (auto predIndex : llvm::seq(0, predecessors.size())) { - Value *value = *(predecessors[predIndex].second + argIndex); + ValuePtr value = *(predecessors[predIndex].second + argIndex); uint32_t predBlockId = getOrCreateBlockID(predecessors[predIndex].first); LLVM_DEBUG(llvm::dbgs() << "[phi] use predecessor (id = " << predBlockId << ") value " << value << ' '); @@ -1784,7 +1784,7 @@ Serializer::processOp(spirv::FunctionCallOp op) { auto funcCallID = getNextID(); SmallVector operands{resTypeID, funcCallID, funcID}; - for (auto *value : op.arguments()) { + for (auto value : op.arguments()) { auto valueID = getValueID(value); assert(valueID && "cannot find a value for spv.FunctionCall"); operands.push_back(valueID); diff --git a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp index d48b31fe491..93ce2c0a0d5 100644 --- a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp @@ -140,7 +140,7 @@ class FuncOpLowering final : public SPIRVOpLowering { public: using SPIRVOpLowering::SPIRVOpLowering; PatternMatchResult - matchAndRewrite(FuncOp funcOp, ArrayRef operands, + matchAndRewrite(FuncOp funcOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; @@ -153,7 +153,7 @@ private: } // namespace PatternMatchResult -FuncOpLowering::matchAndRewrite(FuncOp funcOp, ArrayRef operands, +FuncOpLowering::matchAndRewrite(FuncOp funcOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const { if (!funcOp.getAttrOfType( spirv::getEntryPointABIAttrName())) { @@ -183,7 +183,7 @@ FuncOpLowering::matchAndRewrite(FuncOp funcOp, ArrayRef operands, OpBuilder::InsertionGuard funcInsertionGuard(rewriter); rewriter.setInsertionPointToStart(&funcOp.front()); // Insert spirv::AddressOf and spirv::AccessChain operations. - Value *replacement = + ValuePtr replacement = rewriter.create(funcOp.getLoc(), var); // Check if the arg is a scalar or vector type. In that case, the value // needs to be loaded into registers. diff --git a/mlir/lib/Dialect/StandardOps/Ops.cpp b/mlir/lib/Dialect/StandardOps/Ops.cpp index 4116f6f14ae..94166b5a7dd 100644 --- a/mlir/lib/Dialect/StandardOps/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/Ops.cpp @@ -81,7 +81,7 @@ struct StdInlinerInterface : public DialectInlinerInterface { /// Handle the given inlined terminator by replacing it with a new operation /// as necessary. void handleTerminator(Operation *op, - ArrayRef valuesToRepl) const final { + ArrayRef valuesToRepl) const final { // Only "std.return" needs to be handled here. auto returnOp = cast(op); @@ -184,7 +184,7 @@ void mlir::printDimAndSymbolList(Operation::operand_iterator begin, // dimension operands parsed. // Returns 'false' on success and 'true' on error. ParseResult mlir::parseDimAndSymbolList(OpAsmParser &parser, - SmallVectorImpl &operands, + SmallVectorImpl &operands, unsigned &numDims) { SmallVector opInfos; if (parser.parseOperandList(opInfos, OpAsmParser::Delimiter::Paren)) @@ -325,7 +325,7 @@ struct SimplifyAllocConst : public OpRewritePattern { PatternRewriter &rewriter) const override { // Check to see if any dimensions operands are constants. If so, we can // substitute and drop them. - if (llvm::none_of(alloc.getOperands(), [](Value *operand) { + if (llvm::none_of(alloc.getOperands(), [](ValuePtr operand) { return matchPattern(operand, m_ConstantIndex()); })) return matchFailure(); @@ -336,8 +336,8 @@ struct SimplifyAllocConst : public OpRewritePattern { // and keep track of the resultant memref type to build. SmallVector newShapeConstants; newShapeConstants.reserve(memrefType.getRank()); - SmallVector newOperands; - SmallVector droppedOperands; + SmallVector newOperands; + SmallVector droppedOperands; unsigned dynamicDimPos = 0; for (unsigned dim = 0, e = memrefType.getRank(); dim < e; ++dim) { @@ -429,7 +429,7 @@ struct SimplifyBrToBlockWithSinglePred : public OpRewritePattern { static ParseResult parseBranchOp(OpAsmParser &parser, OperationState &result) { Block *dest; - SmallVector destOperands; + SmallVector destOperands; if (parser.parseSuccessorAndUseList(dest, destOperands)) return failure(); result.addSuccessor(dest, destOperands); @@ -623,7 +623,7 @@ static Type getI1SameShape(Builder *build, Type type) { //===----------------------------------------------------------------------===// static void buildCmpIOp(Builder *build, OperationState &result, - CmpIPredicate predicate, Value *lhs, Value *rhs) { + CmpIPredicate predicate, ValuePtr lhs, ValuePtr rhs) { result.addOperands({lhs, rhs}); result.types.push_back(getI1SameShape(build, lhs->getType())); result.addAttribute( @@ -777,7 +777,7 @@ CmpFPredicate CmpFOp::getPredicateByName(StringRef name) { } static void buildCmpFOp(Builder *build, OperationState &result, - CmpFPredicate predicate, Value *lhs, Value *rhs) { + CmpFPredicate predicate, ValuePtr lhs, ValuePtr rhs) { result.addOperands({lhs, rhs}); result.types.push_back(getI1SameShape(build, lhs->getType())); result.addAttribute( @@ -946,7 +946,7 @@ struct SimplifyConstCondBranchPred : public OpRewritePattern { static ParseResult parseCondBranchOp(OpAsmParser &parser, OperationState &result) { - SmallVector destOperands; + SmallVector destOperands; Block *dest; OpAsmParser::OperandType condInfo; @@ -1088,7 +1088,7 @@ OpFoldResult ConstantOp::fold(ArrayRef operands) { } void ConstantOp::getAsmResultNames( - function_ref setNameFn) { + function_ref setNameFn) { Type type = getType(); if (auto intCst = getValue().dyn_cast()) { IntegerType intTy = type.dyn_cast(); @@ -1183,7 +1183,7 @@ struct SimplifyDeadDealloc : public OpRewritePattern { PatternMatchResult matchAndRewrite(DeallocOp dealloc, PatternRewriter &rewriter) const override { // Check that the memref operand's defining operation is an AllocOp. - Value *memref = dealloc.memref(); + ValuePtr memref = dealloc.memref(); if (!isa_and_nonnull(memref->getDefiningOp())) return matchFailure(); @@ -1362,11 +1362,11 @@ OpFoldResult UnsignedDivIOp::fold(ArrayRef operands) { // --------------------------------------------------------------------------- void DmaStartOp::build(Builder *builder, OperationState &result, - Value *srcMemRef, ValueRange srcIndices, - Value *destMemRef, ValueRange destIndices, - Value *numElements, Value *tagMemRef, - ValueRange tagIndices, Value *stride, - Value *elementsPerStride) { + ValuePtr srcMemRef, ValueRange srcIndices, + ValuePtr destMemRef, ValueRange destIndices, + ValuePtr numElements, ValuePtr tagMemRef, + ValueRange tagIndices, ValuePtr stride, + ValuePtr elementsPerStride) { result.addOperands(srcMemRef); result.addOperands(srcIndices); result.addOperands(destMemRef); @@ -1507,8 +1507,8 @@ LogicalResult DmaStartOp::fold(ArrayRef cstOperands, // --------------------------------------------------------------------------- void DmaWaitOp::build(Builder *builder, OperationState &result, - Value *tagMemRef, ValueRange tagIndices, - Value *numElements) { + ValuePtr tagMemRef, ValueRange tagIndices, + ValuePtr numElements) { result.addOperands(tagMemRef); result.addOperands(tagIndices); result.addOperands(numElements); @@ -2025,7 +2025,7 @@ static LogicalResult verify(SelectOp op) { } OpFoldResult SelectOp::fold(ArrayRef operands) { - auto *condition = getCondition(); + auto condition = getCondition(); // select true, %0, %1 => %0 if (matchPattern(condition, m_One())) @@ -2357,7 +2357,7 @@ static ParseResult parseViewOp(OpAsmParser &parser, OperationState &result) { static void print(OpAsmPrinter &p, ViewOp op) { p << op.getOperationName() << ' ' << *op.getOperand(0) << '['; - auto *dynamicOffset = op.getDynamicOffset(); + auto dynamicOffset = op.getDynamicOffset(); if (dynamicOffset != nullptr) p.printOperand(dynamicOffset); p << "][" << op.getDynamicSizes() << ']'; @@ -2365,7 +2365,7 @@ static void print(OpAsmPrinter &p, ViewOp op) { p << " : " << op.getOperand(0)->getType() << " to " << op.getType(); } -Value *ViewOp::getDynamicOffset() { +ValuePtr ViewOp::getDynamicOffset() { int64_t offset; SmallVector strides; auto result = @@ -2440,7 +2440,7 @@ struct ViewOpShapeFolder : public OpRewritePattern { PatternMatchResult matchAndRewrite(ViewOp viewOp, PatternRewriter &rewriter) const override { // Return if none of the operands are constants. - if (llvm::none_of(viewOp.getOperands(), [](Value *operand) { + if (llvm::none_of(viewOp.getOperands(), [](ValuePtr operand) { return matchPattern(operand, m_ConstantIndex()); })) return matchFailure(); @@ -2457,11 +2457,11 @@ struct ViewOpShapeFolder : public OpRewritePattern { if (failed(getStridesAndOffset(memrefType, oldStrides, oldOffset))) return matchFailure(); - SmallVector newOperands; - SmallVector droppedOperands; + SmallVector newOperands; + SmallVector droppedOperands; // Fold dynamic offset operand if it is produced by a constant. - auto *dynamicOffset = viewOp.getDynamicOffset(); + auto dynamicOffset = viewOp.getDynamicOffset(); int64_t newOffset = oldOffset; unsigned dynamicOffsetOperandCount = 0; if (dynamicOffset != nullptr) { @@ -2576,7 +2576,7 @@ static Type inferSubViewResultType(MemRefType memRefType) { memRefType.getMemorySpace()); } -void mlir::SubViewOp::build(Builder *b, OperationState &result, Value *source, +void mlir::SubViewOp::build(Builder *b, OperationState &result, ValuePtr source, ValueRange offsets, ValueRange sizes, ValueRange strides, Type resultType, ArrayRef attrs) { @@ -2590,7 +2590,7 @@ void mlir::SubViewOp::build(Builder *b, OperationState &result, Value *source, } void mlir::SubViewOp::build(Builder *b, OperationState &result, Type resultType, - Value *source) { + ValuePtr source) { build(b, result, source, /*offsets=*/{}, /*sizes=*/{}, /*strides=*/{}, resultType); } @@ -2826,7 +2826,7 @@ public: // Follow all or nothing approach for shapes for now. If all the operands // for sizes are constants then fold it into the type of the result memref. if (subViewType.hasStaticShape() || - llvm::any_of(subViewOp.sizes(), [](Value *operand) { + llvm::any_of(subViewOp.sizes(), [](ValuePtr operand) { return !matchPattern(operand, m_ConstantIndex()); })) { return matchFailure(); @@ -2842,7 +2842,7 @@ public: subViewType.getMemorySpace()); auto newSubViewOp = rewriter.create( subViewOp.getLoc(), subViewOp.source(), subViewOp.offsets(), - ArrayRef(), subViewOp.strides(), newMemRefType); + ArrayRef(), subViewOp.strides(), newMemRefType); // Insert a memref_cast for compatibility of the uses of the op. rewriter.replaceOpWithNewOp( subViewOp.sizes(), subViewOp, newSubViewOp, subViewOp.getType()); @@ -2871,7 +2871,7 @@ public: failed(getStridesAndOffset(subViewType, resultStrides, resultOffset)) || llvm::is_contained(baseStrides, MemRefType::getDynamicStrideOrOffset()) || - llvm::any_of(subViewOp.strides(), [](Value *stride) { + llvm::any_of(subViewOp.strides(), [](ValuePtr stride) { return !matchPattern(stride, m_ConstantIndex()); })) { return matchFailure(); @@ -2892,7 +2892,7 @@ public: layoutMap, subViewType.getMemorySpace()); auto newSubViewOp = rewriter.create( subViewOp.getLoc(), subViewOp.source(), subViewOp.offsets(), - subViewOp.sizes(), ArrayRef(), newMemRefType); + subViewOp.sizes(), ArrayRef(), newMemRefType); // Insert a memref_cast for compatibility of the uses of the op. rewriter.replaceOpWithNewOp( subViewOp.strides(), subViewOp, newSubViewOp, subViewOp.getType()); @@ -2922,7 +2922,7 @@ public: llvm::is_contained(baseStrides, MemRefType::getDynamicStrideOrOffset()) || baseOffset == MemRefType::getDynamicStrideOrOffset() || - llvm::any_of(subViewOp.offsets(), [](Value *stride) { + llvm::any_of(subViewOp.offsets(), [](ValuePtr stride) { return !matchPattern(stride, m_ConstantIndex()); })) { return matchFailure(); @@ -2943,7 +2943,7 @@ public: MemRefType::get(subViewType.getShape(), subViewType.getElementType(), layoutMap, subViewType.getMemorySpace()); auto newSubViewOp = rewriter.create( - subViewOp.getLoc(), subViewOp.source(), ArrayRef(), + subViewOp.getLoc(), subViewOp.source(), ArrayRef(), subViewOp.sizes(), subViewOp.strides(), newMemRefType); // Insert a memref_cast for compatibility of the uses of the op. rewriter.replaceOpWithNewOp( diff --git a/mlir/lib/Dialect/VectorOps/VectorOps.cpp b/mlir/lib/Dialect/VectorOps/VectorOps.cpp index 6a3ff74afcd..18c1714f403 100644 --- a/mlir/lib/Dialect/VectorOps/VectorOps.cpp +++ b/mlir/lib/Dialect/VectorOps/VectorOps.cpp @@ -72,7 +72,7 @@ ArrayAttr vector::getVectorSubscriptAttr(Builder &builder, //===----------------------------------------------------------------------===// void vector::ContractionOp::build(Builder *builder, OperationState &result, - Value *lhs, Value *rhs, Value *acc, + ValuePtr lhs, ValuePtr rhs, ValuePtr acc, ArrayAttr indexingMaps, ArrayAttr iteratorTypes) { result.addOperands({lhs, rhs, acc}); @@ -404,7 +404,7 @@ static Type inferExtractOpResultType(VectorType vectorType, } void vector::ExtractOp::build(Builder *builder, OperationState &result, - Value *source, ArrayRef position) { + ValuePtr source, ArrayRef position) { result.addOperands(source); auto positionAttr = getVectorSubscriptAttr(*builder, position); result.addTypes(inferExtractOpResultType(source->getType().cast(), @@ -471,7 +471,7 @@ static LogicalResult verify(vector::ExtractOp op) { //===----------------------------------------------------------------------===// void ExtractSlicesOp::build(Builder *builder, OperationState &result, - TupleType tupleType, Value *vector, + TupleType tupleType, ValuePtr vector, ArrayRef sizes, ArrayRef strides) { result.addOperands(vector); @@ -647,8 +647,8 @@ static ParseResult parseBroadcastOp(OpAsmParser &parser, // ShuffleOp //===----------------------------------------------------------------------===// -void ShuffleOp::build(Builder *builder, OperationState &result, Value *v1, - Value *v2, ArrayRef mask) { +void ShuffleOp::build(Builder *builder, OperationState &result, ValuePtr v1, + ValuePtr v2, ArrayRef mask) { result.addOperands({v1, v2}); auto maskAttr = getVectorSubscriptAttr(*builder, mask); result.addTypes(v1->getType()); @@ -771,8 +771,8 @@ static LogicalResult verify(InsertElementOp op) { // InsertOp //===----------------------------------------------------------------------===// -void InsertOp::build(Builder *builder, OperationState &result, Value *source, - Value *dest, ArrayRef position) { +void InsertOp::build(Builder *builder, OperationState &result, ValuePtr source, + ValuePtr dest, ArrayRef position) { result.addOperands({source, dest}); auto positionAttr = getVectorSubscriptAttr(*builder, position); result.addTypes(dest->getType()); @@ -893,7 +893,7 @@ void InsertSlicesOp::getStrides(SmallVectorImpl &results) { //===----------------------------------------------------------------------===// void InsertStridedSliceOp::build(Builder *builder, OperationState &result, - Value *source, Value *dest, + ValuePtr source, ValuePtr dest, ArrayRef offsets, ArrayRef strides) { result.addOperands({source, dest}); @@ -1201,17 +1201,17 @@ static LogicalResult verify(ReshapeOp op) { // If all shape operands are produced by constant ops, verify that product // of dimensions for input/output shape match. - auto isDefByConstant = [](Value *operand) { + auto isDefByConstant = [](ValuePtr operand) { return isa_and_nonnull(operand->getDefiningOp()); }; if (llvm::all_of(op.input_shape(), isDefByConstant) && llvm::all_of(op.output_shape(), isDefByConstant)) { int64_t numInputElements = 1; - for (auto *operand : op.input_shape()) + for (auto operand : op.input_shape()) numInputElements *= cast(operand->getDefiningOp()).getValue(); int64_t numOutputElements = 1; - for (auto *operand : op.output_shape()) + for (auto operand : op.output_shape()) numOutputElements *= cast(operand->getDefiningOp()).getValue(); if (numInputElements != numOutputElements) @@ -1247,7 +1247,7 @@ static Type inferStridedSliceOpResultType(VectorType vectorType, } void StridedSliceOp::build(Builder *builder, OperationState &result, - Value *source, ArrayRef offsets, + ValuePtr source, ArrayRef offsets, ArrayRef sizes, ArrayRef strides) { result.addOperands(source); auto offsetsAttr = getVectorSubscriptAttr(*builder, offsets); @@ -1603,7 +1603,7 @@ static MemRefType inferVectorTypeCastResultType(MemRefType t) { } void TypeCastOp::build(Builder *builder, OperationState &result, - Value *source) { + ValuePtr source) { result.addOperands(source); result.addTypes( inferVectorTypeCastResultType(source->getType().cast())); @@ -1793,14 +1793,14 @@ public: PatternMatchResult matchAndRewrite(CreateMaskOp createMaskOp, PatternRewriter &rewriter) const override { // Return if any of 'createMaskOp' operands are not defined by a constant. - auto is_not_def_by_constant = [](Value *operand) { + auto is_not_def_by_constant = [](ValuePtr operand) { return !isa_and_nonnull(operand->getDefiningOp()); }; if (llvm::any_of(createMaskOp.operands(), is_not_def_by_constant)) return matchFailure(); // Gather constant mask dimension sizes. SmallVector maskDimSizes; - for (auto *operand : createMaskOp.operands()) { + for (auto operand : createMaskOp.operands()) { auto defOp = operand->getDefiningOp(); maskDimSizes.push_back(cast(defOp).getValue()); } diff --git a/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp b/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp index 64cacb28720..e5c281cbf64 100644 --- a/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp +++ b/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp @@ -106,17 +106,17 @@ static SmallVector delinearize(int64_t linearIndex, // `resultTypes`. static Operation *cloneOpWithOperandsAndTypes(PatternRewriter &builder, Location loc, Operation *op, - ArrayRef operands, + ArrayRef operands, ArrayRef resultTypes) { OperationState res(loc, op->getName().getStringRef(), operands, resultTypes, op->getAttrs()); return builder.createOperation(res); } -static Value *makeSplatZero(Location loc, PatternRewriter &rewriter, - VectorType vt) { +static ValuePtr makeSplatZero(Location loc, PatternRewriter &rewriter, + VectorType vt) { auto t = vt.getElementType(); - Value *f = nullptr; + ValuePtr f = nullptr; if (t.isBF16() || t.isF16()) f = rewriter.create(loc, t, rewriter.getF64FloatAttr(0.0f)); else if (t.isF32()) @@ -190,12 +190,12 @@ struct UnrolledVectorState { SmallVector unrollFactors; SmallVector basis; int64_t numInstances; - Value *slicesTuple; + ValuePtr slicesTuple; }; // Populates 'state' with unrolled shape, unroll factors, basis and // num unrolled instances for 'vectorType'. -static void initUnrolledVectorState(VectorType vectorType, Value *initValue, +static void initUnrolledVectorState(VectorType vectorType, ValuePtr initValue, const DenseMap &indexMap, ArrayRef targetShape, UnrolledVectorState &state, @@ -239,10 +239,10 @@ getUnrolledVectorLinearIndex(UnrolledVectorState &state, // Returns an unrolled vector at 'vectorOffsets' within the vector // represented by 'state'. The vector is created from a slice of 'initValue' // if not present in 'cache'. -static Value *getOrCreateUnrolledVectorSlice( +static ValuePtr getOrCreateUnrolledVectorSlice( Location loc, UnrolledVectorState &state, ArrayRef vectorOffsets, ArrayRef offsets, DenseMap &indexMap, - Value *initValue, SmallVectorImpl &cache, + ValuePtr initValue, SmallVectorImpl &cache, PatternRewriter &builder) { // Compute slice offsets. SmallVector sliceOffsets(state.unrolledShape.size()); @@ -253,7 +253,7 @@ static Value *getOrCreateUnrolledVectorSlice( int64_t sliceLinearIndex = getUnrolledVectorLinearIndex(state, vectorOffsets, indexMap); assert(sliceLinearIndex < static_cast(cache.size())); - auto *valueSlice = cache[sliceLinearIndex]; + auto valueSlice = cache[sliceLinearIndex]; if (valueSlice == nullptr) { // Return tuple element at 'sliceLinearIndex'. auto tupleIndex = builder.getI64IntegerAttr(sliceLinearIndex); @@ -330,12 +330,10 @@ struct VectorState { // TODO(andydavis) Generalize this to support structured ops beyond // vector ContractionOp, and merge it with 'unrollSingleResultOpMatchingType' -static Value *unrollSingleResultStructuredOp(Operation *op, - ArrayRef iterationBounds, - std::vector &vectors, - unsigned resultIndex, - ArrayRef targetShape, - PatternRewriter &builder) { +static ValuePtr unrollSingleResultStructuredOp( + Operation *op, ArrayRef iterationBounds, + std::vector &vectors, unsigned resultIndex, + ArrayRef targetShape, PatternRewriter &builder) { auto shapedType = op->getResult(0)->getType().dyn_cast_or_null(); if (!shapedType || !shapedType.hasStaticShape()) assert(false && "Expected a statically shaped result type"); @@ -351,7 +349,7 @@ static Value *unrollSingleResultStructuredOp(Operation *op, SmallVector unrolledVectorState(numVectors); for (unsigned i = 0; i < numVectors; ++i) { int64_t operandIndex = vectors[i].operandIndex; - auto *operand = operandIndex >= 0 ? op->getOperand(operandIndex) : nullptr; + auto operand = operandIndex >= 0 ? op->getOperand(operandIndex) : nullptr; initUnrolledVectorState(vectors[i].type, operand, vectors[i].indexMap, targetShape, unrolledVectorState[i], builder); } @@ -364,7 +362,7 @@ static Value *unrollSingleResultStructuredOp(Operation *op, shapedType.getElementType()); // Initialize caches for intermediate vector results. - std::vector> caches(numVectors); + std::vector> caches(numVectors); for (unsigned i = 0; i < numVectors; ++i) caches[i].resize(unrolledVectorState[i].numInstances); @@ -376,13 +374,13 @@ static Value *unrollSingleResultStructuredOp(Operation *op, auto offsets = zipMap([](int64_t v1, int64_t v2) { return v1 * v2; }, vectorOffsets, targetShape); // Get cached slice (or create slice) for each operand at 'offsets'. - SmallVector operands; + SmallVector operands; operands.resize(op->getNumOperands()); for (unsigned i = 0; i < numVectors; ++i) { int64_t operandIndex = vectors[i].operandIndex; if (operandIndex < 0) continue; // Output - auto *operand = op->getOperand(operandIndex); + auto operand = op->getOperand(operandIndex); operands[operandIndex] = getOrCreateUnrolledVectorSlice( op->getLoc(), unrolledVectorState[i], vectorOffsets, offsets, vectors[i].indexMap, operand, caches[i], builder); @@ -402,21 +400,21 @@ static Value *unrollSingleResultStructuredOp(Operation *op, // Create TupleOp of unrolled result vectors. SmallVector vectorTupleTypes(resultValueState.numInstances); - SmallVector vectorTupleValues(resultValueState.numInstances); + SmallVector vectorTupleValues(resultValueState.numInstances); for (unsigned i = 0; i < resultValueState.numInstances; ++i) { vectorTupleTypes[i] = caches[resultIndex][i]->getType().cast(); vectorTupleValues[i] = caches[resultIndex][i]; } TupleType tupleType = builder.getTupleType(vectorTupleTypes); - Value *tupleOp = builder.create(op->getLoc(), tupleType, - vectorTupleValues); + ValuePtr tupleOp = builder.create(op->getLoc(), tupleType, + vectorTupleValues); // Create InsertSlicesOp(Tuple(result_vectors)). auto resultVectorType = op->getResult(0)->getType().cast(); SmallVector sizes(resultValueState.unrolledShape); SmallVector strides(resultValueState.unrollFactors.size(), 1); - Value *insertSlicesOp = builder.create( + ValuePtr insertSlicesOp = builder.create( op->getLoc(), resultVectorType, tupleOp, builder.getI64ArrayAttr(sizes), builder.getI64ArrayAttr(strides)); return insertSlicesOp; @@ -487,7 +485,7 @@ getVectorElementwiseOpUnrollState(Operation *op, ArrayRef targetShape, } // Entry point for unrolling declarative pattern rewrites. -Value *mlir::vector::unrollSingleResultOpMatchingType( +ValuePtr mlir::vector::unrollSingleResultOpMatchingType( PatternRewriter &builder, Operation *op, ArrayRef targetShape) { assert(op->getNumResults() == 1 && "Expected single result operation"); @@ -516,8 +514,8 @@ Value *mlir::vector::unrollSingleResultOpMatchingType( static void generateTransferOpSlices(VectorType vectorType, TupleType tupleType, ArrayRef sizes, ArrayRef strides, - ArrayRef indices, PatternRewriter &rewriter, - function_ref)> fn) { + ArrayRef indices, PatternRewriter &rewriter, + function_ref)> fn) { // Compute strides w.r.t. to slice counts in each dimension. auto maybeDimSliceCounts = shapeRatio(vectorType.getShape(), sizes); assert(maybeDimSliceCounts.hasValue()); @@ -534,13 +532,13 @@ generateTransferOpSlices(VectorType vectorType, TupleType tupleType, auto offsets = zipMap([](int64_t v1, int64_t v2) { return v1 * v2; }, vectorOffsets, sizes); // Compute 'sliceIndices' by adding 'sliceOffsets[i]' to 'indices[i]'. - SmallVector sliceIndices(numSliceIndices); + SmallVector sliceIndices(numSliceIndices); for (auto it : llvm::enumerate(indices)) { auto expr = getAffineDimExpr(0, ctx) + getAffineConstantExpr(offsets[it.index()], ctx); auto map = AffineMap::get(/*dimCount=*/1, /*symbolCount=*/0, expr); sliceIndices[it.index()] = rewriter.create( - it.value()->getLoc(), map, ArrayRef(it.value())); + it.value()->getLoc(), map, ArrayRef(it.value())); } // Call 'fn' to generate slice 'i' at 'sliceIndices'. fn(i, sliceIndices); @@ -559,7 +557,7 @@ struct SplitTransferReadOp : public OpRewritePattern { if (!xferReadOp.permutation_map().isIdentity()) return matchFailure(); // Return unless the unique 'xferReadOp' user is an ExtractSlicesOp. - Value *xferReadResult = xferReadOp.getResult(); + ValuePtr xferReadResult = xferReadOp.getResult(); auto extractSlicesOp = dyn_cast(*xferReadResult->getUsers().begin()); if (!xferReadResult->hasOneUse() || !extractSlicesOp) @@ -576,10 +574,10 @@ struct SplitTransferReadOp : public OpRewritePattern { Location loc = xferReadOp.getLoc(); int64_t numSlices = resultTupleType.size(); - SmallVector vectorTupleValues(numSlices); - SmallVector indices(xferReadOp.indices().begin(), - xferReadOp.indices().end()); - auto createSlice = [&](unsigned index, ArrayRef sliceIndices) { + SmallVector vectorTupleValues(numSlices); + SmallVector indices(xferReadOp.indices().begin(), + xferReadOp.indices().end()); + auto createSlice = [&](unsigned index, ArrayRef sliceIndices) { // Get VectorType for slice 'i'. auto sliceVectorType = resultTupleType.getType(index); // Create split TransferReadOp for 'sliceUser'. @@ -591,8 +589,8 @@ struct SplitTransferReadOp : public OpRewritePattern { indices, rewriter, createSlice); // Create tuple of splice xfer read operations. - Value *tupleOp = rewriter.create(loc, resultTupleType, - vectorTupleValues); + ValuePtr tupleOp = rewriter.create(loc, resultTupleType, + vectorTupleValues); // Replace 'xferReadOp' with result 'insertSlicesResult'. rewriter.replaceOpWithNewOp( xferReadOp, sourceVectorType, tupleOp, extractSlicesOp.sizes(), @@ -632,9 +630,9 @@ struct SplitTransferWriteOp : public OpRewritePattern { insertSlicesOp.getStrides(strides); Location loc = xferWriteOp.getLoc(); - SmallVector indices(xferWriteOp.indices().begin(), - xferWriteOp.indices().end()); - auto createSlice = [&](unsigned index, ArrayRef sliceIndices) { + SmallVector indices(xferWriteOp.indices().begin(), + xferWriteOp.indices().end()); + auto createSlice = [&](unsigned index, ArrayRef sliceIndices) { // Create split TransferWriteOp for source vector 'tupleOp.operand[i]'. rewriter.create( loc, tupleOp.getOperand(index), xferWriteOp.memref(), sliceIndices, @@ -676,7 +674,7 @@ struct TupleGetFolderOp : public OpRewritePattern { return matchFailure(); // Forward Value from 'tupleOp' at 'tupleGetOp.index'. - Value *tupleValue = tupleOp.getOperand(tupleGetOp.getIndex()); + ValuePtr tupleValue = tupleOp.getOperand(tupleGetOp.getIndex()); rewriter.replaceOp(tupleGetOp, tupleValue); return matchSuccess(); } diff --git a/mlir/lib/EDSC/Builders.cpp b/mlir/lib/EDSC/Builders.cpp index 47e2dfed55e..35108ed5666 100644 --- a/mlir/lib/EDSC/Builders.cpp +++ b/mlir/lib/EDSC/Builders.cpp @@ -88,9 +88,8 @@ ValueHandle &mlir::edsc::ValueHandle::operator=(const ValueHandle &other) { return *this; } -ValueHandle -mlir::edsc::ValueHandle::createComposedAffineApply(AffineMap map, - ArrayRef operands) { +ValueHandle mlir::edsc::ValueHandle::createComposedAffineApply( + AffineMap map, ArrayRef operands) { Operation *op = makeComposedAffineApply(ScopedContext::getBuilder(), ScopedContext::getLocation(), map, operands) @@ -118,7 +117,7 @@ OperationHandle OperationHandle::create(StringRef name, ArrayRef resultTypes, ArrayRef attributes) { OperationState state(ScopedContext::getLocation(), name); - SmallVector ops(operands.begin(), operands.end()); + SmallVector ops(operands.begin(), operands.end()); state.addOperands(ops); state.addTypes(resultTypes); for (const auto &attr : attributes) { @@ -169,8 +168,8 @@ mlir::edsc::LoopBuilder mlir::edsc::LoopBuilder::makeAffine( if (auto staticFor = emitStaticFor(lbHandles, ubHandles, step)) { *iv = staticFor.getValue(); } else { - SmallVector lbs(lbHandles.begin(), lbHandles.end()); - SmallVector ubs(ubHandles.begin(), ubHandles.end()); + SmallVector lbs(lbHandles.begin(), lbHandles.end()); + SmallVector ubs(ubHandles.begin(), ubHandles.end()); *iv = ValueHandle::create( lbs, ScopedContext::getBuilder().getMultiDimIdentityMap(lbs.size()), ubs, ScopedContext::getBuilder().getMultiDimIdentityMap(ubs.size()), @@ -309,11 +308,11 @@ static ValueHandle createBinaryHandle(ValueHandle lhs, ValueHandle rhs) { return ValueHandle::create(lhs.getValue(), rhs.getValue()); } -static std::pair -categorizeValueByAffineType(MLIRContext *context, Value *val, unsigned &numDims, - unsigned &numSymbols) { +static std::pair +categorizeValueByAffineType(MLIRContext *context, ValuePtr val, + unsigned &numDims, unsigned &numSymbols) { AffineExpr d; - Value *resultVal = nullptr; + ValuePtr resultVal = nullptr; if (auto constant = dyn_cast_or_null(val->getDefiningOp())) { d = getAffineConstantExpr(constant.getValue(), context); } else if (isValidSymbol(val) && !isValidDim(val)) { @@ -332,12 +331,12 @@ static ValueHandle createBinaryIndexHandle( MLIRContext *context = ScopedContext::getContext(); unsigned numDims = 0, numSymbols = 0; AffineExpr d0, d1; - Value *v0, *v1; + ValuePtr v0, v1; std::tie(d0, v0) = categorizeValueByAffineType(context, lhs.getValue(), numDims, numSymbols); std::tie(d1, v1) = categorizeValueByAffineType(context, rhs.getValue(), numDims, numSymbols); - SmallVector operands; + SmallVector operands; if (v0) { operands.push_back(v0); } diff --git a/mlir/lib/EDSC/Helpers.cpp b/mlir/lib/EDSC/Helpers.cpp index eeb28668a34..1771eb0a427 100644 --- a/mlir/lib/EDSC/Helpers.cpp +++ b/mlir/lib/EDSC/Helpers.cpp @@ -22,7 +22,7 @@ using namespace mlir; using namespace mlir::edsc; -static SmallVector getMemRefSizes(Value *memRef) { +static SmallVector getMemRefSizes(ValuePtr memRef) { MemRefType memRefType = memRef->getType().cast(); assert(isStrided(memRefType) && "Expected strided MemRef type"); @@ -39,7 +39,7 @@ static SmallVector getMemRefSizes(Value *memRef) { return res; } -mlir::edsc::MemRefView::MemRefView(Value *v) : base(v) { +mlir::edsc::MemRefView::MemRefView(ValuePtr v) : base(v) { assert(v->getType().isa() && "MemRefType expected"); auto memrefSizeValues = getMemRefSizes(v); @@ -50,7 +50,7 @@ mlir::edsc::MemRefView::MemRefView(Value *v) : base(v) { } } -mlir::edsc::VectorView::VectorView(Value *v) : base(v) { +mlir::edsc::VectorView::VectorView(ValuePtr v) : base(v) { auto vectorType = v->getType().cast(); for (auto s : vectorType.getShape()) { diff --git a/mlir/lib/EDSC/Intrinsics.cpp b/mlir/lib/EDSC/Intrinsics.cpp index 1b19f9aa0bf..c6738c42993 100644 --- a/mlir/lib/EDSC/Intrinsics.cpp +++ b/mlir/lib/EDSC/Intrinsics.cpp @@ -29,7 +29,7 @@ OperationHandle mlir::edsc::intrinsics::br(BlockHandle bh, (void)o; assert(o && "Expected already captured ValueHandle"); } - SmallVector ops(operands.begin(), operands.end()); + SmallVector ops(operands.begin(), operands.end()); return OperationHandle::create(bh.getBlock(), ops); } static void enforceEmptyCapturesMatchOperands(ArrayRef captures, @@ -52,7 +52,7 @@ OperationHandle mlir::edsc::intrinsics::br(BlockHandle *bh, assert(!*bh && "Unexpected already captured BlockHandle"); enforceEmptyCapturesMatchOperands(captures, operands); BlockBuilder(bh, captures)(/* no body */); - SmallVector ops(operands.begin(), operands.end()); + SmallVector ops(operands.begin(), operands.end()); return OperationHandle::create(bh->getBlock(), ops); } @@ -61,8 +61,8 @@ mlir::edsc::intrinsics::cond_br(ValueHandle cond, BlockHandle trueBranch, ArrayRef trueOperands, BlockHandle falseBranch, ArrayRef falseOperands) { - SmallVector trueOps(trueOperands.begin(), trueOperands.end()); - SmallVector falseOps(falseOperands.begin(), falseOperands.end()); + SmallVector trueOps(trueOperands.begin(), trueOperands.end()); + SmallVector falseOps(falseOperands.begin(), falseOperands.end()); return OperationHandle::create( cond, trueBranch.getBlock(), trueOps, falseBranch.getBlock(), falseOps); } @@ -78,8 +78,8 @@ OperationHandle mlir::edsc::intrinsics::cond_br( enforceEmptyCapturesMatchOperands(falseCaptures, falseOperands); BlockBuilder(trueBranch, trueCaptures)(/* no body */); BlockBuilder(falseBranch, falseCaptures)(/* no body */); - SmallVector trueOps(trueOperands.begin(), trueOperands.end()); - SmallVector falseOps(falseOperands.begin(), falseOperands.end()); + SmallVector trueOps(trueOperands.begin(), trueOperands.end()); + SmallVector falseOps(falseOperands.begin(), falseOperands.end()); return OperationHandle::create( cond, trueBranch->getBlock(), trueOps, falseBranch->getBlock(), falseOps); } diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index f3c92ada0a0..177d8a5ef05 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -319,7 +319,7 @@ void ModuleState::visitOperation(Operation *op) { visitType(type); for (auto ®ion : op->getRegions()) for (auto &block : region) - for (auto *arg : block.getArguments()) + for (auto arg : block.getArguments()) visitType(arg->getType()); // Visit each of the attributes. @@ -1437,7 +1437,7 @@ public: void printAttribute(Attribute attr) override { ModulePrinter::printAttribute(attr); } - void printOperand(Value *value) override { printValueID(value); } + void printOperand(ValuePtr value) override { printValueID(value); } void printOptionalAttrDict(ArrayRef attrs, ArrayRef elidedAttrs = {}) override { @@ -1519,7 +1519,7 @@ protected: void numberValuesInRegion(Region ®ion); void numberValuesInBlock(Block &block); void numberValuesInOp(Operation &op); - void printValueID(Value *value, bool printResultNo = true) const { + void printValueID(ValuePtr value, bool printResultNo = true) const { printValueIDImpl(value, printResultNo, os); } @@ -1528,13 +1528,13 @@ private: /// 'lookupValue' and the result of 'result' within that group in /// 'lookupResultNo'. 'lookupResultNo' is only filled in if the result group /// has more than 1 result. - void getResultIDAndNumber(OpResult *result, Value *&lookupValue, + void getResultIDAndNumber(OpResultPtr result, ValuePtr &lookupValue, int &lookupResultNo) const; - void printValueIDImpl(Value *value, bool printResultNo, + void printValueIDImpl(ValuePtr value, bool printResultNo, raw_ostream &stream) const; /// Set a special value name for the given value. - void setValueName(Value *value, StringRef name); + void setValueName(ValuePtr value, StringRef name); /// Uniques the given value name within the printer. If the given name /// conflicts, it is automatically renamed. @@ -1542,8 +1542,8 @@ private: /// This is the value ID for each SSA value. If this returns ~0, then the /// valueID has an entry in valueNames. - DenseMap valueIDs; - DenseMap valueNames; + DenseMap valueIDs; + DenseMap valueNames; /// This is a map of operations that contain multiple named result groups, /// i.e. there may be multiple names for the results of the operation. The key @@ -1619,7 +1619,7 @@ void OperationPrinter::numberValuesInRegion(Region ®ion) { } void OperationPrinter::numberValuesInBlock(Block &block) { - auto setArgNameFn = [&](Value *arg, StringRef name) { + auto setArgNameFn = [&](ValuePtr arg, StringRef name) { assert(!valueIDs.count(arg) && "arg numbered multiple times"); assert(cast(arg)->getOwner() == &block && "arg not defined in 'block'"); @@ -1638,7 +1638,7 @@ void OperationPrinter::numberValuesInBlock(Block &block) { // 'arg'. SmallString<32> specialNameBuffer(isEntryBlock ? "arg" : ""); llvm::raw_svector_ostream specialName(specialNameBuffer); - for (auto *arg : block.getArguments()) { + for (auto arg : block.getArguments()) { if (valueIDs.count(arg)) continue; if (isEntryBlock) { @@ -1657,11 +1657,11 @@ void OperationPrinter::numberValuesInOp(Operation &op) { unsigned numResults = op.getNumResults(); if (numResults == 0) return; - Value *resultBegin = op.getResult(0); + ValuePtr resultBegin = op.getResult(0); // Function used to set the special result names for the operation. SmallVector resultGroups(/*Size=*/1, /*Value=*/0); - auto setResultNameFn = [&](Value *result, StringRef name) { + auto setResultNameFn = [&](ValuePtr result, StringRef name) { assert(!valueIDs.count(result) && "result numbered multiple times"); assert(result->getDefiningOp() == &op && "result not defined by 'op'"); setValueName(result, name); @@ -1690,7 +1690,7 @@ void OperationPrinter::numberValuesInOp(Operation &op) { } /// Set a special value name for the given value. -void OperationPrinter::setValueName(Value *value, StringRef name) { +void OperationPrinter::setValueName(ValuePtr value, StringRef name) { // If the name is empty, the value uses the default numbering. if (name.empty()) { valueIDs[value] = nextValueID++; @@ -1737,7 +1737,7 @@ void OperationPrinter::print(Block *block, bool printBlockArgs, // Print the argument list if non-empty. if (!block->args_empty()) { os << '('; - interleaveComma(block->getArguments(), [&](BlockArgument *arg) { + interleaveComma(block->getArguments(), [&](BlockArgumentPtr arg) { printValueID(arg); os << ": "; printType(arg->getType()); @@ -1788,8 +1788,8 @@ void OperationPrinter::print(Operation *op) { printTrailingLocation(op->getLoc()); } -void OperationPrinter::getResultIDAndNumber(OpResult *result, - Value *&lookupValue, +void OperationPrinter::getResultIDAndNumber(OpResultPtr result, + ValuePtr &lookupValue, int &lookupResultNo) const { Operation *owner = result->getOwner(); if (owner->getNumResults() == 1) @@ -1827,7 +1827,7 @@ void OperationPrinter::getResultIDAndNumber(OpResult *result, lookupValue = owner->getResult(groupResultNo); } -void OperationPrinter::printValueIDImpl(Value *value, bool printResultNo, +void OperationPrinter::printValueIDImpl(ValuePtr value, bool printResultNo, raw_ostream &stream) const { if (!value) { stream << "<>"; @@ -1840,7 +1840,7 @@ void OperationPrinter::printValueIDImpl(Value *value, bool printResultNo, // If this is a reference to the result of a multi-result operation or // operation, print out the # identifier and make sure to map our lookup // to the first result of the operation. - if (OpResult *result = dyn_cast(value)) + if (OpResultPtr result = dyn_cast(value)) getResultIDAndNumber(result, lookupValue, resultNo); auto it = valueIDs.find(lookupValue); @@ -1875,11 +1875,11 @@ void OperationPrinter::shadowRegionArgs(Region ®ion, ValueRange namesToUse) { SmallVector nameStr; for (unsigned i = 0, e = namesToUse.size(); i != e; ++i) { - auto *nameToUse = namesToUse[i]; + auto nameToUse = namesToUse[i]; if (nameToUse == nullptr) continue; - auto *nameToReplace = region.front().getArgument(i); + auto nameToReplace = region.front().getArgument(i); nameStr.clear(); llvm::raw_svector_ostream nameStream(nameStr); @@ -1951,10 +1951,10 @@ void OperationPrinter::printGenericOp(Operation *op) { for (unsigned i = 0; i < numSuccessors; ++i) totalNumSuccessorOperands += op->getNumSuccessorOperands(i); unsigned numProperOperands = op->getNumOperands() - totalNumSuccessorOperands; - SmallVector properOperands( + SmallVector properOperands( op->operand_begin(), std::next(op->operand_begin(), numProperOperands)); - interleaveComma(properOperands, [&](Value *value) { printValueID(value); }); + interleaveComma(properOperands, [&](ValuePtr value) { printValueID(value); }); os << ')'; @@ -1997,10 +1997,10 @@ void OperationPrinter::printSuccessorAndUseList(Operation *term, os << '('; interleaveComma(succOperands, - [this](Value *operand) { printValueID(operand); }); + [this](ValuePtr operand) { printValueID(operand); }); os << " : "; interleaveComma(succOperands, - [this](Value *operand) { printType(operand->getType()); }); + [this](ValuePtr operand) { printType(operand->getType()); }); os << ')'; } @@ -2072,7 +2072,7 @@ void Value::print(raw_ostream &os) { if (auto *op = getDefiningOp()) return op->print(os); // TODO: Improve this. - assert(isa(*this)); + assert(isa()); os << "\n"; } diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp index 4dac32ae0c0..894f9ba38d0 100644 --- a/mlir/lib/IR/Block.cpp +++ b/mlir/lib/IR/Block.cpp @@ -98,7 +98,7 @@ void Block::dropAllReferences() { } void Block::dropAllDefinedValueUses() { - for (auto *arg : getArguments()) + for (auto arg : getArguments()) arg->dropAllUses(); for (auto &op : *this) op.dropAllDefinedValueUses(); @@ -151,7 +151,7 @@ void Block::recomputeOpOrder() { // Argument list management. //===----------------------------------------------------------------------===// -BlockArgument *Block::addArgument(Type type) { +BlockArgumentPtr Block::addArgument(Type type) { auto *arg = new BlockArgument(type, this); arguments.push_back(arg); return arg; diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp index 691b2ad99c4..733fcd13994 100644 --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -343,7 +343,7 @@ Operation *OpBuilder::createOperation(const OperationState &state) { /// 'results'. Returns success if the operation was folded, failure otherwise. /// Note: This function does not erase the operation on a successful fold. LogicalResult OpBuilder::tryFold(Operation *op, - SmallVectorImpl &results) { + SmallVectorImpl &results) { results.reserve(op->getNumResults()); auto cleanupFailure = [&] { results.assign(op->result_begin(), op->result_end()); @@ -374,7 +374,7 @@ LogicalResult OpBuilder::tryFold(Operation *op, Dialect *dialect = op->getDialect(); for (auto &it : llvm::enumerate(foldResults)) { // Normal values get pushed back directly. - if (auto *value = it.value().dyn_cast()) { + if (auto value = it.value().dyn_cast()) { results.push_back(value); continue; } diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp index 9df10791046..53399ce00a3 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -114,7 +114,7 @@ template <> unsigned BlockOperand::getOperandNumber() { /// Create a new Operation with the specific fields. Operation *Operation::create(Location location, OperationName name, ArrayRef resultTypes, - ArrayRef operands, + ArrayRef operands, ArrayRef attributes, ArrayRef successors, unsigned numRegions, bool resizableOperandList) { @@ -134,7 +134,7 @@ Operation *Operation::create(const OperationState &state) { /// Create a new Operation with the specific fields. Operation *Operation::create(Location location, OperationName name, ArrayRef resultTypes, - ArrayRef operands, + ArrayRef operands, NamedAttributeList attributes, ArrayRef successors, RegionRange regions, bool resizableOperandList) { @@ -151,7 +151,7 @@ Operation *Operation::create(Location location, OperationName name, /// unnecessarily uniquing a list of attributes. Operation *Operation::create(Location location, OperationName name, ArrayRef resultTypes, - ArrayRef operands, + ArrayRef operands, NamedAttributeList attributes, ArrayRef successors, unsigned numRegions, bool resizableOperandList) { @@ -314,7 +314,7 @@ bool Operation::isProperAncestor(Operation *other) { } /// Replace any uses of 'from' with 'to' within this operation. -void Operation::replaceUsesOfWith(Value *from, Value *to) { +void Operation::replaceUsesOfWith(ValuePtr from, ValuePtr to) { if (from == to) return; for (auto &operand : getOpOperands()) @@ -585,7 +585,7 @@ void Operation::dropAllDefinedValueUses() { /// Return true if there are no users of any results of this operation. bool Operation::use_empty() { - for (auto *result : getResults()) + for (auto result : getResults()) if (!result->use_empty()) return false; return true; @@ -672,14 +672,14 @@ InFlightDiagnostic Operation::emitOpError(const Twine &message) { /// Operands are remapped using `mapper` (if present), and `mapper` is updated /// to contain the results. Operation *Operation::cloneWithoutRegions(BlockAndValueMapping &mapper) { - SmallVector operands; + SmallVector operands; SmallVector successors; operands.reserve(getNumOperands() + getNumSuccessors()); if (getNumSuccessors() == 0) { // Non-branching operations can just add all the operands. - for (auto *opValue : getOperands()) + for (auto opValue : getOperands()) operands.push_back(mapper.lookupOrDefault(opValue)); } else { // We add the operands separated by nullptr's for each successor. @@ -699,7 +699,7 @@ Operation *Operation::cloneWithoutRegions(BlockAndValueMapping &mapper) { operands.push_back(nullptr); // Remap the successors operands. - for (auto *operand : getSuccessorOperands(succ)) + for (auto operand : getSuccessorOperands(succ)) operands.push_back(mapper.lookupOrDefault(operand)); } } @@ -1092,8 +1092,8 @@ LogicalResult OpTrait::impl::verifyResultSizeAttr(Operation *op, // These functions are out-of-line implementations of the methods in BinaryOp, // which avoids them being template instantiated/duplicated. -void impl::buildBinaryOp(Builder *builder, OperationState &result, Value *lhs, - Value *rhs) { +void impl::buildBinaryOp(Builder *builder, OperationState &result, ValuePtr lhs, + ValuePtr rhs) { assert(lhs->getType() == rhs->getType()); result.addOperands({lhs, rhs}); result.types.push_back(lhs->getType()); @@ -1133,8 +1133,8 @@ void impl::printOneResultOp(Operation *op, OpAsmPrinter &p) { // CastOp implementation //===----------------------------------------------------------------------===// -void impl::buildCastOp(Builder *builder, OperationState &result, Value *source, - Type destType) { +void impl::buildCastOp(Builder *builder, OperationState &result, + ValuePtr source, Type destType) { result.addOperands(source); result.addTypes(destType); } @@ -1157,7 +1157,7 @@ void impl::printCastOp(Operation *op, OpAsmPrinter &p) { << op->getResult(0)->getType(); } -Value *impl::foldCastOp(Operation *op) { +ValuePtr impl::foldCastOp(Operation *op) { // Identity cast if (op->getOperand(0)->getType() == op->getResult(0)->getType()) return op->getOperand(0); diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp index 256a261acd8..333685a16fd 100644 --- a/mlir/lib/IR/OperationSupport.cpp +++ b/mlir/lib/IR/OperationSupport.cpp @@ -164,7 +164,7 @@ ResultRange::ResultRange(Operation *op) //===----------------------------------------------------------------------===// // ValueRange -ValueRange::ValueRange(ArrayRef values) +ValueRange::ValueRange(ArrayRef values) : ValueRange(values.data(), values.size()) {} ValueRange::ValueRange(OperandRange values) : ValueRange(values.begin().getBase(), values.size()) {} @@ -176,18 +176,19 @@ ValueRange::OwnerT ValueRange::offset_base(const OwnerT &owner, ptrdiff_t index) { if (OpOperand *operand = owner.dyn_cast()) return operand + index; - if (OpResult *result = owner.dyn_cast()) + if (OpResultPtr result = owner.dyn_cast()) return result + index; - return owner.get() + index; + return owner.get() + index; } /// See `detail::indexed_accessor_range_base` for details. -Value *ValueRange::dereference_iterator(const OwnerT &owner, ptrdiff_t index) { +ValuePtr ValueRange::dereference_iterator(const OwnerT &owner, + ptrdiff_t index) { // Operands access the held value via 'get'. if (OpOperand *operand = owner.dyn_cast()) return operand[index].get(); // An OpResult is a value, so we can return it directly. - if (OpResult *result = owner.dyn_cast()) + if (OpResultPtr result = owner.dyn_cast()) return &result[index]; // Otherwise, this is a raw value array so just index directly. - return owner.get()[index]; + return owner.get()[index]; } diff --git a/mlir/lib/IR/Region.cpp b/mlir/lib/IR/Region.cpp index 6cec021b6a1..26f14c43424 100644 --- a/mlir/lib/IR/Region.cpp +++ b/mlir/lib/IR/Region.cpp @@ -91,7 +91,7 @@ void Region::cloneInto(Region *dest, Region::iterator destPos, // Clone the block arguments. The user might be deleting arguments to the // block by specifying them in the mapper. If so, we don't add the // argument to the cloned block. - for (auto *arg : block.getArguments()) + for (auto arg : block.getArguments()) if (!mapper.contains(arg)) mapper.map(arg, newBlock->addArgument(arg->getType())); @@ -106,7 +106,7 @@ void Region::cloneInto(Region *dest, Region::iterator destPos, // operands of each of the operations. auto remapOperands = [&](Operation *op) { for (auto &operand : op->getOpOperands()) - if (auto *mappedOp = mapper.lookupOrNull(operand.get())) + if (auto mappedOp = mapper.lookupOrNull(operand.get())) operand.set(mappedOp); for (auto &succOp : op->getBlockOperands()) if (auto *mappedOp = mapper.lookupOrNull(succOp.get())) @@ -143,7 +143,7 @@ static bool isIsolatedAbove(Region ®ion, Region &limit, while (!pendingRegions.empty()) { for (Block &block : *pendingRegions.pop_back_val()) { for (Operation &op : block) { - for (Value *operand : op.getOperands()) { + for (ValuePtr operand : op.getOperands()) { // operand should be non-null here if the IR is well-formed. But // we don't assert here as this function is called from the verifier // and so could be called on invalid IR. diff --git a/mlir/lib/IR/TypeUtilities.cpp b/mlir/lib/IR/TypeUtilities.cpp index 54b1bf6329b..8200e3a3bc6 100644 --- a/mlir/lib/IR/TypeUtilities.cpp +++ b/mlir/lib/IR/TypeUtilities.cpp @@ -33,11 +33,11 @@ Type mlir::getElementTypeOrSelf(Type type) { return type; } -Type mlir::getElementTypeOrSelf(Value *val) { +Type mlir::getElementTypeOrSelf(ValuePtr val) { return getElementTypeOrSelf(val->getType()); } -Type mlir::getElementTypeOrSelf(Value &val) { +Type mlir::getElementTypeOrSelf(ValueRef val) { return getElementTypeOrSelf(val.getType()); } @@ -101,18 +101,18 @@ LogicalResult mlir::verifyCompatibleShape(Type type1, Type type2) { OperandElementTypeIterator::OperandElementTypeIterator( Operation::operand_iterator it) - : llvm::mapped_iterator( + : llvm::mapped_iterator( it, &unwrap) {} -Type OperandElementTypeIterator::unwrap(Value *value) { +Type OperandElementTypeIterator::unwrap(ValuePtr value) { return value->getType().cast().getElementType(); } ResultElementTypeIterator::ResultElementTypeIterator( Operation::result_iterator it) - : llvm::mapped_iterator( + : llvm::mapped_iterator( it, &unwrap) {} -Type ResultElementTypeIterator::unwrap(Value *value) { +Type ResultElementTypeIterator::unwrap(ValuePtr value) { return value->getType().cast().getElementType(); } diff --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp index 4c2ea5ac69c..660d8ae3248 100644 --- a/mlir/lib/IR/Value.cpp +++ b/mlir/lib/IR/Value.cpp @@ -23,7 +23,7 @@ using namespace mlir; /// If this value is the result of an Operation, return the operation that /// defines it. Operation *Value::getDefiningOp() { - if (auto *result = dyn_cast(this)) + if (auto *result = dyn_cast()) return result->getOwner(); return nullptr; } @@ -38,7 +38,7 @@ Location Value::getLoc() { Region *Value::getParentRegion() { if (auto *op = getDefiningOp()) return op->getParentRegion(); - return cast(this)->getOwner()->getParent(); + return cast()->getOwner()->getParent(); } //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index 498a64d70c2..f78704842fe 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -3093,7 +3093,7 @@ public: ParseResult popSSANameScope(); /// Register a definition of a value with the symbol table. - ParseResult addDefinition(SSAUseInfo useInfo, Value *value); + ParseResult addDefinition(SSAUseInfo useInfo, ValuePtr value); /// Parse an optional list of SSA uses into 'results'. ParseResult parseOptionalSSAUseList(SmallVectorImpl &results); @@ -3103,12 +3103,13 @@ public: /// Given a reference to an SSA value and its type, return a reference. This /// returns null on failure. - Value *resolveSSAUse(SSAUseInfo useInfo, Type type); + ValuePtr resolveSSAUse(SSAUseInfo useInfo, Type type); ParseResult parseSSADefOrUseAndType( const std::function &action); - ParseResult parseOptionalSSAUseAndTypeList(SmallVectorImpl &results); + ParseResult + parseOptionalSSAUseAndTypeList(SmallVectorImpl &results); /// Return the location of the value identified by its name and number if it /// has been already reference. @@ -3130,12 +3131,12 @@ public: /// Parse a single operation successor and its operand list. ParseResult parseSuccessorAndUseList(Block *&dest, - SmallVectorImpl &operands); + SmallVectorImpl &operands); /// Parse a comma-separated list of operation successors in brackets. ParseResult parseSuccessors(SmallVectorImpl &destinations, - SmallVectorImpl> &operands); + SmallVectorImpl> &operands); /// Parse an operation instance that is in the generic form. Operation *parseGenericOperation(); @@ -3174,7 +3175,7 @@ public: /// Parse a (possibly empty) list of block arguments. ParseResult - parseOptionalBlockArgList(SmallVectorImpl &results, + parseOptionalBlockArgList(SmallVectorImpl &results, Block *owner); /// Get the block with the specified name, creating it if it doesn't @@ -3204,14 +3205,14 @@ private: void recordDefinition(StringRef def); /// Get the value entry for the given SSA name. - SmallVectorImpl> &getSSAValueEntry(StringRef name); + SmallVectorImpl> &getSSAValueEntry(StringRef name); /// Create a forward reference placeholder value with the given location and /// result type. - Value *createForwardRefPlaceholder(SMLoc loc, Type type); + ValuePtr createForwardRefPlaceholder(SMLoc loc, Type type); /// Return true if this is a forward reference. - bool isForwardRefPlaceholder(Value *value) { + bool isForwardRefPlaceholder(ValuePtr value) { return forwardRefPlaceholders.count(value); } @@ -3236,7 +3237,7 @@ private: /// This keeps track of all of the SSA values we are tracking for each name /// scope, indexed by their name. This has one entry per result number. - llvm::StringMap, 1>> values; + llvm::StringMap, 1>> values; /// This keeps track of all of the values defined by a specific name scope. SmallVector, 2> definitionsPerScope; @@ -3253,7 +3254,7 @@ private: /// These are all of the placeholders we've made along with the location of /// their first reference, to allow checking for use of undefined values. - DenseMap forwardRefPlaceholders; + DenseMap forwardRefPlaceholders; /// The builder used when creating parsed operation instances. OpBuilder opBuilder; @@ -3278,7 +3279,7 @@ ParseResult OperationParser::finalize() { // Check for any forward references that are left. If we find any, error // out. if (!forwardRefPlaceholders.empty()) { - SmallVector, 4> errors; + SmallVector, 4> errors; // Iteration over the map isn't deterministic, so sort by source location. for (auto entry : forwardRefPlaceholders) errors.push_back({entry.second.getPointer(), entry.first}); @@ -3342,7 +3343,7 @@ ParseResult OperationParser::popSSANameScope() { } /// Register a definition of a value with the symbol table. -ParseResult OperationParser::addDefinition(SSAUseInfo useInfo, Value *value) { +ParseResult OperationParser::addDefinition(SSAUseInfo useInfo, ValuePtr value) { auto &entries = getSSAValueEntry(useInfo.name); // Make sure there is a slot for this value. @@ -3351,7 +3352,7 @@ ParseResult OperationParser::addDefinition(SSAUseInfo useInfo, Value *value) { // If we already have an entry for this, check to see if it was a definition // or a forward reference. - if (auto *existing = entries[useInfo.number].first) { + if (auto existing = entries[useInfo.number].first) { if (!isForwardRefPlaceholder(existing)) { return emitError(useInfo.loc) .append("redefinition of SSA value '", useInfo.name, "'") @@ -3416,12 +3417,12 @@ ParseResult OperationParser::parseSSAUse(SSAUseInfo &result) { /// Given an unbound reference to an SSA value and its type, return the value /// it specifies. This returns null on failure. -Value *OperationParser::resolveSSAUse(SSAUseInfo useInfo, Type type) { +ValuePtr OperationParser::resolveSSAUse(SSAUseInfo useInfo, Type type) { auto &entries = getSSAValueEntry(useInfo.name); // If we have already seen a value of this name, return it. if (useInfo.number < entries.size() && entries[useInfo.number].first) { - auto *result = entries[useInfo.number].first; + auto result = entries[useInfo.number].first; // Check that the type matches the other uses. if (result->getType() == type) return result; @@ -3447,7 +3448,7 @@ Value *OperationParser::resolveSSAUse(SSAUseInfo useInfo, Type type) { // Otherwise, this is a forward reference. Create a placeholder and remember // that we did so. - auto *result = createForwardRefPlaceholder(useInfo.loc, type); + auto result = createForwardRefPlaceholder(useInfo.loc, type); entries[useInfo.number].first = result; entries[useInfo.number].second = useInfo.loc; return result; @@ -3477,7 +3478,7 @@ ParseResult OperationParser::parseSSADefOrUseAndType( /// ::= ssa-use-list ':' type-list-no-parens /// ParseResult OperationParser::parseOptionalSSAUseAndTypeList( - SmallVectorImpl &results) { + SmallVectorImpl &results) { SmallVector valueIDs; if (parseOptionalSSAUseList(valueIDs)) return failure(); @@ -3497,7 +3498,7 @@ ParseResult OperationParser::parseOptionalSSAUseAndTypeList( results.reserve(valueIDs.size()); for (unsigned i = 0, e = valueIDs.size(); i != e; ++i) { - if (auto *value = resolveSSAUse(valueIDs[i], types[i])) + if (auto value = resolveSSAUse(valueIDs[i], types[i])) results.push_back(value); else return failure(); @@ -3512,13 +3513,13 @@ void OperationParser::recordDefinition(StringRef def) { } /// Get the value entry for the given SSA name. -SmallVectorImpl> & +SmallVectorImpl> & OperationParser::getSSAValueEntry(StringRef name) { return isolatedNameScopes.back().values[name]; } /// Create and remember a new placeholder for a forward reference. -Value *OperationParser::createForwardRefPlaceholder(SMLoc loc, Type type) { +ValuePtr OperationParser::createForwardRefPlaceholder(SMLoc loc, Type type) { // Forward references are always created as operations, because we just need // something with a def/use chain. // @@ -3632,7 +3633,7 @@ ParseResult OperationParser::parseOperation() { /// ParseResult OperationParser::parseSuccessorAndUseList(Block *&dest, - SmallVectorImpl &operands) { + SmallVectorImpl &operands) { // Verify branch is identifier and get the matching block. if (!getToken().is(Token::caret_identifier)) return emitError("expected block name"); @@ -3655,13 +3656,13 @@ OperationParser::parseSuccessorAndUseList(Block *&dest, /// ParseResult OperationParser::parseSuccessors( SmallVectorImpl &destinations, - SmallVectorImpl> &operands) { + SmallVectorImpl> &operands) { if (parseToken(Token::l_square, "expected '['")) return failure(); auto parseElt = [this, &destinations, &operands]() { Block *dest; - SmallVector destOperands; + SmallVector destOperands; auto res = parseSuccessorAndUseList(dest, destOperands); destinations.push_back(dest); operands.push_back(destOperands); @@ -3718,7 +3719,7 @@ Operation *OperationParser::parseGenericOperation() { // Parse the successor list but don't add successors to the result yet to // avoid messing up with the argument order. SmallVector successors; - SmallVector, 2> successorOperands; + SmallVector, 2> successorOperands; if (getToken().is(Token::l_square)) { // Check if the operation is a known terminator. const AbstractOperation *abstractOp = result.name.getAbstractOperation(); @@ -3779,7 +3780,7 @@ Operation *OperationParser::parseGenericOperation() { // Add the successors, and their operands after the proper operands. for (const auto &succ : llvm::zip(successors, successorOperands)) { Block *successor = std::get<0>(succ); - const SmallVector &operands = std::get<1>(succ); + const SmallVector &operands = std::get<1>(succ); result.addSuccessor(successor, operands); } @@ -4129,10 +4130,10 @@ public: /// Resolve an operand to an SSA value, emitting an error on failure. ParseResult resolveOperand(const OperandType &operand, Type type, - SmallVectorImpl &result) override { + SmallVectorImpl &result) override { OperationParser::SSAUseInfo operandInfo = {operand.name, operand.number, operand.location}; - if (auto *value = parser.resolveSSAUse(operandInfo, type)) { + if (auto value = parser.resolveSSAUse(operandInfo, type)) { result.push_back(value); return success(); } @@ -4242,7 +4243,7 @@ public: /// Parse a single operation successor and its operand list. ParseResult parseSuccessorAndUseList(Block *&dest, - SmallVectorImpl &operands) override { + SmallVectorImpl &operands) override { return parser.parseSuccessorAndUseList(dest, operands); } @@ -4470,7 +4471,7 @@ ParseResult OperationParser::parseBlock(Block *&block) { // If an argument list is present, parse it. if (consumeIf(Token::l_paren)) { - SmallVector bbArgs; + SmallVector bbArgs; if (parseOptionalBlockArgList(bbArgs, block) || parseToken(Token::r_paren, "expected ')' to end argument list")) return failure(); @@ -4534,7 +4535,7 @@ Block *OperationParser::defineBlockNamed(StringRef name, SMLoc loc, /// ssa-id-and-type-list ::= ssa-id-and-type (`,` ssa-id-and-type)* /// ParseResult OperationParser::parseOptionalBlockArgList( - SmallVectorImpl &results, Block *owner) { + SmallVectorImpl &results, Block *owner) { if (getToken().is(Token::r_brace)) return success(); @@ -4555,7 +4556,7 @@ ParseResult OperationParser::parseOptionalBlockArgList( return emitError("too many arguments specified in argument list"); // Finally, make sure the existing argument has the correct type. - auto *arg = owner->getArgument(nextArgument++); + auto arg = owner->getArgument(nextArgument++); if (arg->getType() != type) return emitError("argument and block argument type mismatch"); return addDefinition(useInfo, arg); diff --git a/mlir/lib/Pass/IRPrinting.cpp b/mlir/lib/Pass/IRPrinting.cpp index 8e172156f05..9d1c1f0d391 100644 --- a/mlir/lib/Pass/IRPrinting.cpp +++ b/mlir/lib/Pass/IRPrinting.cpp @@ -48,14 +48,14 @@ public: for (Region ®ion : op->getRegions()) { for (Block &block : region) { addDataToHash(hasher, &block); - for (BlockArgument *arg : block.getArguments()) + for (BlockArgumentPtr arg : block.getArguments()) addDataToHash(hasher, arg); } } // - Location addDataToHash(hasher, op->getLoc().getAsOpaquePointer()); // - Operands - for (Value *operand : op->getOperands()) + for (ValuePtr operand : op->getOperands()) addDataToHash(hasher, operand); // - Successors for (unsigned i = 0, e = op->getNumSuccessors(); i != e; ++i) diff --git a/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp b/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp index d38c76255f0..13fed0f9b1c 100644 --- a/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp +++ b/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp @@ -102,7 +102,7 @@ void CAGSlice::enumerateImpliedConnections( std::vector> impliedPairs; for (auto &resultAnchorPair : resultAnchors) { CAGResultAnchor *resultAnchor = resultAnchorPair.second; - Value *resultValue = resultAnchor->getValue(); + ValuePtr resultValue = resultAnchor->getValue(); for (auto &use : resultValue->getUses()) { Operation *operandOp = use.getOwner(); unsigned operandIdx = use.getOperandNumber(); diff --git a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp index a32bb2c9b3c..a3cbe214040 100644 --- a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp +++ b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp @@ -74,7 +74,7 @@ void AddDefaultStatsPass::runWithConfig(SolverContext &solverContext, auto func = getFunction(); // Insert stats for each argument. - for (auto *arg : func.getArguments()) { + for (auto arg : func.getArguments()) { if (!config.isHandledType(arg->getType())) continue; OpBuilder b(func.getBody()); diff --git a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp index 511df0a463f..68c263bc423 100644 --- a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp +++ b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp @@ -181,17 +181,17 @@ void InferQuantizedTypesPass::runWithConfig(SolverContext &solverContext, void InferQuantizedTypesPass::transformOperandType(CAGOperandAnchor *anchor, Type newType) { - Value *inputValue = anchor->getValue(); + ValuePtr inputValue = anchor->getValue(); Operation *op = anchor->getOp(); OpBuilder b(op->getBlock(), Block::iterator(op)); - SmallVector removeValuesIfDead; + SmallVector removeValuesIfDead; // Because we've already run the result transforms at this phase, it is // very likely that inputValue points to a dcast op whose input matches // our type. We detect that situation and route around just to save some // bulk in the IR. - Value *newTypedInputValue = inputValue; + ValuePtr newTypedInputValue = inputValue; auto inputDcastOp = dyn_cast_or_null(inputValue->getDefiningOp()); if (inputDcastOp && inputDcastOp.arg()->getType() == newType) { @@ -228,7 +228,7 @@ void InferQuantizedTypesPass::transformOperandType(CAGOperandAnchor *anchor, break; } - for (Value *removeValueIfDead : removeValuesIfDead) { + for (ValuePtr removeValueIfDead : removeValuesIfDead) { if (removeValueIfDead->use_empty()) { removeValueIfDead->getDefiningOp()->erase(); } @@ -237,12 +237,12 @@ void InferQuantizedTypesPass::transformOperandType(CAGOperandAnchor *anchor, void InferQuantizedTypesPass::transformResultType(CAGResultAnchor *anchor, Type newType) { - Value *origResultValue = anchor->getValue(); + ValuePtr origResultValue = anchor->getValue(); Operation *op = origResultValue->getDefiningOp(); OpBuilder b(op->getBlock(), ++Block::iterator(op)); - Value *replacedResultValue = nullptr; - Value *newResultValue = nullptr; + ValuePtr replacedResultValue = nullptr; + ValuePtr newResultValue = nullptr; switch (anchor->getTypeTransformRule()) { case CAGAnchorNode::TypeTransformRule::Direct: origResultValue->setType(newType); diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp index 098dba3ae6e..e8f44087b85 100644 --- a/mlir/lib/TableGen/Pattern.cpp +++ b/mlir/lib/TableGen/Pattern.cpp @@ -224,7 +224,7 @@ tblgen::SymbolInfoMap::SymbolInfo::getVarDecl(StringRef name) const { return formatv("Operation::operand_range {0}(op0->getOperands());\n", name); } case Kind::Value: { - return formatv("ArrayRef {0};\n", name); + return formatv("ArrayRef {0};\n", name); } case Kind::Result: { // Use the op itself for captured results. diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp index 6cf975bcce2..7273d3dfd7b 100644 --- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp @@ -76,7 +76,7 @@ private: /// `value` is an SSA-use. Return the remapped version of `value` or a /// placeholder that will be remapped later if this is an instruction that /// has not yet been visited. - Value *processValue(llvm::Value *value); + ValuePtr processValue(llvm::Value *value); /// Create the most accurate Location possible using a llvm::DebugLoc and /// possibly an llvm::Instruction to narrow the Location if debug information /// is unavailable. @@ -85,14 +85,14 @@ private: /// `br` branches to `target`. Return the block arguments to attach to the /// generated branch op. These should be in the same order as the PHIs in /// `target`. - SmallVector processBranchArgs(llvm::BranchInst *br, - llvm::BasicBlock *target); + SmallVector processBranchArgs(llvm::BranchInst *br, + llvm::BasicBlock *target); /// Return `value` as an attribute to attach to a GlobalOp. Attribute getConstantAsAttr(llvm::Constant *value); /// Return `c` as an MLIR Value. This could either be a ConstantOp, or /// an expanded sequence of ops in the current function's entry block (for /// ConstantExprs or ConstantGEPs). - Value *processConstant(llvm::Constant *c); + ValuePtr processConstant(llvm::Constant *c); /// The current builder, pointing at where the next Instruction should be /// generated. @@ -120,7 +120,7 @@ private: /// Remapped blocks, for the current function. DenseMap blocks; /// Remapped values. These are function-local. - DenseMap instMap; + DenseMap instMap; /// Instructions that had not been defined when first encountered as a use. /// Maps to the dummy Operation that was created in processValue(). DenseMap unknownInstMap; @@ -263,13 +263,13 @@ GlobalOp Importer::processGlobal(llvm::GlobalVariable *GV) { Region &r = op.getInitializerRegion(); currentEntryBlock = b.createBlock(&r); b.setInsertionPoint(currentEntryBlock, currentEntryBlock->begin()); - Value *v = processConstant(GV->getInitializer()); - b.create(op.getLoc(), ArrayRef({v})); + ValuePtr v = processConstant(GV->getInitializer()); + b.create(op.getLoc(), ArrayRef({v})); } return globals[GV] = op; } -Value *Importer::processConstant(llvm::Constant *c) { +ValuePtr Importer::processConstant(llvm::Constant *c) { if (Attribute attr = getConstantAsAttr(c)) { // These constants can be represented as attributes. OpBuilder b(currentEntryBlock, currentEntryBlock->begin()); @@ -298,7 +298,7 @@ Value *Importer::processConstant(llvm::Constant *c) { return nullptr; } -Value *Importer::processValue(llvm::Value *value) { +ValuePtr Importer::processValue(llvm::Value *value) { auto it = instMap.find(value); if (it != instMap.end()) return it->second; @@ -407,9 +407,9 @@ static ICmpPredicate getICmpPredicate(llvm::CmpInst::Predicate p) { // `br` branches to `target`. Return the branch arguments to `br`, in the // same order of the PHIs in `target`. -SmallVector Importer::processBranchArgs(llvm::BranchInst *br, - llvm::BasicBlock *target) { - SmallVector v; +SmallVector Importer::processBranchArgs(llvm::BranchInst *br, + llvm::BasicBlock *target) { + SmallVector v; for (auto inst = target->begin(); isa(inst); ++inst) { auto *PN = cast(&*inst); v.push_back(processValue(PN->getIncomingValueForBlock(br->getParent()))); @@ -421,7 +421,7 @@ LogicalResult Importer::processInstruction(llvm::Instruction *inst) { // FIXME: Support uses of SubtargetData. Currently inbounds GEPs, fast-math // flags and call / operand attributes are not supported. Location loc = processDebugLoc(inst->getDebugLoc(), inst); - Value *&v = instMap[inst]; + ValuePtr &v = instMap[inst]; assert(!v && "processInstruction must be called only once per instruction!"); switch (inst->getOpcode()) { default: @@ -462,7 +462,7 @@ LogicalResult Importer::processInstruction(llvm::Instruction *inst) { case llvm::Instruction::AddrSpaceCast: case llvm::Instruction::BitCast: { OperationState state(loc, opcMap.lookup(inst->getOpcode())); - SmallVector ops; + SmallVector ops; ops.reserve(inst->getNumOperands()); for (auto *op : inst->operand_values()) ops.push_back(processValue(op)); @@ -484,7 +484,7 @@ LogicalResult Importer::processInstruction(llvm::Instruction *inst) { auto *brInst = cast(inst); OperationState state(loc, brInst->isConditional() ? "llvm.cond_br" : "llvm.br"); - SmallVector ops; + SmallVector ops; if (brInst->isConditional()) ops.push_back(processValue(brInst->getCondition())); state.addOperands(ops); @@ -500,7 +500,7 @@ LogicalResult Importer::processInstruction(llvm::Instruction *inst) { } case llvm::Instruction::Call: { llvm::CallInst *ci = cast(inst); - SmallVector ops; + SmallVector ops; ops.reserve(inst->getNumOperands()); for (auto &op : ci->arg_operands()) ops.push_back(processValue(op.get())); @@ -523,7 +523,7 @@ LogicalResult Importer::processInstruction(llvm::Instruction *inst) { case llvm::Instruction::GetElementPtr: { // FIXME: Support inbounds GEPs. llvm::GetElementPtrInst *gep = cast(inst); - SmallVector ops; + SmallVector ops; for (auto *op : gep->operand_values()) ops.push_back(processValue(op)); v = b.create(loc, processType(inst->getType()), ops, @@ -565,8 +565,8 @@ LogicalResult Importer::processFunction(llvm::Function *f) { // any unknown uses we encountered are remapped. for (auto &llvmAndUnknown : unknownInstMap) { assert(instMap.count(llvmAndUnknown.first)); - Value *newValue = instMap[llvmAndUnknown.first]; - Value *oldValue = llvmAndUnknown.second->getResult(0); + ValuePtr newValue = instMap[llvmAndUnknown.first]; + ValuePtr oldValue = llvmAndUnknown.second->getResult(0); oldValue->replaceAllUsesWith(newValue); llvmAndUnknown.second->erase(); } diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index e59c69aa25b..ec28434b823 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -248,7 +248,7 @@ LogicalResult ModuleTranslation::convertBlock(Block &bb, bool ignoreArguments) { auto predecessors = bb.getPredecessors(); unsigned numPredecessors = std::distance(predecessors.begin(), predecessors.end()); - for (auto *arg : bb.getArguments()) { + for (auto arg : bb.getArguments()) { auto wrappedType = arg->getType().dyn_cast(); if (!wrappedType) return emitError(bb.front().getLoc(), @@ -342,8 +342,8 @@ void ModuleTranslation::convertGlobals() { /// Get the SSA value passed to the current block from the terminator operation /// of its predecessor. -static Value *getPHISourceValue(Block *current, Block *pred, - unsigned numArguments, unsigned index) { +static ValuePtr getPHISourceValue(Block *current, Block *pred, + unsigned numArguments, unsigned index) { auto &terminator = *pred->getTerminator(); if (isa(terminator)) { return terminator.getOperand(index); @@ -420,7 +420,7 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) { unsigned int argIdx = 0; for (const auto &kvp : llvm::zip(func.getArguments(), llvmFunc->args())) { llvm::Argument &llvmArg = std::get<1>(kvp); - BlockArgument *mlirArg = std::get<0>(kvp); + BlockArgumentPtr mlirArg = std::get<0>(kvp); if (auto attr = func.getArgAttrOfType(argIdx, "llvm.noalias")) { // NB: Attribute already verified to be boolean, so check if we can indeed @@ -497,7 +497,7 @@ SmallVector ModuleTranslation::lookupValues(ValueRange values) { SmallVector remapped; remapped.reserve(values.size()); - for (Value *v : values) + for (ValuePtr v : values) remapped.push_back(valueMapping.lookup(v)); return remapped; } diff --git a/mlir/lib/Transforms/AffineDataCopyGeneration.cpp b/mlir/lib/Transforms/AffineDataCopyGeneration.cpp index 7fb356f3ad2..5bc33943e50 100644 --- a/mlir/lib/Transforms/AffineDataCopyGeneration.cpp +++ b/mlir/lib/Transforms/AffineDataCopyGeneration.cpp @@ -130,7 +130,7 @@ struct AffineDataCopyGeneration bool skipNonUnitStrideLoops; // Constant zero index to avoid too many duplicates. - Value *zeroIndex = nullptr; + ValuePtr zeroIndex = nullptr; }; } // end anonymous namespace diff --git a/mlir/lib/Transforms/AffineLoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/AffineLoopInvariantCodeMotion.cpp index f384f6d3fb1..23199dd8a39 100644 --- a/mlir/lib/Transforms/AffineLoopInvariantCodeMotion.cpp +++ b/mlir/lib/Transforms/AffineLoopInvariantCodeMotion.cpp @@ -58,15 +58,15 @@ struct LoopInvariantCodeMotion : public FunctionPass { } // end anonymous namespace static bool -checkInvarianceOfNestedIfOps(Operation *op, Value *indVar, +checkInvarianceOfNestedIfOps(Operation *op, ValuePtr indVar, SmallPtrSetImpl &definedOps, SmallPtrSetImpl &opsToHoist); -static bool isOpLoopInvariant(Operation &op, Value *indVar, +static bool isOpLoopInvariant(Operation &op, ValuePtr indVar, SmallPtrSetImpl &definedOps, SmallPtrSetImpl &opsToHoist); static bool -areAllOpsInTheBlockListInvariant(Region &blockList, Value *indVar, +areAllOpsInTheBlockListInvariant(Region &blockList, ValuePtr indVar, SmallPtrSetImpl &definedOps, SmallPtrSetImpl &opsToHoist); @@ -79,7 +79,7 @@ static bool isMemRefDereferencingOp(Operation &op) { } // Returns true if the individual op is loop invariant. -bool isOpLoopInvariant(Operation &op, Value *indVar, +bool isOpLoopInvariant(Operation &op, ValuePtr indVar, SmallPtrSetImpl &definedOps, SmallPtrSetImpl &opsToHoist) { LLVM_DEBUG(llvm::dbgs() << "iterating on op: " << op;); @@ -97,9 +97,9 @@ bool isOpLoopInvariant(Operation &op, Value *indVar, return false; } else if (!isa(op)) { if (isMemRefDereferencingOp(op)) { - Value *memref = isa(op) - ? cast(op).getMemRef() - : cast(op).getMemRef(); + ValuePtr memref = isa(op) + ? cast(op).getMemRef() + : cast(op).getMemRef(); for (auto *user : memref->getUsers()) { // If this memref has a user that is a DMA, give up because these // operations write to this memref. @@ -163,7 +163,8 @@ bool isOpLoopInvariant(Operation &op, Value *indVar, // Checks if all ops in a region (i.e. list of blocks) are loop invariant. bool areAllOpsInTheBlockListInvariant( - Region &blockList, Value *indVar, SmallPtrSetImpl &definedOps, + Region &blockList, ValuePtr indVar, + SmallPtrSetImpl &definedOps, SmallPtrSetImpl &opsToHoist) { for (auto &b : blockList) { @@ -178,7 +179,7 @@ bool areAllOpsInTheBlockListInvariant( } // Returns true if the affine.if op can be hoisted. -bool checkInvarianceOfNestedIfOps(Operation *op, Value *indVar, +bool checkInvarianceOfNestedIfOps(Operation *op, ValuePtr indVar, SmallPtrSetImpl &definedOps, SmallPtrSetImpl &opsToHoist) { assert(isa(op)); @@ -199,7 +200,7 @@ bool checkInvarianceOfNestedIfOps(Operation *op, Value *indVar, void LoopInvariantCodeMotion::runOnAffineForOp(AffineForOp forOp) { auto *loopBody = forOp.getBody(); - auto *indVar = forOp.getInductionVar(); + auto indVar = forOp.getInductionVar(); SmallPtrSet definedOps; // This is the place where hoisted instructions would reside. diff --git a/mlir/lib/Transforms/DialectConversion.cpp b/mlir/lib/Transforms/DialectConversion.cpp index 37c918fe9be..05066ef599c 100644 --- a/mlir/lib/Transforms/DialectConversion.cpp +++ b/mlir/lib/Transforms/DialectConversion.cpp @@ -86,13 +86,13 @@ namespace { struct ConversionValueMapping { /// Lookup a mapped value within the map. If a mapping for the provided value /// does not exist then return the provided value. - Value *lookupOrDefault(Value *from) const; + ValuePtr lookupOrDefault(ValuePtr from) const; /// Map a value to the one provided. - void map(Value *oldVal, Value *newVal) { mapping.map(oldVal, newVal); } + void map(ValuePtr oldVal, ValuePtr newVal) { mapping.map(oldVal, newVal); } /// Drop the last mapping for the given value. - void erase(Value *value) { mapping.erase(value); } + void erase(ValuePtr value) { mapping.erase(value); } private: /// Current value mappings. @@ -102,10 +102,10 @@ private: /// Lookup a mapped value within the map. If a mapping for the provided value /// does not exist then return the provided value. -Value *ConversionValueMapping::lookupOrDefault(Value *from) const { +ValuePtr ConversionValueMapping::lookupOrDefault(ValuePtr from) const { // If this value had a valid mapping, unmap that value as well in the case // that it was also replaced. - while (auto *mappedValue = mapping.lookupOrNull(from)) + while (auto mappedValue = mapping.lookupOrNull(from)) from = mappedValue; return from; } @@ -127,7 +127,7 @@ struct ArgConverter { /// been converted. struct ConvertedArgInfo { ConvertedArgInfo(unsigned newArgIdx, unsigned newArgSize, - Value *castValue = nullptr) + ValuePtr castValue = nullptr) : newArgIdx(newArgIdx), newArgSize(newArgSize), castValue(castValue) {} /// The start index of in the new argument list that contains arguments that @@ -139,7 +139,7 @@ struct ArgConverter { /// The cast value that was created to cast from the new arguments to the /// old. This only used if 'newArgSize' > 1. - Value *castValue; + ValuePtr castValue; }; /// This structure contains information pertaining to a block that has had its @@ -235,7 +235,7 @@ void ArgConverter::notifyOpRemoved(Operation *op) { // Drop all uses of the original arguments and delete the original block. Block *origBlock = it->second.origBlock; - for (BlockArgument *arg : origBlock->getArguments()) + for (BlockArgumentPtr arg : origBlock->getArguments()) arg->dropAllUses(); conversionInfo.erase(it); } @@ -270,7 +270,7 @@ void ArgConverter::applyRewrites(ConversionValueMapping &mapping) { // Process the remapping for each of the original arguments. for (unsigned i = 0, e = origBlock->getNumArguments(); i != e; ++i) { Optional &argInfo = blockInfo.argInfo[i]; - BlockArgument *origArg = origBlock->getArgument(i); + BlockArgumentPtr origArg = origBlock->getArgument(i); // Handle the case of a 1->0 value mapping. if (!argInfo) { @@ -305,7 +305,7 @@ void ArgConverter::applyRewrites(ConversionValueMapping &mapping) { } // Otherwise this is a 1->N value mapping. - Value *castValue = argInfo->castValue; + ValuePtr castValue = argInfo->castValue; assert(argInfo->newArgSize > 1 && castValue && "expected 1->N mapping"); // If the argument is still used, replace it with the generated cast. @@ -344,8 +344,8 @@ Block *ArgConverter::applySignatureConversion( Block *newBlock = block->splitBlock(block->begin()); block->replaceAllUsesWith(newBlock); - SmallVector newArgRange(newBlock->addArguments(convertedTypes)); - ArrayRef newArgs(newArgRange); + SmallVector newArgRange(newBlock->addArguments(convertedTypes)); + ArrayRef newArgs(newArgRange); // Remap each of the original arguments as determined by the signature // conversion. @@ -358,7 +358,7 @@ Block *ArgConverter::applySignatureConversion( auto inputMap = signatureConversion.getInputMapping(i); if (!inputMap) continue; - BlockArgument *origArg = block->getArgument(i); + BlockArgumentPtr origArg = block->getArgument(i); // If inputMap->replacementValue is not nullptr, then the argument is // dropped and a replacement value is provided to be the remappedValue. @@ -445,7 +445,7 @@ struct ConversionPatternRewriterImpl { : op(op), newValues(newValues.begin(), newValues.end()) {} Operation *op; - SmallVector newValues; + SmallVector newValues; }; /// The kind of the block action performed during the rewrite. Actions can be @@ -542,7 +542,7 @@ struct ConversionPatternRewriterImpl { /// Remap the given operands to those with potentially different types. void remapValues(Operation::operand_range operands, - SmallVectorImpl &remapped); + SmallVectorImpl &remapped); /// Returns true if the given operation is ignored, and does not need to be /// converted. @@ -591,7 +591,7 @@ void ConversionPatternRewriterImpl::resetState(RewriterState state) { // Reset any replaced operations and undo any saved mappings. for (auto &repl : llvm::drop_begin(replacements, state.numReplacements)) - for (auto *result : repl.op->getResults()) + for (auto result : repl.op->getResults()) mapping.erase(result); replacements.resize(state.numReplacements); @@ -660,7 +660,7 @@ void ConversionPatternRewriterImpl::applyRewrites() { // Apply all of the rewrites replacements requested during conversion. for (auto &repl : replacements) { for (unsigned i = 0, e = repl.newValues.size(); i != e; ++i) { - if (auto *newValue = repl.newValues[i]) + if (auto newValue = repl.newValues[i]) repl.op->getResult(i)->replaceAllUsesWith( mapping.lookupOrDefault(newValue)); } @@ -715,7 +715,7 @@ void ConversionPatternRewriterImpl::replaceOp(Operation *op, // Create mappings for each of the new result values. for (unsigned i = 0, e = newValues.size(); i < e; ++i) - if (auto *repl = newValues[i]) + if (auto repl = newValues[i]) mapping.map(op->getResult(i), repl); // Record the requested operation replacement. @@ -755,9 +755,9 @@ void ConversionPatternRewriterImpl::notifyRegionWasClonedBefore( } void ConversionPatternRewriterImpl::remapValues( - Operation::operand_range operands, SmallVectorImpl &remapped) { + Operation::operand_range operands, SmallVectorImpl &remapped) { remapped.reserve(llvm::size(operands)); - for (Value *operand : operands) + for (ValuePtr operand : operands) remapped.push_back(mapping.lookupOrDefault(operand)); } @@ -803,7 +803,7 @@ void ConversionPatternRewriter::replaceOp(Operation *op, ValueRange newValues, void ConversionPatternRewriter::eraseOp(Operation *op) { LLVM_DEBUG(llvm::dbgs() << "** Erasing operation : " << op->getName() << "\n"); - SmallVector nullRepls(op->getNumResults(), nullptr); + SmallVector nullRepls(op->getNumResults(), nullptr); impl->replaceOp(op, nullRepls, /*valuesToRemoveIfDead=*/llvm::None); } @@ -813,8 +813,8 @@ Block *ConversionPatternRewriter::applySignatureConversion( return impl->applySignatureConversion(region, conversion); } -void ConversionPatternRewriter::replaceUsesOfBlockArgument(BlockArgument *from, - Value *to) { +void ConversionPatternRewriter::replaceUsesOfBlockArgument( + BlockArgumentPtr from, ValuePtr to) { for (auto &u : from->getUses()) { if (u.getOwner() == to->getDefiningOp()) continue; @@ -825,7 +825,7 @@ void ConversionPatternRewriter::replaceUsesOfBlockArgument(BlockArgument *from, /// Return the converted value that replaces 'key'. Return 'key' if there is /// no such a converted value. -Value *ConversionPatternRewriter::getRemappedValue(Value *key) { +ValuePtr ConversionPatternRewriter::getRemappedValue(ValuePtr key) { return impl->mapping.lookupOrDefault(key); } @@ -896,7 +896,7 @@ detail::ConversionPatternRewriterImpl &ConversionPatternRewriter::getImpl() { PatternMatchResult ConversionPattern::matchAndRewrite(Operation *op, PatternRewriter &rewriter) const { - SmallVector operands; + SmallVector operands; auto &dialectRewriter = static_cast(rewriter); dialectRewriter.getImpl().remapValues(op->getOperands(), operands); @@ -908,7 +908,7 @@ ConversionPattern::matchAndRewrite(Operation *op, SmallVector destinations; destinations.reserve(op->getNumSuccessors()); - SmallVector, 2> operandsPerDestination; + SmallVector, 2> operandsPerDestination; unsigned firstSuccessorOperand = op->getSuccessorOperandIndex(0); for (unsigned i = 0, seen = 0, e = op->getNumSuccessors(); i < e; ++i) { destinations.push_back(op->getSuccessor(i)); @@ -1059,7 +1059,7 @@ OperationLegalizer::legalizeWithFold(Operation *op, RewriterState curState = rewriterImpl.getCurrentState(); // Try to fold the operation. - SmallVector replacementValues; + SmallVector replacementValues; rewriter.setInsertionPoint(op); if (failed(rewriter.tryFold(op, replacementValues))) return failure(); @@ -1459,7 +1459,7 @@ void TypeConverter::SignatureConversion::remapInput(unsigned origInputNo, /// Remap an input of the original signature to another `replacementValue` /// value. This would make the signature converter drop this argument. void TypeConverter::SignatureConversion::remapInput(unsigned origInputNo, - Value *replacementValue) { + ValuePtr replacementValue) { assert(!remappedInputs[origInputNo] && "input has already been remapped"); remappedInputs[origInputNo] = InputMapping{origInputNo, /*size=*/0, replacementValue}; @@ -1528,7 +1528,7 @@ struct FuncOpSignatureConversion : public OpConversionPattern { /// Hook for derived classes to implement combined matching and rewriting. PatternMatchResult - matchAndRewrite(FuncOp funcOp, ArrayRef operands, + matchAndRewrite(FuncOp funcOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { FunctionType type = funcOp.getType(); diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index 5694c990b9b..60f0264eb35 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -172,7 +172,7 @@ public: Node(unsigned id, Operation *op) : id(id), op(op) {} // Returns the load op count for 'memref'. - unsigned getLoadOpCount(Value *memref) { + unsigned getLoadOpCount(ValuePtr memref) { unsigned loadOpCount = 0; for (auto *loadOpInst : loads) { if (memref == cast(loadOpInst).getMemRef()) @@ -182,7 +182,7 @@ public: } // Returns the store op count for 'memref'. - unsigned getStoreOpCount(Value *memref) { + unsigned getStoreOpCount(ValuePtr memref) { unsigned storeOpCount = 0; for (auto *storeOpInst : stores) { if (memref == cast(storeOpInst).getMemRef()) @@ -192,7 +192,7 @@ public: } // Returns all store ops in 'storeOps' which access 'memref'. - void getStoreOpsForMemref(Value *memref, + void getStoreOpsForMemref(ValuePtr memref, SmallVectorImpl *storeOps) { for (auto *storeOpInst : stores) { if (memref == cast(storeOpInst).getMemRef()) @@ -201,7 +201,7 @@ public: } // Returns all load ops in 'loadOps' which access 'memref'. - void getLoadOpsForMemref(Value *memref, + void getLoadOpsForMemref(ValuePtr memref, SmallVectorImpl *loadOps) { for (auto *loadOpInst : loads) { if (memref == cast(loadOpInst).getMemRef()) @@ -211,13 +211,13 @@ public: // Returns all memrefs in 'loadAndStoreMemrefSet' for which this node // has at least one load and store operation. - void getLoadAndStoreMemrefSet(DenseSet *loadAndStoreMemrefSet) { - llvm::SmallDenseSet loadMemrefs; + void getLoadAndStoreMemrefSet(DenseSet *loadAndStoreMemrefSet) { + llvm::SmallDenseSet loadMemrefs; for (auto *loadOpInst : loads) { loadMemrefs.insert(cast(loadOpInst).getMemRef()); } for (auto *storeOpInst : stores) { - auto *memref = cast(storeOpInst).getMemRef(); + auto memref = cast(storeOpInst).getMemRef(); if (loadMemrefs.count(memref) > 0) loadAndStoreMemrefSet->insert(memref); } @@ -239,7 +239,7 @@ public: // defines an SSA value and another graph node which uses the SSA value // (e.g. a constant operation defining a value which is used inside a loop // nest). - Value *value; + ValuePtr value; }; // Map from node id to Node. @@ -250,7 +250,7 @@ public: DenseMap> outEdges; // Map from memref to a count on the dependence edges associated with that // memref. - DenseMap memrefEdgeCount; + DenseMap memrefEdgeCount; // The next unique identifier to use for newly created graph nodes. unsigned nextNodeId = 0; @@ -309,7 +309,7 @@ public: bool writesToLiveInOrEscapingMemrefs(unsigned id) { Node *node = getNode(id); for (auto *storeOpInst : node->stores) { - auto *memref = cast(storeOpInst).getMemRef(); + auto memref = cast(storeOpInst).getMemRef(); auto *op = memref->getDefiningOp(); // Return true if 'memref' is a block argument. if (!op) @@ -338,7 +338,7 @@ public: const auto &nodeOutEdges = outEdgeIt->second; for (auto *op : node->stores) { auto storeOp = cast(op); - auto *memref = storeOp.getMemRef(); + auto memref = storeOp.getMemRef(); // Skip this store if there are no dependences on its memref. This means // that store either: // *) writes to a memref that is only read within the same loop nest @@ -381,7 +381,7 @@ public: // Returns true iff there is an edge from node 'srcId' to node 'dstId' which // is for 'value' if non-null, or for any value otherwise. Returns false // otherwise. - bool hasEdge(unsigned srcId, unsigned dstId, Value *value = nullptr) { + bool hasEdge(unsigned srcId, unsigned dstId, ValuePtr value = nullptr) { if (outEdges.count(srcId) == 0 || inEdges.count(dstId) == 0) { return false; } @@ -395,7 +395,7 @@ public: } // Adds an edge from node 'srcId' to node 'dstId' for 'value'. - void addEdge(unsigned srcId, unsigned dstId, Value *value) { + void addEdge(unsigned srcId, unsigned dstId, ValuePtr value) { if (!hasEdge(srcId, dstId, value)) { outEdges[srcId].push_back({dstId, value}); inEdges[dstId].push_back({srcId, value}); @@ -405,7 +405,7 @@ public: } // Removes an edge from node 'srcId' to node 'dstId' for 'value'. - void removeEdge(unsigned srcId, unsigned dstId, Value *value) { + void removeEdge(unsigned srcId, unsigned dstId, ValuePtr value) { assert(inEdges.count(dstId) > 0); assert(outEdges.count(srcId) > 0); if (value->getType().isa()) { @@ -459,7 +459,7 @@ public: // Returns the input edge count for node 'id' and 'memref' from src nodes // which access 'memref' with a store operation. - unsigned getIncomingMemRefAccesses(unsigned id, Value *memref) { + unsigned getIncomingMemRefAccesses(unsigned id, ValuePtr memref) { unsigned inEdgeCount = 0; if (inEdges.count(id) > 0) for (auto &inEdge : inEdges[id]) @@ -474,7 +474,7 @@ public: // Returns the output edge count for node 'id' and 'memref' (if non-null), // otherwise returns the total output edge count from node 'id'. - unsigned getOutEdgeCount(unsigned id, Value *memref = nullptr) { + unsigned getOutEdgeCount(unsigned id, ValuePtr memref = nullptr) { unsigned outEdgeCount = 0; if (outEdges.count(id) > 0) for (auto &outEdge : outEdges[id]) @@ -548,7 +548,7 @@ public: // Updates edge mappings from node 'srcId' to node 'dstId' after 'oldMemRef' // has been replaced in node at 'dstId' by a private memref depending // on the value of 'createPrivateMemRef'. - void updateEdges(unsigned srcId, unsigned dstId, Value *oldMemRef, + void updateEdges(unsigned srcId, unsigned dstId, ValuePtr oldMemRef, bool createPrivateMemRef) { // For each edge in 'inEdges[srcId]': add new edge remaping to 'dstId'. if (inEdges.count(srcId) > 0) { @@ -681,7 +681,7 @@ public: // TODO(andydavis) Add support for taking a Block arg to construct the // dependence graph at a different depth. bool MemRefDependenceGraph::init(FuncOp f) { - DenseMap> memrefAccesses; + DenseMap> memrefAccesses; // TODO: support multi-block functions. if (f.getBlocks().size() != 1) @@ -701,12 +701,12 @@ bool MemRefDependenceGraph::init(FuncOp f) { Node node(nextNodeId++, &op); for (auto *opInst : collector.loadOpInsts) { node.loads.push_back(opInst); - auto *memref = cast(opInst).getMemRef(); + auto memref = cast(opInst).getMemRef(); memrefAccesses[memref].insert(node.id); } for (auto *opInst : collector.storeOpInsts) { node.stores.push_back(opInst); - auto *memref = cast(opInst).getMemRef(); + auto memref = cast(opInst).getMemRef(); memrefAccesses[memref].insert(node.id); } forToNodeMap[&op] = node.id; @@ -715,14 +715,14 @@ bool MemRefDependenceGraph::init(FuncOp f) { // Create graph node for top-level load op. Node node(nextNodeId++, &op); node.loads.push_back(&op); - auto *memref = cast(op).getMemRef(); + auto memref = cast(op).getMemRef(); memrefAccesses[memref].insert(node.id); nodes.insert({node.id, node}); } else if (auto storeOp = dyn_cast(op)) { // Create graph node for top-level store op. Node node(nextNodeId++, &op); node.stores.push_back(&op); - auto *memref = cast(op).getMemRef(); + auto memref = cast(op).getMemRef(); memrefAccesses[memref].insert(node.id); nodes.insert({node.id, node}); } else if (op.getNumRegions() != 0) { @@ -743,7 +743,7 @@ bool MemRefDependenceGraph::init(FuncOp f) { if (!node.loads.empty() || !node.stores.empty()) continue; auto *opInst = node.op; - for (auto *value : opInst->getResults()) { + for (auto value : opInst->getResults()) { for (auto *user : value->getUsers()) { SmallVector loops; getLoopIVs(*user, &loops); @@ -777,7 +777,7 @@ bool MemRefDependenceGraph::init(FuncOp f) { // Removes load operations from 'srcLoads' which operate on 'memref', and // adds them to 'dstLoads'. -static void moveLoadsAccessingMemrefTo(Value *memref, +static void moveLoadsAccessingMemrefTo(ValuePtr memref, SmallVectorImpl *srcLoads, SmallVectorImpl *dstLoads) { dstLoads->clear(); @@ -893,10 +893,11 @@ static unsigned getMemRefEltSizeInBytes(MemRefType memRefType) { // MemRefRegion written to by 'srcStoreOpInst' at depth 'dstLoopDepth'. // TODO(bondhugula): consider refactoring the common code from generateDma and // this one. -static Value *createPrivateMemRef(AffineForOp forOp, Operation *srcStoreOpInst, - unsigned dstLoopDepth, - Optional fastMemorySpace, - uint64_t localBufSizeThreshold) { +static ValuePtr createPrivateMemRef(AffineForOp forOp, + Operation *srcStoreOpInst, + unsigned dstLoopDepth, + Optional fastMemorySpace, + uint64_t localBufSizeThreshold) { auto *forInst = forOp.getOperation(); // Create builder to insert alloc op just before 'forOp'. @@ -904,7 +905,7 @@ static Value *createPrivateMemRef(AffineForOp forOp, Operation *srcStoreOpInst, // Builder to create constants at the top level. OpBuilder top(forInst->getParentOfType().getBody()); // Create new memref type based on slice bounds. - auto *oldMemRef = cast(srcStoreOpInst).getMemRef(); + auto oldMemRef = cast(srcStoreOpInst).getMemRef(); auto oldMemRefType = oldMemRef->getType().cast(); unsigned rank = oldMemRefType.getRank(); @@ -928,7 +929,7 @@ static Value *createPrivateMemRef(AffineForOp forOp, Operation *srcStoreOpInst, // 'outerIVs' holds the values that this memory region is symbolic/parametric // on; this would correspond to loop IVs surrounding the level at which the // slice is being materialized. - SmallVector outerIVs; + SmallVector outerIVs; cst->getIdValues(rank, cst->getNumIds(), &outerIVs); // Build 'rank' AffineExprs from MemRefRegion 'lbs' @@ -960,7 +961,7 @@ static Value *createPrivateMemRef(AffineForOp forOp, Operation *srcStoreOpInst, auto newMemRefType = MemRefType::get(newShape, oldMemRefType.getElementType(), {}, newMemSpace); // Gather alloc operands for the dynamic dimensions of the memref. - SmallVector allocOperands; + SmallVector allocOperands; unsigned dynamicDimCount = 0; for (auto dimSize : oldMemRefType.getShape()) { if (dimSize == -1) @@ -973,7 +974,7 @@ static Value *createPrivateMemRef(AffineForOp forOp, Operation *srcStoreOpInst, // consumer loop nests to reduce their live range. Currently they are added // at the beginning of the function, because loop nests can be reordered // during the fusion pass. - Value *newMemRef = + ValuePtr newMemRef = top.create(forOp.getLoc(), newMemRefType, allocOperands); // Build an AffineMap to remap access functions based on lower bound offsets. @@ -1016,7 +1017,7 @@ static bool canFuseSrcWhichWritesToLiveOut(unsigned srcId, unsigned dstId, MemRefDependenceGraph *mdg) { assert(srcLiveOutStoreOp && "Expected a valid store op"); auto *dstNode = mdg->getNode(dstId); - Value *memref = srcLiveOutStoreOp.getMemRef(); + ValuePtr memref = srcLiveOutStoreOp.getMemRef(); // Return false if 'srcNode' has more than one output edge on 'memref'. if (mdg->getOutEdgeCount(srcId, memref) > 1) return false; @@ -1495,10 +1496,10 @@ public: SmallVector loads = dstNode->loads; SmallVector dstLoadOpInsts; - DenseSet visitedMemrefs; + DenseSet visitedMemrefs; while (!loads.empty()) { // Get memref of load on top of the stack. - auto *memref = cast(loads.back()).getMemRef(); + auto memref = cast(loads.back()).getMemRef(); if (visitedMemrefs.count(memref) > 0) continue; visitedMemrefs.insert(memref); @@ -1653,7 +1654,7 @@ public: } // TODO(andydavis) Use union of memref write regions to compute // private memref footprint. - auto *newMemRef = createPrivateMemRef( + auto newMemRef = createPrivateMemRef( dstAffineForOp, storesForMemref[0], bestDstLoopDepth, fastMemorySpace, localBufSizeThreshold); visitedMemrefs.insert(newMemRef); @@ -1671,7 +1672,7 @@ public: // Add new load ops to current Node load op list 'loads' to // continue fusing based on new operands. for (auto *loadOpInst : dstLoopCollector.loadOpInsts) { - auto *loadMemRef = cast(loadOpInst).getMemRef(); + auto loadMemRef = cast(loadOpInst).getMemRef(); if (visitedMemrefs.count(loadMemRef) == 0) loads.push_back(loadOpInst); } @@ -1737,10 +1738,10 @@ public: // Attempt to fuse 'dstNode' with sibling nodes in the graph. void fuseWithSiblingNodes(Node *dstNode) { DenseSet visitedSibNodeIds; - std::pair idAndMemref; + std::pair idAndMemref; while (findSiblingNodeToFuse(dstNode, &visitedSibNodeIds, &idAndMemref)) { unsigned sibId = idAndMemref.first; - Value *memref = idAndMemref.second; + ValuePtr memref = idAndMemref.second; // TODO(andydavis) Check that 'sibStoreOpInst' post-dominates all other // stores to the same memref in 'sibNode' loop nest. auto *sibNode = mdg->getNode(sibId); @@ -1804,10 +1805,10 @@ public: // 'idAndMemrefToFuse' on success. Returns false otherwise. bool findSiblingNodeToFuse(Node *dstNode, DenseSet *visitedSibNodeIds, - std::pair *idAndMemrefToFuse) { + std::pair *idAndMemrefToFuse) { // Returns true if 'sibNode' can be fused with 'dstNode' for input reuse // on 'memref'. - auto canFuseWithSibNode = [&](Node *sibNode, Value *memref) { + auto canFuseWithSibNode = [&](Node *sibNode, ValuePtr memref) { // Skip if 'outEdge' is not a read-after-write dependence. // TODO(andydavis) Remove restrict to single load op restriction. if (sibNode->getLoadOpCount(memref) != 1) @@ -1819,15 +1820,15 @@ public: return false; // Skip sib node if it loads to (and stores from) the same memref on // which it also has an input dependence edge. - DenseSet loadAndStoreMemrefSet; + DenseSet loadAndStoreMemrefSet; sibNode->getLoadAndStoreMemrefSet(&loadAndStoreMemrefSet); - if (llvm::any_of(loadAndStoreMemrefSet, [=](Value *memref) { + if (llvm::any_of(loadAndStoreMemrefSet, [=](ValuePtr memref) { return mdg->getIncomingMemRefAccesses(sibNode->id, memref) > 0; })) return false; // Check that all stores are to the same memref. - DenseSet storeMemrefs; + DenseSet storeMemrefs; for (auto *storeOpInst : sibNode->stores) { storeMemrefs.insert(cast(storeOpInst).getMemRef()); } @@ -1856,7 +1857,7 @@ public: if (visitedSibNodeIds->count(sibNode->id) > 0) continue; // Skip 'use' if it does not load from the same memref as 'dstNode'. - auto *memref = loadOp.getMemRef(); + auto memref = loadOp.getMemRef(); if (dstNode->getLoadOpCount(memref) == 0) continue; // Check if 'sibNode/dstNode' can be input-reuse fused on 'memref'. @@ -1950,7 +1951,7 @@ public: for (auto &pair : mdg->memrefEdgeCount) { if (pair.second > 0) continue; - auto *memref = pair.first; + auto memref = pair.first; // Skip if there exist other uses (return operation or function calls). if (!memref->use_empty()) continue; diff --git a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp index 4932494a04b..bd58827d001 100644 --- a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp +++ b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp @@ -50,7 +50,7 @@ public: // - the op has no side-effects. If sideEffecting is Never, sideeffects of this // op and its nested ops are ignored. static bool canBeHoisted(Operation *op, - function_ref definedOutside, + function_ref definedOutside, SideEffecting sideEffecting, SideEffectsInterface &interface) { // Check that dependencies are defined outside of loop. @@ -92,7 +92,7 @@ static LogicalResult moveLoopInvariantCode(LoopLikeOpInterface looplike, SmallVector opsToMove; // Helper to check whether an operation is loop invariant wrt. SSA properties. - auto isDefinedOutsideOfBody = [&](Value *value) { + auto isDefinedOutsideOfBody = [&](ValuePtr value) { auto definingOp = value->getDefiningOp(); return (definingOp && !!willBeMovedSet.count(definingOp)) || looplike.isDefinedOutsideOfLoop(value); diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp index 10654783aa9..361a4d8ecb9 100644 --- a/mlir/lib/Transforms/LoopTiling.cpp +++ b/mlir/lib/Transforms/LoopTiling.cpp @@ -120,8 +120,8 @@ constructTiledIndexSetHyperRect(MutableArrayRef origLoops, for (unsigned i = 0; i < width; i++) { auto lbOperands = origLoops[i].getLowerBoundOperands(); auto ubOperands = origLoops[i].getUpperBoundOperands(); - SmallVector newLbOperands(lbOperands); - SmallVector newUbOperands(ubOperands); + SmallVector newLbOperands(lbOperands); + SmallVector newUbOperands(ubOperands); newLoops[i].setLowerBound(newLbOperands, origLoops[i].getLowerBoundMap()); newLoops[i].setUpperBound(newUbOperands, origLoops[i].getUpperBoundMap()); newLoops[i].setStep(tileSizes[i]); @@ -147,7 +147,7 @@ constructTiledIndexSetHyperRect(MutableArrayRef origLoops, // with 'i' (tile-space loop) appended to it. The new upper bound map is // the original one with an additional expression i + tileSize appended. auto ub = origLoops[i].getUpperBound(); - SmallVector ubOperands; + SmallVector ubOperands; ubOperands.reserve(ub.getNumOperands() + 1); auto origUbMap = ub.getMap(); // Add dim operands from original upper bound. @@ -235,9 +235,10 @@ LogicalResult mlir::tileCodeGen(MutableArrayRef band, // Move the loop body of the original nest to the new one. moveLoopBody(origLoops[origLoops.size() - 1], innermostPointLoop); - SmallVector origLoopIVs; + SmallVector origLoopIVs; extractForInductionVars(band, &origLoopIVs); - SmallVector, 6> ids(origLoopIVs.begin(), origLoopIVs.end()); + SmallVector, 6> ids(origLoopIVs.begin(), + origLoopIVs.end()); FlatAffineConstraints cst; getIndexSet(band, &cst); diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp index 230869abcd5..a857b8ec95a 100644 --- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp +++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp @@ -191,7 +191,7 @@ LogicalResult mlir::loopUnrollJamByFactor(AffineForOp forOp, // Adjust the lower bound of the cleanup loop; its upper bound is the same // as the original loop's upper bound. AffineMap cleanupMap; - SmallVector cleanupOperands; + SmallVector cleanupOperands; getCleanupLoopLowerBound(forOp, unrollJamFactor, &cleanupMap, &cleanupOperands, builder); cleanupAffineForOp.setLowerBound(cleanupOperands, cleanupMap); @@ -208,7 +208,7 @@ LogicalResult mlir::loopUnrollJamByFactor(AffineForOp forOp, int64_t step = forOp.getStep(); forOp.setStep(step * unrollJamFactor); - auto *forOpIV = forOp.getInductionVar(); + auto forOpIV = forOp.getInductionVar(); // Unroll and jam (appends unrollJamFactor - 1 additional copies). for (unsigned i = unrollJamFactor - 1; i >= 1; --i) { // Operand map persists across all sub-blocks. diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp index c531ca551b4..0695aafe171 100644 --- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp +++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp @@ -76,7 +76,7 @@ struct MemRefDataFlowOpt : public FunctionPass { void forwardStoreToLoad(AffineLoadOp loadOp); // A list of memref's that are potentially dead / could be eliminated. - SmallPtrSet memrefsToErase; + SmallPtrSet memrefsToErase; // Load op's whose results were replaced by those forwarded from stores. SmallVector loadOpsToErase; @@ -180,7 +180,7 @@ void MemRefDataFlowOpt::forwardStoreToLoad(AffineLoadOp loadOp) { return; // Perform the actual store to load forwarding. - Value *storeVal = cast(lastWriteStoreOp).getValueToStore(); + ValuePtr storeVal = cast(lastWriteStoreOp).getValueToStore(); loadOp.replaceAllUsesWith(storeVal); // Record the memref for a later sweep to optimize away. memrefsToErase.insert(loadOp.getMemRef()); @@ -213,7 +213,7 @@ void MemRefDataFlowOpt::runOnFunction() { // Check if the store fwd'ed memrefs are now left with only stores and can // thus be completely deleted. Note: the canonicalize pass should be able // to do this as well, but we'll do it here since we collected these anyway. - for (auto *memref : memrefsToErase) { + for (auto memref : memrefsToErase) { // If the memref hasn't been alloc'ed in this function, skip. Operation *defInst = memref->getDefiningOp(); if (!defInst || !isa(defInst)) diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp index fdf01351549..4162936ea2d 100644 --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -70,7 +70,7 @@ static unsigned getTagMemRefPos(Operation &dmaInst) { /// Replaces all uses of the old memref by the new one while indexing the newly /// added dimension by the loop IV of the specified 'affine.for' operation /// modulo 2. Returns false if such a replacement cannot be performed. -static bool doubleBuffer(Value *oldMemRef, AffineForOp forOp) { +static bool doubleBuffer(ValuePtr oldMemRef, AffineForOp forOp) { auto *forBody = forOp.getBody(); OpBuilder bInner(forBody, forBody->begin()); @@ -94,7 +94,7 @@ static bool doubleBuffer(Value *oldMemRef, AffineForOp forOp) { auto *forInst = forOp.getOperation(); OpBuilder bOuter(forInst); // Put together alloc operands for any dynamic dimensions of the memref. - SmallVector allocOperands; + SmallVector allocOperands; unsigned dynamicDimCount = 0; for (auto dimSize : oldMemRefType.getShape()) { if (dimSize == -1) @@ -103,7 +103,7 @@ static bool doubleBuffer(Value *oldMemRef, AffineForOp forOp) { } // Create and place the alloc right before the 'affine.for' operation. - Value *newMemRef = + ValuePtr newMemRef = bOuter.create(forInst->getLoc(), newMemRefType, allocOperands); // Create 'iv mod 2' value to index the leading dimension. @@ -212,7 +212,7 @@ static void findMatchingStartFinishInsts( continue; // We only double buffer if the buffer is not live out of loop. - auto *memref = dmaStartOp.getOperand(dmaStartOp.getFasterMemPos()); + auto memref = dmaStartOp.getOperand(dmaStartOp.getFasterMemPos()); bool escapingUses = false; for (auto *user : memref->getUsers()) { // We can double buffer regardless of dealloc's outside the loop. @@ -270,7 +270,7 @@ void PipelineDataTransfer::runOnAffineForOp(AffineForOp forOp) { // dimension. for (auto &pair : startWaitPairs) { auto *dmaStartInst = pair.first; - Value *oldMemRef = dmaStartInst->getOperand( + ValuePtr oldMemRef = dmaStartInst->getOperand( cast(dmaStartInst).getFasterMemPos()); if (!doubleBuffer(oldMemRef, forOp)) { // Normally, double buffering should not fail because we already checked @@ -301,7 +301,7 @@ void PipelineDataTransfer::runOnAffineForOp(AffineForOp forOp) { // Double the buffers for tag memrefs. for (auto &pair : startWaitPairs) { auto *dmaFinishInst = pair.second; - Value *oldTagMemRef = + ValuePtr oldTagMemRef = dmaFinishInst->getOperand(getTagMemRefPos(*dmaFinishInst)); if (!doubleBuffer(oldTagMemRef, forOp)) { LLVM_DEBUG(llvm::dbgs() << "tag double buffering failed\n";); @@ -342,7 +342,7 @@ void PipelineDataTransfer::runOnAffineForOp(AffineForOp forOp) { // If a slice wasn't created, the reachable affine.apply op's from its // operands are the ones that go with it. SmallVector affineApplyInsts; - SmallVector operands(dmaStartInst->getOperands()); + SmallVector operands(dmaStartInst->getOperands()); getReachableAffineApplyOps(operands, affineApplyInsts); for (auto *op : affineApplyInsts) { instShiftMap[op] = 0; diff --git a/mlir/lib/Transforms/Utils/FoldUtils.cpp b/mlir/lib/Transforms/Utils/FoldUtils.cpp index d4b7caae527..85d1f21305e 100644 --- a/mlir/lib/Transforms/Utils/FoldUtils.cpp +++ b/mlir/lib/Transforms/Utils/FoldUtils.cpp @@ -90,7 +90,7 @@ LogicalResult OperationFolder::tryToFold( return failure(); // Try to fold the operation. - SmallVector results; + SmallVector results; if (failed(tryToFold(op, results, processGeneratedConstants))) return failure(); @@ -138,7 +138,7 @@ void OperationFolder::notifyRemoval(Operation *op) { /// Tries to perform folding on the given `op`. If successful, populates /// `results` with the results of the folding. LogicalResult OperationFolder::tryToFold( - Operation *op, SmallVectorImpl &results, + Operation *op, SmallVectorImpl &results, function_ref processGeneratedConstants) { SmallVector operandConstants; SmallVector foldResults; @@ -181,13 +181,13 @@ LogicalResult OperationFolder::tryToFold( assert(!foldResults[i].isNull() && "expected valid OpFoldResult"); // Check if the result was an SSA value. - if (auto *repl = foldResults[i].dyn_cast()) { + if (auto repl = foldResults[i].dyn_cast()) { results.emplace_back(repl); continue; } // Check to see if there is a canonicalized version of this constant. - auto *res = op->getResult(i); + auto res = op->getResult(i); Attribute attrRepl = foldResults[i].get(); if (auto *constOp = tryGetOrCreateConstant(uniquedConstants, dialect, builder, attrRepl, diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp index e2ca3f8fc5e..fe4a6f9f9e0 100644 --- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp +++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp @@ -107,7 +107,7 @@ protected: // simplifications to its users - make sure to add them to the worklist // before the root is changed. void notifyRootReplaced(Operation *op) override { - for (auto *result : op->getResults()) + for (auto result : op->getResults()) for (auto *user : result->getUsers()) addToWorklist(user); } @@ -118,7 +118,7 @@ private: // operation is modified or removed, as it may trigger further // simplifications. template void addToWorklist(Operands &&operands) { - for (Value *operand : operands) { + for (ValuePtr operand : operands) { // If the use count of this operand is now < 2, we re-add the defining // operation to the worklist. // TODO(riverriddle) This is based on the fact that zero use operations @@ -160,7 +160,7 @@ bool GreedyPatternRewriteDriver::simplify(MutableArrayRef regions, region.walk(collectOps); // These are scratch vectors used in the folding loop below. - SmallVector originalOperands, resultValues; + SmallVector originalOperands, resultValues; changed = false; while (!worklist.empty()) { @@ -189,7 +189,7 @@ bool GreedyPatternRewriteDriver::simplify(MutableArrayRef regions, // Add all the users of the result to the worklist so we make sure // to revisit them. - for (auto *result : op->getResults()) + for (auto result : op->getResults()) for (auto *operand : result->getUsers()) addToWorklist(operand); diff --git a/mlir/lib/Transforms/Utils/InliningUtils.cpp b/mlir/lib/Transforms/Utils/InliningUtils.cpp index e8466aa3fd6..048130c0d3a 100644 --- a/mlir/lib/Transforms/Utils/InliningUtils.cpp +++ b/mlir/lib/Transforms/Utils/InliningUtils.cpp @@ -55,7 +55,7 @@ static void remapInlinedOperands(iterator_range inlinedBlocks, BlockAndValueMapping &mapper) { auto remapOperands = [&](Operation *op) { for (auto &operand : op->getOpOperands()) - if (auto *mappedOp = mapper.lookupOrNull(operand.get())) + if (auto mappedOp = mapper.lookupOrNull(operand.get())) operand.set(mappedOp); }; for (auto &block : inlinedBlocks) @@ -98,7 +98,7 @@ void InlinerInterface::handleTerminator(Operation *op, Block *newDest) const { /// Handle the given inlined terminator by replacing it with a new operation /// as necessary. void InlinerInterface::handleTerminator(Operation *op, - ArrayRef valuesToRepl) const { + ArrayRef valuesToRepl) const { auto *handler = getInterfaceFor(op); assert(handler && "expected valid dialect handler"); handler->handleTerminator(op, valuesToRepl); @@ -137,7 +137,7 @@ static bool isLegalToInline(InlinerInterface &interface, Region *src, LogicalResult mlir::inlineRegion(InlinerInterface &interface, Region *src, Operation *inlinePoint, BlockAndValueMapping &mapper, - ArrayRef resultsToReplace, + ArrayRef resultsToReplace, Optional inlineLoc, bool shouldCloneInlinedRegion) { // We expect the region to have at least one block. @@ -147,7 +147,7 @@ LogicalResult mlir::inlineRegion(InlinerInterface &interface, Region *src, // Check that all of the region arguments have been mapped. auto *srcEntryBlock = &src->front(); if (llvm::any_of(srcEntryBlock->getArguments(), - [&](BlockArgument *arg) { return !mapper.contains(arg); })) + [&](BlockArgumentPtr arg) { return !mapper.contains(arg); })) return failure(); // The insertion point must be within a block. @@ -207,7 +207,7 @@ LogicalResult mlir::inlineRegion(InlinerInterface &interface, Region *src, } else { // Otherwise, there were multiple blocks inlined. Add arguments to the post // insertion block to represent the results to replace. - for (Value *resultToRepl : resultsToReplace) { + for (ValuePtr resultToRepl : resultsToReplace) { resultToRepl->replaceAllUsesWith( postInsertBlock->addArgument(resultToRepl->getType())); } @@ -229,8 +229,8 @@ LogicalResult mlir::inlineRegion(InlinerInterface &interface, Region *src, /// in-favor of the region arguments when inlining. LogicalResult mlir::inlineRegion(InlinerInterface &interface, Region *src, Operation *inlinePoint, - ArrayRef inlinedOperands, - ArrayRef resultsToReplace, + ArrayRef inlinedOperands, + ArrayRef resultsToReplace, Optional inlineLoc, bool shouldCloneInlinedRegion) { // We expect the region to have at least one block. @@ -246,7 +246,7 @@ LogicalResult mlir::inlineRegion(InlinerInterface &interface, Region *src, for (unsigned i = 0, e = inlinedOperands.size(); i != e; ++i) { // Verify that the types of the provided values match the function argument // types. - BlockArgument *regionArg = entryBlock->getArgument(i); + BlockArgumentPtr regionArg = entryBlock->getArgument(i); if (inlinedOperands[i]->getType() != regionArg->getType()) return failure(); mapper.map(regionArg, inlinedOperands[i]); @@ -259,10 +259,10 @@ LogicalResult mlir::inlineRegion(InlinerInterface &interface, Region *src, /// Utility function used to generate a cast operation from the given interface, /// or return nullptr if a cast could not be generated. -static Value *materializeConversion(const DialectInlinerInterface *interface, - SmallVectorImpl &castOps, - OpBuilder &castBuilder, Value *arg, - Type type, Location conversionLoc) { +static ValuePtr materializeConversion(const DialectInlinerInterface *interface, + SmallVectorImpl &castOps, + OpBuilder &castBuilder, ValuePtr arg, + Type type, Location conversionLoc) { if (!interface) return nullptr; @@ -297,8 +297,8 @@ LogicalResult mlir::inlineCall(InlinerInterface &interface, // Make sure that the number of arguments and results matchup between the call // and the region. - SmallVector callOperands(call.getArgOperands()); - SmallVector callResults(call.getOperation()->getResults()); + SmallVector callOperands(call.getArgOperands()); + SmallVector callResults(call.getOperation()->getResults()); if (callOperands.size() != entryBlock->getNumArguments() || callResults.size() != callableResultTypes.size()) return failure(); @@ -325,8 +325,8 @@ LogicalResult mlir::inlineCall(InlinerInterface &interface, // Map the provided call operands to the arguments of the region. BlockAndValueMapping mapper; for (unsigned i = 0, e = callOperands.size(); i != e; ++i) { - BlockArgument *regionArg = entryBlock->getArgument(i); - Value *operand = callOperands[i]; + BlockArgumentPtr regionArg = entryBlock->getArgument(i); + ValuePtr operand = callOperands[i]; // If the call operand doesn't match the expected region argument, try to // generate a cast. @@ -342,13 +342,13 @@ LogicalResult mlir::inlineCall(InlinerInterface &interface, // Ensure that the resultant values of the call, match the callable. castBuilder.setInsertionPointAfter(call); for (unsigned i = 0, e = callResults.size(); i != e; ++i) { - Value *callResult = callResults[i]; + ValuePtr callResult = callResults[i]; if (callResult->getType() == callableResultTypes[i]) continue; // Generate a conversion that will produce the original type, so that the IR // is still valid after the original call gets replaced. - Value *castResult = + ValuePtr castResult = materializeConversion(callInterface, castOps, castBuilder, callResult, callResult->getType(), castLoc); if (!castResult) diff --git a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp index fd803390ce7..d5cda3265de 100644 --- a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp @@ -45,7 +45,7 @@ using namespace mlir; // Gathers all load and store memref accesses in 'opA' into 'values', where // 'values[memref] == true' for each store operation. static void getLoadAndStoreMemRefAccesses(Operation *opA, - DenseMap &values) { + DenseMap &values) { opA->walk([&](Operation *op) { if (auto loadOp = dyn_cast(op)) { if (values.count(loadOp.getMemRef()) == 0) @@ -60,7 +60,7 @@ static void getLoadAndStoreMemRefAccesses(Operation *opA, // accessed 'values' and at least one of the access is a store operation. // Returns false otherwise. static bool isDependentLoadOrStoreOp(Operation *op, - DenseMap &values) { + DenseMap &values) { if (auto loadOp = dyn_cast(op)) { return values.count(loadOp.getMemRef()) > 0 && values[loadOp.getMemRef()] == true; @@ -75,7 +75,7 @@ static bool isDependentLoadOrStoreOp(Operation *op, static Operation *getFirstDependentOpInRange(Operation *opA, Operation *opB) { // Record memref values from all loads/store in loop nest rooted at 'opA'. // Map from memref value to bool which is true if store, false otherwise. - DenseMap values; + DenseMap values; getLoadAndStoreMemRefAccesses(opA, values); // For each 'opX' in block in range ('opA', 'opB'), check if there is a data @@ -101,7 +101,7 @@ static Operation *getFirstDependentOpInRange(Operation *opA, Operation *opB) { static Operation *getLastDependentOpInRange(Operation *opA, Operation *opB) { // Record memref values from all loads/store in loop nest rooted at 'opB'. // Map from memref value to bool which is true if store, false otherwise. - DenseMap values; + DenseMap values; getLoadAndStoreMemRefAccesses(opB, values); // For each 'opX' in block in range ('opA', 'opB') in reverse order, @@ -121,8 +121,8 @@ static Operation *getLastDependentOpInRange(Operation *opA, Operation *opB) { } return WalkResult::advance(); } - for (auto *value : op->getResults()) { - for (auto *user : value->getUsers()) { + for (auto value : op->getResults()) { + for (auto user : value->getUsers()) { SmallVector loops; // Check if any loop in loop nest surrounding 'user' is 'opB'. getLoopIVs(*user, &loops); @@ -443,7 +443,7 @@ bool mlir::getFusionComputeCost(AffineForOp srcForOp, LoopNestStats &srcStats, // Subtract from operation count the loads/store we expect load/store // forwarding to remove. unsigned storeCount = 0; - llvm::SmallDenseSet storeMemrefs; + llvm::SmallDenseSet storeMemrefs; srcForOp.walk([&](Operation *op) { if (auto storeOp = dyn_cast(op)) { storeMemrefs.insert(storeOp.getMemRef()); @@ -455,7 +455,7 @@ bool mlir::getFusionComputeCost(AffineForOp srcForOp, LoopNestStats &srcStats, computeCostMap[insertPointParent] = -storeCount; // Subtract out any load users of 'storeMemrefs' nested below // 'insertPointParent'. - for (auto *value : storeMemrefs) { + for (auto value : storeMemrefs) { for (auto *user : value->getUsers()) { if (auto loadOp = dyn_cast(user)) { SmallVector loops; diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index 3691aee4870..bc1ced408a9 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -52,7 +52,7 @@ using llvm::SmallMapVector; /// expression. void mlir::getCleanupLoopLowerBound(AffineForOp forOp, unsigned unrollFactor, AffineMap *map, - SmallVectorImpl *operands, + SmallVectorImpl *operands, OpBuilder &b) { auto lbMap = forOp.getLowerBoundMap(); @@ -63,7 +63,7 @@ void mlir::getCleanupLoopLowerBound(AffineForOp forOp, unsigned unrollFactor, } AffineMap tripCountMap; - SmallVector tripCountOperands; + SmallVector tripCountOperands; buildTripCountMapAndOperands(forOp, &tripCountMap, &tripCountOperands); // Sometimes the trip count cannot be expressed as an affine expression. @@ -82,7 +82,7 @@ void mlir::getCleanupLoopLowerBound(AffineForOp forOp, unsigned unrollFactor, // lb + tr1 - tr1 % ufactor, lb + tr2 - tr2 % ufactor; the results of all // these affine.apply's make up the cleanup loop lower bound. SmallVector bumpExprs(tripCountMap.getNumResults()); - SmallVector bumpValues(tripCountMap.getNumResults()); + SmallVector bumpValues(tripCountMap.getNumResults()); for (unsigned i = 0, e = tripCountMap.getNumResults(); i < e; i++) { auto tripCountExpr = tripCountMap.getResult(i); bumpExprs[i] = (tripCountExpr - tripCountExpr % unrollFactor) * step; @@ -105,7 +105,7 @@ void mlir::getCleanupLoopLowerBound(AffineForOp forOp, unsigned unrollFactor, *map = simplifyAffineMap(*map); canonicalizeMapAndOperands(map, operands); // Remove any affine.apply's that became dead from the simplification above. - for (auto *v : bumpValues) { + for (auto v : bumpValues) { if (v->use_empty()) { v->getDefiningOp()->erase(); } @@ -127,7 +127,7 @@ LogicalResult mlir::promoteIfSingleIteration(AffineForOp forOp) { return failure(); // Replaces all IV uses to its single iteration value. - auto *iv = forOp.getInductionVar(); + auto iv = forOp.getInductionVar(); Operation *op = forOp.getOperation(); if (!iv->use_empty()) { if (forOp.hasConstantLowerBound()) { @@ -137,7 +137,7 @@ LogicalResult mlir::promoteIfSingleIteration(AffineForOp forOp) { iv->replaceAllUsesWith(constOp); } else { AffineBound lb = forOp.getLowerBound(); - SmallVector lbOperands(lb.operand_begin(), lb.operand_end()); + SmallVector lbOperands(lb.operand_begin(), lb.operand_end()); OpBuilder builder(op->getBlock(), Block::iterator(op)); if (lb.getMap() == builder.getDimIdentityMap()) { // No need of generating an affine.apply. @@ -178,8 +178,8 @@ generateLoop(AffineMap lbMap, AffineMap ubMap, const std::vector>> &instGroupQueue, unsigned offset, AffineForOp srcForInst, OpBuilder b) { - SmallVector lbOperands(srcForInst.getLowerBoundOperands()); - SmallVector ubOperands(srcForInst.getUpperBoundOperands()); + SmallVector lbOperands(srcForInst.getLowerBoundOperands()); + SmallVector ubOperands(srcForInst.getUpperBoundOperands()); assert(lbMap.getNumInputs() == lbOperands.size()); assert(ubMap.getNumInputs() == ubOperands.size()); @@ -187,8 +187,8 @@ generateLoop(AffineMap lbMap, AffineMap ubMap, auto loopChunk = b.create(srcForInst.getLoc(), lbOperands, lbMap, ubOperands, ubMap, srcForInst.getStep()); - auto *loopChunkIV = loopChunk.getInductionVar(); - auto *srcIV = srcForInst.getInductionVar(); + auto loopChunkIV = loopChunk.getInductionVar(); + auto srcIV = srcForInst.getInductionVar(); BlockAndValueMapping operandMap; @@ -449,7 +449,7 @@ LogicalResult mlir::loopUnrollByFactor(AffineForOp forOp, OpBuilder builder(op->getBlock(), ++Block::iterator(op)); auto cleanupForInst = cast(builder.clone(*op)); AffineMap cleanupMap; - SmallVector cleanupOperands; + SmallVector cleanupOperands; getCleanupLoopLowerBound(forOp, unrollFactor, &cleanupMap, &cleanupOperands, builder); assert(cleanupMap && @@ -477,7 +477,7 @@ LogicalResult mlir::loopUnrollByFactor(AffineForOp forOp, Block::iterator srcBlockEnd = std::prev(forOp.getBody()->end(), 2); // Unroll the contents of 'forOp' (append unrollFactor-1 additional copies). - auto *forOpIV = forOp.getInductionVar(); + auto forOpIV = forOp.getInductionVar(); for (unsigned i = 1; i < unrollFactor; i++) { BlockAndValueMapping operandMap; @@ -669,8 +669,8 @@ void mlir::sinkLoop(AffineForOp forOp, unsigned loopDepth) { // ... // } // ``` -static void augmentMapAndBounds(OpBuilder &b, Value *iv, AffineMap *map, - SmallVector *operands, +static void augmentMapAndBounds(OpBuilder &b, ValuePtr iv, AffineMap *map, + SmallVector *operands, int64_t offset = 0) { auto bounds = llvm::to_vector<4>(map->getResults()); bounds.push_back(b.getAffineDimExpr(map->getNumDims()) + offset); @@ -699,16 +699,16 @@ stripmineSink(AffineForOp forOp, uint64_t factor, // Lower-bound map creation. auto lbMap = forOp.getLowerBoundMap(); - SmallVector lbOperands(forOp.getLowerBoundOperands()); + SmallVector lbOperands(forOp.getLowerBoundOperands()); augmentMapAndBounds(b, forOp.getInductionVar(), &lbMap, &lbOperands); // Upper-bound map creation. auto ubMap = forOp.getUpperBoundMap(); - SmallVector ubOperands(forOp.getUpperBoundOperands()); + SmallVector ubOperands(forOp.getUpperBoundOperands()); augmentMapAndBounds(b, forOp.getInductionVar(), &ubMap, &ubOperands, /*offset=*/scaledStep); - auto *iv = forOp.getInductionVar(); + auto iv = forOp.getInductionVar(); SmallVector innerLoops; for (auto t : targets) { // Insert newForOp before the terminator of `t`. @@ -729,10 +729,10 @@ stripmineSink(AffineForOp forOp, uint64_t factor, return innerLoops; } -static Loops stripmineSink(loop::ForOp forOp, Value *factor, +static Loops stripmineSink(loop::ForOp forOp, ValuePtr factor, ArrayRef targets) { - auto *originalStep = forOp.step(); - auto *iv = forOp.getInductionVar(); + auto originalStep = forOp.step(); + auto iv = forOp.getInductionVar(); OpBuilder b(forOp); forOp.setStep(b.create(forOp.getLoc(), originalStep, factor)); @@ -745,10 +745,10 @@ static Loops stripmineSink(loop::ForOp forOp, Value *factor, // Insert newForOp before the terminator of `t`. OpBuilder b(t.getBodyBuilder()); - Value *stepped = b.create(t.getLoc(), iv, forOp.step()); - Value *less = b.create(t.getLoc(), CmpIPredicate::slt, - forOp.upperBound(), stepped); - Value *ub = + ValuePtr stepped = b.create(t.getLoc(), iv, forOp.step()); + ValuePtr less = b.create(t.getLoc(), CmpIPredicate::slt, + forOp.upperBound(), stepped); + ValuePtr ub = b.create(t.getLoc(), less, forOp.upperBound(), stepped); // Splice [begin, begin + nOps - 1) into `newForOp` and replace uses. @@ -799,7 +799,7 @@ mlir::tile(ArrayRef forOps, ArrayRef sizes, } SmallVector mlir::tile(ArrayRef forOps, - ArrayRef sizes, + ArrayRef sizes, ArrayRef targets) { return tileImpl(forOps, sizes, targets); } @@ -821,13 +821,13 @@ SmallVector mlir::tile(ArrayRef forOps, return tileImpl(forOps, sizes, target); } -Loops mlir::tile(ArrayRef forOps, ArrayRef sizes, +Loops mlir::tile(ArrayRef forOps, ArrayRef sizes, loop::ForOp target) { return tileImpl(forOps, sizes, target); } Loops mlir::tilePerfectlyNested(loop::ForOp rootForOp, - ArrayRef sizes) { + ArrayRef sizes) { // Collect perfectly nested loops. If more size values provided than nested // loops available, truncate `sizes`. SmallVector forOps; @@ -842,14 +842,15 @@ Loops mlir::tilePerfectlyNested(loop::ForOp rootForOp, // Build the IR that performs ceil division of a positive value by a constant: // ceildiv(a, B) = divis(a + (B-1), B) // where divis is rounding-to-zero division. -static Value *ceilDivPositive(OpBuilder &builder, Location loc, Value *dividend, - int64_t divisor) { +static ValuePtr ceilDivPositive(OpBuilder &builder, Location loc, + ValuePtr dividend, int64_t divisor) { assert(divisor > 0 && "expected positive divisor"); assert(dividend->getType().isIndex() && "expected index-typed value"); - Value *divisorMinusOneCst = builder.create(loc, divisor - 1); - Value *divisorCst = builder.create(loc, divisor); - Value *sum = builder.create(loc, dividend, divisorMinusOneCst); + ValuePtr divisorMinusOneCst = + builder.create(loc, divisor - 1); + ValuePtr divisorCst = builder.create(loc, divisor); + ValuePtr sum = builder.create(loc, dividend, divisorMinusOneCst); return builder.create(loc, sum, divisorCst); } @@ -857,13 +858,13 @@ static Value *ceilDivPositive(OpBuilder &builder, Location loc, Value *dividend, // positive value: // ceildiv(a, b) = divis(a + (b - 1), b) // where divis is rounding-to-zero division. -static Value *ceilDivPositive(OpBuilder &builder, Location loc, Value *dividend, - Value *divisor) { +static ValuePtr ceilDivPositive(OpBuilder &builder, Location loc, + ValuePtr dividend, ValuePtr divisor) { assert(dividend->getType().isIndex() && "expected index-typed value"); - Value *cstOne = builder.create(loc, 1); - Value *divisorMinusOne = builder.create(loc, divisor, cstOne); - Value *sum = builder.create(loc, dividend, divisorMinusOne); + ValuePtr cstOne = builder.create(loc, 1); + ValuePtr divisorMinusOne = builder.create(loc, divisor, cstOne); + ValuePtr sum = builder.create(loc, dividend, divisorMinusOne); return builder.create(loc, sum, divisor); } @@ -945,7 +946,7 @@ TileLoops mlir::extractFixedOuterLoops(loop::ForOp rootForOp, // iterations. Given that the loop current executes // numIterations = ceildiv((upperBound - lowerBound), step) // iterations, we need to tile with size ceildiv(numIterations, size[i]). - SmallVector tileSizes; + SmallVector tileSizes; tileSizes.reserve(sizes.size()); for (unsigned i = 0, e = sizes.size(); i < e; ++i) { assert(sizes[i] > 0 && "expected strictly positive size for strip-mining"); @@ -953,10 +954,10 @@ TileLoops mlir::extractFixedOuterLoops(loop::ForOp rootForOp, auto forOp = forOps[i]; OpBuilder builder(forOp); auto loc = forOp.getLoc(); - Value *diff = + ValuePtr diff = builder.create(loc, forOp.upperBound(), forOp.lowerBound()); - Value *numIterations = ceilDivPositive(builder, loc, diff, forOp.step()); - Value *iterationsPerBlock = + ValuePtr numIterations = ceilDivPositive(builder, loc, diff, forOp.step()); + ValuePtr iterationsPerBlock = ceilDivPositive(builder, loc, numIterations, sizes[i]); tileSizes.push_back(iterationsPerBlock); } @@ -976,7 +977,7 @@ TileLoops mlir::extractFixedOuterLoops(loop::ForOp rootForOp, // Replaces all uses of `orig` with `replacement` except if the user is listed // in `exceptions`. static void -replaceAllUsesExcept(Value *orig, Value *replacement, +replaceAllUsesExcept(ValuePtr orig, ValuePtr replacement, const SmallPtrSetImpl &exceptions) { for (auto &use : llvm::make_early_inc_range(orig->getUses())) { if (exceptions.count(use.getOwner()) == 0) @@ -1018,30 +1019,30 @@ static void normalizeLoop(loop::ForOp loop, loop::ForOp outer, // of the loop to go from 0 to the number of iterations, if necessary. // TODO(zinenko): introduce support for negative steps or emit dynamic asserts // on step positivity, whatever gets implemented first. - Value *diff = + ValuePtr diff = builder.create(loc, loop.upperBound(), loop.lowerBound()); - Value *numIterations = ceilDivPositive(builder, loc, diff, loop.step()); + ValuePtr numIterations = ceilDivPositive(builder, loc, diff, loop.step()); loop.setUpperBound(numIterations); - Value *lb = loop.lowerBound(); + ValuePtr lb = loop.lowerBound(); if (!isZeroBased) { - Value *cst0 = builder.create(loc, 0); + ValuePtr cst0 = builder.create(loc, 0); loop.setLowerBound(cst0); } - Value *step = loop.step(); + ValuePtr step = loop.step(); if (!isStepOne) { - Value *cst1 = builder.create(loc, 1); + ValuePtr cst1 = builder.create(loc, 1); loop.setStep(cst1); } // Insert code computing the value of the original loop induction variable // from the "normalized" one. builder.setInsertionPointToStart(inner.getBody()); - Value *scaled = + ValuePtr scaled = isStepOne ? loop.getInductionVar() : builder.create(loc, loop.getInductionVar(), step); - Value *shifted = + ValuePtr shifted = isZeroBased ? scaled : builder.create(loc, scaled, lb); SmallPtrSet preserve{scaled->getDefiningOp(), @@ -1065,7 +1066,7 @@ void mlir::coalesceLoops(MutableArrayRef loops) { // of the number of iterations of all loops. OpBuilder builder(outermost); Location loc = outermost.getLoc(); - Value *upperBound = outermost.upperBound(); + ValuePtr upperBound = outermost.upperBound(); for (auto loop : loops.drop_front()) upperBound = builder.create(loc, upperBound, loop.upperBound()); outermost.setUpperBound(upperBound); @@ -1080,16 +1081,16 @@ void mlir::coalesceLoops(MutableArrayRef loops) { // iv_i = floordiv(iv_linear, product-of-loop-ranges-until-i) mod range_i. // Compute these iteratively from the innermost loop by creating a "running // quotient" of division by the range. - Value *previous = outermost.getInductionVar(); + ValuePtr previous = outermost.getInductionVar(); for (unsigned i = 0, e = loops.size(); i < e; ++i) { unsigned idx = loops.size() - i - 1; if (i != 0) previous = builder.create(loc, previous, loops[idx + 1].upperBound()); - Value *iv = (i == e - 1) ? previous - : builder.create( - loc, previous, loops[idx].upperBound()); + ValuePtr iv = (i == e - 1) ? previous + : builder.create( + loc, previous, loops[idx].upperBound()); replaceAllUsesInRegionWith(loops[idx].getInductionVar(), iv, loops.back().region()); } @@ -1105,24 +1106,24 @@ void mlir::coalesceLoops(MutableArrayRef loops) { } void mlir::mapLoopToProcessorIds(loop::ForOp forOp, - ArrayRef processorId, - ArrayRef numProcessors) { + ArrayRef processorId, + ArrayRef numProcessors) { assert(processorId.size() == numProcessors.size()); if (processorId.empty()) return; OpBuilder b(forOp); Location loc(forOp.getLoc()); - Value *mul = processorId.front(); + ValuePtr mul = processorId.front(); for (unsigned i = 1, e = processorId.size(); i < e; ++i) mul = b.create(loc, b.create(loc, mul, numProcessors[i]), processorId[i]); - Value *lb = b.create(loc, forOp.lowerBound(), - b.create(loc, forOp.step(), mul)); + ValuePtr lb = b.create(loc, forOp.lowerBound(), + b.create(loc, forOp.step(), mul)); forOp.setLowerBound(lb); - Value *step = forOp.step(); - for (auto *numProcs : numProcessors) + ValuePtr step = forOp.step(); + for (auto numProcs : numProcessors) step = b.create(loc, step, numProcs); forOp.setStep(step); } @@ -1139,7 +1140,7 @@ findHighestBlockForPlacement(const MemRefRegion ®ion, Block &block, Block::iterator *copyInPlacementStart, Block::iterator *copyOutPlacementStart) { const auto *cst = region.getConstraints(); - SmallVector symbols; + SmallVector symbols; cst->getIdValues(cst->getNumDimIds(), cst->getNumDimAndSymbolIds(), &symbols); SmallVector enclosingFors; @@ -1202,10 +1203,10 @@ static void getMultiLevelStrides(const MemRefRegion ®ion, /// returns the outermost AffineForOp of the copy loop nest. `memIndicesStart' /// holds the lower coordinates of the region in the original memref to copy /// in/out. If `copyOut' is true, generates a copy-out; otherwise a copy-in. -static AffineForOp generatePointWiseCopy(Location loc, Value *memref, - Value *fastMemRef, +static AffineForOp generatePointWiseCopy(Location loc, ValuePtr memref, + ValuePtr fastMemRef, AffineMap memAffineMap, - ArrayRef memIndicesStart, + ArrayRef memIndicesStart, ArrayRef fastBufferShape, bool isCopyOut, OpBuilder b) { assert(!memIndicesStart.empty() && "only 1-d or more memrefs"); @@ -1215,7 +1216,7 @@ static AffineForOp generatePointWiseCopy(Location loc, Value *memref, // for y = ... // fast_buf[x][y] = buf[mem_x + x][mem_y + y] - SmallVector fastBufIndices, memIndices; + SmallVector fastBufIndices, memIndices; AffineForOp copyNestRoot; for (unsigned d = 0, e = fastBufferShape.size(); d < e; ++d) { auto forOp = b.create(loc, 0, fastBufferShape[d]); @@ -1224,7 +1225,7 @@ static AffineForOp generatePointWiseCopy(Location loc, Value *memref, b = forOp.getBodyBuilder(); fastBufIndices.push_back(forOp.getInductionVar()); - Value *memBase = + ValuePtr memBase = (memAffineMap == b.getMultiDimIdentityMap(memAffineMap.getNumDims())) ? memIndicesStart[d] : b.create( @@ -1277,7 +1278,7 @@ static LogicalResult generateCopy( const MemRefRegion ®ion, Block *block, Block::iterator begin, Block::iterator end, Block *copyPlacementBlock, Block::iterator copyInPlacementStart, Block::iterator copyOutPlacementStart, - AffineCopyOptions copyOptions, DenseMap &fastBufferMap, + AffineCopyOptions copyOptions, DenseMap &fastBufferMap, DenseSet ©Nests, uint64_t *sizeInBytes, Block::iterator *nBegin, Block::iterator *nEnd) { *nBegin = begin; @@ -1285,7 +1286,7 @@ static LogicalResult generateCopy( FuncOp f = begin->getParentOfType(); OpBuilder topBuilder(f.getBody()); - Value *zeroIndex = topBuilder.create(f.getLoc(), 0); + ValuePtr zeroIndex = topBuilder.create(f.getLoc(), 0); if (begin == end) return success(); @@ -1305,7 +1306,7 @@ static LogicalResult generateCopy( OpBuilder top(func.getBody()); auto loc = region.loc; - auto *memref = region.memref; + auto memref = region.memref; auto memRefType = memref->getType().cast(); auto layoutMaps = memRefType.getAffineMaps(); @@ -1317,9 +1318,9 @@ static LogicalResult generateCopy( // Indices to use for the copying. // Indices for the original memref being copied from/to. - SmallVector memIndices; + SmallVector memIndices; // Indices for the faster buffer being copied into/from. - SmallVector bufIndices; + SmallVector bufIndices; unsigned rank = memRefType.getRank(); SmallVector fastBufferShape; @@ -1345,7 +1346,7 @@ static LogicalResult generateCopy( // 'regionSymbols' hold values that this memory region is symbolic/parametric // on; these typically include loop IVs surrounding the level at which the // copy generation is being done or other valid symbols in MLIR. - SmallVector regionSymbols; + SmallVector regionSymbols; cst->getIdValues(rank, cst->getNumIds(), ®ionSymbols); // Construct the index expressions for the fast memory buffer. The index @@ -1393,7 +1394,7 @@ static LogicalResult generateCopy( } // The faster memory space buffer. - Value *fastMemRef; + ValuePtr fastMemRef; // Check if a buffer was already created. bool existingBuf = fastBufferMap.count(memref) > 0; @@ -1433,8 +1434,8 @@ static LogicalResult generateCopy( return failure(); } - Value *stride = nullptr; - Value *numEltPerStride = nullptr; + ValuePtr stride = nullptr; + ValuePtr numEltPerStride = nullptr; if (!strideInfos.empty()) { stride = top.create(loc, strideInfos[0].stride); numEltPerStride = @@ -1473,7 +1474,7 @@ static LogicalResult generateCopy( copyOptions.tagMemorySpace); auto tagMemRef = prologue.create(loc, tagMemRefType); - SmallVector tagIndices({zeroIndex}); + SmallVector tagIndices({zeroIndex}); auto tagAffineMap = b.getMultiDimIdentityMap(tagIndices.size()); fullyComposeAffineMapAndOperands(&tagAffineMap, &tagIndices); if (!region.isWrite()) { @@ -1582,7 +1583,7 @@ static bool getFullMemRefAsRegion(Operation *opInst, unsigned numParamLoopIVs, SmallVector ivs; getLoopIVs(*opInst, &ivs); ivs.resize(numParamLoopIVs); - SmallVector symbols; + SmallVector symbols; extractForInductionVars(ivs, &symbols); regionCst->reset(rank, numParamLoopIVs, 0); regionCst->setIdValues(rank, rank + numParamLoopIVs, symbols); @@ -1629,12 +1630,12 @@ uint64_t mlir::affineDataCopyGenerate(Block::iterator begin, // List of memory regions to copy for. We need a map vector to have a // guaranteed iteration order to write test cases. CHECK-DAG doesn't help here // since the alloc's for example are identical except for the SSA id. - SmallMapVector, 4> readRegions; - SmallMapVector, 4> writeRegions; + SmallMapVector, 4> readRegions; + SmallMapVector, 4> writeRegions; // Map from original memref's to the fast buffers that their accesses are // replaced with. - DenseMap fastBufferMap; + DenseMap fastBufferMap; // To check for errors when walking the block. bool error = false; @@ -1684,7 +1685,7 @@ uint64_t mlir::affineDataCopyGenerate(Block::iterator begin, // Attempts to update; returns true if 'region' exists in targetRegions. auto updateRegion = - [&](const SmallMapVector, 4> + [&](const SmallMapVector, 4> &targetRegions) { auto it = targetRegions.find(region->memref); if (it == targetRegions.end()) @@ -1736,7 +1737,7 @@ uint64_t mlir::affineDataCopyGenerate(Block::iterator begin, uint64_t totalCopyBuffersSizeInBytes = 0; bool ret = true; auto processRegions = - [&](const SmallMapVector, 4> + [&](const SmallMapVector, 4> ®ions) { for (const auto ®ionEntry : regions) { // For each region, hoist copy in/out past all hoistable diff --git a/mlir/lib/Transforms/Utils/RegionUtils.cpp b/mlir/lib/Transforms/Utils/RegionUtils.cpp index b91b189b381..749d5bf1dd0 100644 --- a/mlir/lib/Transforms/Utils/RegionUtils.cpp +++ b/mlir/lib/Transforms/Utils/RegionUtils.cpp @@ -27,9 +27,9 @@ using namespace mlir; -void mlir::replaceAllUsesInRegionWith(Value *orig, Value *replacement, +void mlir::replaceAllUsesInRegionWith(ValuePtr orig, ValuePtr replacement, Region ®ion) { - for (IROperand &use : llvm::make_early_inc_range(orig->getUses())) { + for (auto &use : llvm::make_early_inc_range(orig->getUses())) { if (region.isAncestor(use.getOwner()->getParentRegion())) use.set(replacement); } @@ -63,14 +63,14 @@ void mlir::visitUsedValuesDefinedAbove( } void mlir::getUsedValuesDefinedAbove(Region ®ion, Region &limit, - llvm::SetVector &values) { + llvm::SetVector &values) { visitUsedValuesDefinedAbove(region, limit, [&](OpOperand *operand) { values.insert(operand->get()); }); } void mlir::getUsedValuesDefinedAbove(MutableArrayRef regions, - llvm::SetVector &values) { + llvm::SetVector &values) { for (Region ®ion : regions) getUsedValuesDefinedAbove(region, region, values); } @@ -146,8 +146,8 @@ namespace { class LiveMap { public: /// Value methods. - bool wasProvenLive(Value *value) { return liveValues.count(value); } - void setProvedLive(Value *value) { + bool wasProvenLive(ValuePtr value) { return liveValues.count(value); } + void setProvedLive(ValuePtr value) { changed |= liveValues.insert(value).second; } @@ -161,7 +161,7 @@ public: private: bool changed = false; - DenseSet liveValues; + DenseSet liveValues; DenseSet liveOps; }; } // namespace @@ -188,7 +188,7 @@ static bool isUseSpeciallyKnownDead(OpOperand &use, LiveMap &liveMap) { return false; } -static void processValue(Value *value, LiveMap &liveMap) { +static void processValue(ValuePtr value, LiveMap &liveMap) { bool provedLive = llvm::any_of(value->getUses(), [&](OpOperand &use) { if (isUseSpeciallyKnownDead(use, liveMap)) return false; @@ -222,9 +222,9 @@ static void propagateLiveness(Operation *op, LiveMap &liveMap) { liveMap.setProvedLive(op); return; } - for (Value *value : op->getResults()) + for (ValuePtr value : op->getResults()) processValue(value, liveMap); - bool provedLive = llvm::any_of(op->getResults(), [&](Value *value) { + bool provedLive = llvm::any_of(op->getResults(), [&](ValuePtr value) { return liveMap.wasProvenLive(value); }); if (provedLive) @@ -240,7 +240,7 @@ static void propagateLiveness(Region ®ion, LiveMap &liveMap) { // faster convergence to a fixed point (we try to visit uses before defs). for (Operation &op : llvm::reverse(block->getOperations())) propagateLiveness(&op, liveMap); - for (Value *value : block->getArguments()) + for (ValuePtr value : block->getArguments()) processValue(value, liveMap); } } @@ -259,7 +259,7 @@ static void eraseTerminatorSuccessorOperands(Operation *terminator, // Iterating args in reverse is needed for correctness, to avoid // shifting later args when earlier args are erased. unsigned arg = argE - argI - 1; - Value *value = terminator->getSuccessor(succ)->getArgument(arg); + ValuePtr value = terminator->getSuccessor(succ)->getArgument(arg); if (!liveMap.wasProvenLive(value)) { terminator->eraseSuccessorOperand(succ, arg); } diff --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp index 57a92531163..96a6cdc544f 100644 --- a/mlir/lib/Transforms/Utils/Utils.cpp +++ b/mlir/lib/Transforms/Utils/Utils.cpp @@ -47,7 +47,8 @@ static bool isMemRefDereferencingOp(Operation &op) { } /// Return the AffineMapAttr associated with memory 'op' on 'memref'. -static NamedAttribute getAffineMapAttrForMemRef(Operation *op, Value *memref) { +static NamedAttribute getAffineMapAttrForMemRef(Operation *op, + ValuePtr memref) { return TypeSwitch(op) .Case( @@ -55,12 +56,10 @@ static NamedAttribute getAffineMapAttrForMemRef(Operation *op, Value *memref) { } // Perform the replacement in `op`. -LogicalResult mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, - Operation *op, - ArrayRef extraIndices, - AffineMap indexRemap, - ArrayRef extraOperands, - ArrayRef symbolOperands) { +LogicalResult mlir::replaceAllMemRefUsesWith( + ValuePtr oldMemRef, ValuePtr newMemRef, Operation *op, + ArrayRef extraIndices, AffineMap indexRemap, + ArrayRef extraOperands, ArrayRef symbolOperands) { unsigned newMemRefRank = newMemRef->getType().cast().getRank(); (void)newMemRefRank; // unused in opt mode unsigned oldMemRefRank = oldMemRef->getType().cast().getRank(); @@ -106,13 +105,13 @@ LogicalResult mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, NamedAttribute oldMapAttrPair = getAffineMapAttrForMemRef(op, oldMemRef); AffineMap oldMap = oldMapAttrPair.second.cast().getValue(); unsigned oldMapNumInputs = oldMap.getNumInputs(); - SmallVector oldMapOperands( + SmallVector oldMapOperands( op->operand_begin() + memRefOperandPos + 1, op->operand_begin() + memRefOperandPos + 1 + oldMapNumInputs); // Apply 'oldMemRefOperands = oldMap(oldMapOperands)'. - SmallVector oldMemRefOperands; - SmallVector affineApplyOps; + SmallVector oldMemRefOperands; + SmallVector affineApplyOps; oldMemRefOperands.reserve(oldMemRefRank); if (oldMap != builder.getMultiDimIdentityMap(oldMap.getNumDims())) { for (auto resultExpr : oldMap.getResults()) { @@ -130,14 +129,14 @@ LogicalResult mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, // Construct new indices as a remap of the old ones if a remapping has been // provided. The indices of a memref come right after it, i.e., // at position memRefOperandPos + 1. - SmallVector remapOperands; + SmallVector remapOperands; remapOperands.reserve(extraOperands.size() + oldMemRefRank + symbolOperands.size()); remapOperands.append(extraOperands.begin(), extraOperands.end()); remapOperands.append(oldMemRefOperands.begin(), oldMemRefOperands.end()); remapOperands.append(symbolOperands.begin(), symbolOperands.end()); - SmallVector remapOutputs; + SmallVector remapOutputs; remapOutputs.reserve(oldMemRefRank); if (indexRemap && @@ -156,11 +155,11 @@ LogicalResult mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, remapOutputs.append(remapOperands.begin(), remapOperands.end()); } - SmallVector newMapOperands; + SmallVector newMapOperands; newMapOperands.reserve(newMemRefRank); // Prepend 'extraIndices' in 'newMapOperands'. - for (auto *extraIndex : extraIndices) { + for (auto extraIndex : extraIndices) { assert(extraIndex->getDefiningOp()->getNumResults() == 1 && "single result op's expected to generate these indices"); assert((isValidDim(extraIndex) || isValidSymbol(extraIndex)) && @@ -179,7 +178,7 @@ LogicalResult mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, newMap = simplifyAffineMap(newMap); canonicalizeMapAndOperands(&newMap, &newMapOperands); // Remove any affine.apply's that became dead as a result of composition. - for (auto *value : affineApplyOps) + for (auto value : affineApplyOps) if (value->use_empty()) value->getDefiningOp()->erase(); @@ -203,7 +202,7 @@ LogicalResult mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, // Result types don't change. Both memref's are of the same elemental type. state.types.reserve(op->getNumResults()); - for (auto *result : op->getResults()) + for (auto result : op->getResults()) state.types.push_back(result->getType()); // Add attribute for 'newMap', other Attributes do not change. @@ -224,13 +223,11 @@ LogicalResult mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, return success(); } -LogicalResult mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, - ArrayRef extraIndices, - AffineMap indexRemap, - ArrayRef extraOperands, - ArrayRef symbolOperands, - Operation *domInstFilter, - Operation *postDomInstFilter) { +LogicalResult mlir::replaceAllMemRefUsesWith( + ValuePtr oldMemRef, ValuePtr newMemRef, ArrayRef extraIndices, + AffineMap indexRemap, ArrayRef extraOperands, + ArrayRef symbolOperands, Operation *domInstFilter, + Operation *postDomInstFilter) { unsigned newMemRefRank = newMemRef->getType().cast().getRank(); (void)newMemRefRank; // unused in opt mode unsigned oldMemRefRank = oldMemRef->getType().cast().getRank(); @@ -331,9 +328,9 @@ LogicalResult mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, void mlir::createAffineComputationSlice( Operation *opInst, SmallVectorImpl *sliceOps) { // Collect all operands that are results of affine apply ops. - SmallVector subOperands; + SmallVector subOperands; subOperands.reserve(opInst->getNumOperands()); - for (auto *operand : opInst->getOperands()) + for (auto operand : opInst->getOperands()) if (isa_and_nonnull(operand->getDefiningOp())) subOperands.push_back(operand); @@ -348,7 +345,7 @@ void mlir::createAffineComputationSlice( // which case there would be nothing to do. bool localized = true; for (auto *op : affineApplyOps) { - for (auto *result : op->getResults()) { + for (auto result : op->getResults()) { for (auto *user : result->getUsers()) { if (user != opInst) { localized = false; @@ -361,7 +358,7 @@ void mlir::createAffineComputationSlice( return; OpBuilder builder(opInst); - SmallVector composedOpOperands(subOperands); + SmallVector composedOpOperands(subOperands); auto composedMap = builder.getMultiDimIdentityMap(composedOpOperands.size()); fullyComposeAffineMapAndOperands(&composedMap, &composedOpOperands); @@ -378,7 +375,7 @@ void mlir::createAffineComputationSlice( // affine apply op above instead of existing ones (subOperands). So, they // differ from opInst's operands only for those operands in 'subOperands', for // which they will be replaced by the corresponding one from 'sliceOps'. - SmallVector newOperands(opInst->getOperands()); + SmallVector newOperands(opInst->getOperands()); for (unsigned i = 0, e = newOperands.size(); i < e; i++) { // Replace the subOperands from among the new operands. unsigned j, f; @@ -451,8 +448,8 @@ LogicalResult mlir::normalizeMemRef(AllocOp allocOp) { newShape[d] = ubConst.getValue() + 1; } - auto *oldMemRef = allocOp.getResult(); - SmallVector symbolOperands(allocOp.getSymbolicOperands()); + auto oldMemRef = allocOp.getResult(); + SmallVector symbolOperands(allocOp.getSymbolicOperands()); auto newMemRefType = MemRefType::get(newShape, memrefType.getElementType(), b.getMultiDimIdentityMap(newRank)); diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp index e3212d54e42..d8f5b1dc0e4 100644 --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -705,7 +705,7 @@ struct VectorizationState { // Map of old scalar Operation to new vectorized Operation. DenseMap vectorizationMap; // Map of old scalar Value to new vectorized Value. - DenseMap replacementMap; + DenseMap replacementMap; // The strategy drives which loop to vectorize by which amount. const VectorizationStrategy *strategy; // Use-def roots. These represent the starting points for the worklist in the @@ -728,7 +728,7 @@ struct VectorizationState { OperationFolder *folder; private: - void registerReplacement(Value *key, Value *value); + void registerReplacement(ValuePtr key, ValuePtr value); }; } // end namespace @@ -768,7 +768,7 @@ void VectorizationState::finishVectorizationPattern() { } } -void VectorizationState::registerReplacement(Value *key, Value *value) { +void VectorizationState::registerReplacement(ValuePtr key, ValuePtr value) { assert(replacementMap.count(key) == 0 && "replacement already registered"); replacementMap.insert(std::make_pair(key, value)); } @@ -776,7 +776,7 @@ void VectorizationState::registerReplacement(Value *key, Value *value) { // Apply 'map' with 'mapOperands' returning resulting values in 'results'. static void computeMemoryOpIndices(Operation *op, AffineMap map, ValueRange mapOperands, - SmallVectorImpl &results) { + SmallVectorImpl &results) { OpBuilder builder(op); for (auto resultExpr : map.getResults()) { auto singleResMap = @@ -803,7 +803,7 @@ static void computeMemoryOpIndices(Operation *op, AffineMap map, /// Such special cases force us to delay the vectorization of the stores until /// the last step. Here we merely register the store operation. template -static LogicalResult vectorizeRootOrTerminal(Value *iv, +static LogicalResult vectorizeRootOrTerminal(ValuePtr iv, LoadOrStoreOpPointer memoryOp, VectorizationState *state) { auto memRefType = memoryOp.getMemRef()->getType().template cast(); @@ -823,7 +823,7 @@ static LogicalResult vectorizeRootOrTerminal(Value *iv, if (auto load = dyn_cast(opInst)) { OpBuilder b(opInst); ValueRange mapOperands = load.getMapOperands(); - SmallVector indices; + SmallVector indices; indices.reserve(load.getMemRefType().getRank()); if (load.getAffineMap() != b.getMultiDimIdentityMap(load.getMemRefType().getRank())) { @@ -838,8 +838,7 @@ static LogicalResult vectorizeRootOrTerminal(Value *iv, LLVM_DEBUG(dbgs() << "\n[early-vect]+++++ permutationMap: "); LLVM_DEBUG(permutationMap.print(dbgs())); auto transfer = b.create( - opInst->getLoc(), vectorType, memoryOp.getMemRef(), - map(makePtrDynCaster(), indices), + opInst->getLoc(), vectorType, memoryOp.getMemRef(), indices, AffineMapAttr::get(permutationMap), // TODO(b/144455320) add a proper padding value, not just 0.0 : f32 state->folder->create(b, opInst->getLoc(), @@ -951,7 +950,8 @@ vectorizeLoopsAndLoadsRecursively(NestedMatch oneMatch, /// element type. /// If `type` is not a valid vector type or if the scalar constant is not a /// valid vector element type, returns nullptr. -static Value *vectorizeConstant(Operation *op, ConstantOp constant, Type type) { +static ValuePtr vectorizeConstant(Operation *op, ConstantOp constant, + Type type) { if (!type || !type.isa() || !VectorType::isValidElementType(constant.getType())) { return nullptr; @@ -989,8 +989,8 @@ static Value *vectorizeConstant(Operation *op, ConstantOp constant, Type type) { /// vectorization is possible with the above logic. Returns nullptr otherwise. /// /// TODO(ntv): handle more complex cases. -static Value *vectorizeOperand(Value *operand, Operation *op, - VectorizationState *state) { +static ValuePtr vectorizeOperand(ValuePtr operand, Operation *op, + VectorizationState *state) { LLVM_DEBUG(dbgs() << "\n[early-vect]vectorize operand: "); LLVM_DEBUG(operand->print(dbgs())); // 1. If this value has already been vectorized this round, we are done. @@ -1004,7 +1004,7 @@ static Value *vectorizeOperand(Value *operand, Operation *op, // been vectorized. This would be invalid IR. auto it = state->replacementMap.find(operand); if (it != state->replacementMap.end()) { - auto *res = it->second; + auto res = it->second; LLVM_DEBUG(dbgs() << "-> delayed replacement by: "); LLVM_DEBUG(res->print(dbgs())); return res; @@ -1047,12 +1047,12 @@ static Operation *vectorizeOneOperation(Operation *opInst, if (auto store = dyn_cast(opInst)) { OpBuilder b(opInst); - auto *memRef = store.getMemRef(); - auto *value = store.getValueToStore(); - auto *vectorValue = vectorizeOperand(value, opInst, state); + auto memRef = store.getMemRef(); + auto value = store.getValueToStore(); + auto vectorValue = vectorizeOperand(value, opInst, state); ValueRange mapOperands = store.getMapOperands(); - SmallVector indices; + SmallVector indices; indices.reserve(store.getMemRefType().getRank()); if (store.getAffineMap() != b.getMultiDimIdentityMap(store.getMemRefType().getRank())) { @@ -1081,16 +1081,16 @@ static Operation *vectorizeOneOperation(Operation *opInst, return nullptr; SmallVector vectorTypes; - for (auto *v : opInst->getResults()) { + for (auto v : opInst->getResults()) { vectorTypes.push_back( VectorType::get(state->strategy->vectorSizes, v->getType())); } - SmallVector vectorOperands; - for (auto *v : opInst->getOperands()) { + SmallVector vectorOperands; + for (auto v : opInst->getOperands()) { vectorOperands.push_back(vectorizeOperand(v, opInst, state)); } // Check whether a single operand is null. If so, vectorization failed. - bool success = llvm::all_of(vectorOperands, [](Value *op) { return op; }); + bool success = llvm::all_of(vectorOperands, [](ValuePtr op) { return op; }); if (!success) { LLVM_DEBUG(dbgs() << "\n[early-vect]+++++ an operand failed vectorize"); return nullptr; diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp index 0b105eadf5a..376fc249a18 100644 --- a/mlir/test/EDSC/builder-api-test.cpp +++ b/mlir/test/EDSC/builder-api-test.cpp @@ -484,7 +484,7 @@ TEST_FUNC(select_op_i32) { IndexedValue A(f.getArgument(0)); IndexHandle i, j; AffineLoopNestBuilder({&i, &j}, {zero, zero}, {one, one}, {1, 1})([&]{ - // This test exercises IndexedValue::operator Value*. + // This test exercises IndexedValue::operator Value. // Without it, one must force conversion to ValueHandle as such: // edsc::intrinsics::select( // i == zero, ValueHandle(A(zero, zero)), ValueHandle(ValueA(i, j))) @@ -802,7 +802,7 @@ TEST_FUNC(affine_if_op) { }; auto intSet = IntegerSet::get(2, 2, affineExprs, isEq); - SmallVector affineIfArgs = {zero, zero, ten, ten}; + SmallVector affineIfArgs = {zero, zero, ten, ten}; intrinsics::affine_if(intSet, affineIfArgs, /*withElseRegion=*/false); intrinsics::affine_if(intSet, affineIfArgs, /*withElseRegion=*/true); diff --git a/mlir/test/lib/TestDialect/TestDialect.cpp b/mlir/test/lib/TestDialect/TestDialect.cpp index 7462db4544f..12d024f6593 100644 --- a/mlir/test/lib/TestDialect/TestDialect.cpp +++ b/mlir/test/lib/TestDialect/TestDialect.cpp @@ -100,7 +100,7 @@ struct TestInlinerInterface : public DialectInlinerInterface { /// Handle the given inlined terminator by replacing it with a new operation /// as necessary. void handleTerminator(Operation *op, - ArrayRef valuesToRepl) const final { + ArrayRef valuesToRepl) const final { // Only handle "test.return" here. auto returnOp = dyn_cast(op); if (!returnOp) @@ -117,7 +117,7 @@ struct TestInlinerInterface : public DialectInlinerInterface { /// operation that takes 'input' as the only operand, and produces a single /// result of 'resultType'. If a conversion can not be generated, nullptr /// should be returned. - Operation *materializeCallConversion(OpBuilder &builder, Value *input, + Operation *materializeCallConversion(OpBuilder &builder, ValuePtr input, Type resultType, Location conversionLoc) const final { // Only allow conversion for i16/i32 types. @@ -231,7 +231,7 @@ static ParseResult parseWrappingRegionOp(OpAsmParser &parser, // Create a return terminator in the inner region, pass as operand to the // terminator the returned values from the wrapped operation. - SmallVector return_operands(wrapped_op->getResults()); + SmallVector return_operands(wrapped_op->getResults()); OpBuilder builder(parser.getBuilder().getContext()); builder.setInsertionPointToEnd(&block); builder.create(wrapped_op->getLoc(), return_operands); @@ -297,7 +297,7 @@ OpFoldResult TestOpWithRegionFold::fold(ArrayRef operands) { LogicalResult TestOpWithVariadicResultsAndFolder::fold( ArrayRef operands, SmallVectorImpl &results) { - for (Value *input : this->operands()) { + for (ValuePtr input : this->operands()) { results.push_back(input); } return success(); diff --git a/mlir/test/lib/TestDialect/TestOps.td b/mlir/test/lib/TestDialect/TestOps.td index e33d9c26c7f..ea071f0ddf4 100644 --- a/mlir/test/lib/TestDialect/TestOps.td +++ b/mlir/test/lib/TestDialect/TestOps.td @@ -644,7 +644,7 @@ def OpSymbolBindingB : TEST_Op<"symbol_binding_b", []> { let builders = [ OpBuilder< - "Builder *builder, OperationState &state, Value *operand", + "Builder *builder, OperationState &state, ValuePtr operand", [{ state.types.assign({builder->getIntegerType(32)}); state.addOperands({operand}); diff --git a/mlir/test/lib/TestDialect/TestPatterns.cpp b/mlir/test/lib/TestDialect/TestPatterns.cpp index 94eb792cc66..1f6224dba3a 100644 --- a/mlir/test/lib/TestDialect/TestPatterns.cpp +++ b/mlir/test/lib/TestDialect/TestPatterns.cpp @@ -22,11 +22,12 @@ using namespace mlir; // Native function for testing NativeCodeCall -static Value *chooseOperand(Value *input1, Value *input2, BoolAttr choice) { +static ValuePtr chooseOperand(ValuePtr input1, ValuePtr input2, + BoolAttr choice) { return choice.getValue() ? input1 : input2; } -static void createOpI(PatternRewriter &rewriter, Value *input) { +static void createOpI(PatternRewriter &rewriter, ValuePtr input) { rewriter.create(rewriter.getUnknownLoc(), input); } @@ -73,7 +74,7 @@ struct ReturnTypeOpMatch : public RewritePattern { PatternMatchResult matchAndRewrite(Operation *op, PatternRewriter &rewriter) const final { if (auto retTypeFn = dyn_cast(op)) { - SmallVector values(op->getOperands()); + SmallVector values(op->getOperands()); SmallVector inferedReturnTypes; if (failed(retTypeFn.inferReturnTypes(op->getLoc(), values, op->getAttrs(), op->getRegions(), @@ -132,7 +133,7 @@ struct TestRegionRewriteBlockMovement : public ConversionPattern { : ConversionPattern("test.region", 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { // Inline this region into the parent region. auto &parentRegion = *op->getParentRegion(); @@ -165,7 +166,7 @@ struct TestRegionRewriteUndo : public RewritePattern { // Add an explicitly illegal operation to ensure the conversion fails. rewriter.create(op->getLoc(), rewriter.getIntegerType(32)); - rewriter.create(op->getLoc(), ArrayRef()); + rewriter.create(op->getLoc(), ArrayRef()); // Drop this operation. rewriter.eraseOp(op); @@ -182,7 +183,7 @@ struct TestDropOpSignatureConversion : public ConversionPattern { : ConversionPattern("test.drop_region_op", 1, ctx), converter(converter) { } PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { Region ®ion = op->getRegion(0); Block *entry = ®ion.front(); @@ -208,7 +209,7 @@ struct TestPassthroughInvalidOp : public ConversionPattern { TestPassthroughInvalidOp(MLIRContext *ctx) : ConversionPattern("test.invalid", 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { rewriter.replaceOpWithNewOp(op, llvm::None, operands, llvm::None); @@ -220,7 +221,7 @@ struct TestSplitReturnType : public ConversionPattern { TestSplitReturnType(MLIRContext *ctx) : ConversionPattern("test.return", 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { // Check for a return of F32. if (op->getNumOperands() != 1 || !op->getOperand(0)->getType().isF32()) @@ -245,7 +246,7 @@ struct TestChangeProducerTypeI32ToF32 : public ConversionPattern { TestChangeProducerTypeI32ToF32(MLIRContext *ctx) : ConversionPattern("test.type_producer", 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { // If the type is I32, change the type to F32. if (!(*op->result_type_begin()).isInteger(32)) @@ -258,7 +259,7 @@ struct TestChangeProducerTypeF32ToF64 : public ConversionPattern { TestChangeProducerTypeF32ToF64(MLIRContext *ctx) : ConversionPattern("test.type_producer", 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { // If the type is F32, change the type to F64. if (!(*op->result_type_begin()).isF32()) @@ -271,7 +272,7 @@ struct TestChangeProducerTypeF32ToInvalid : public ConversionPattern { TestChangeProducerTypeF32ToInvalid(MLIRContext *ctx) : ConversionPattern("test.type_producer", 10, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { // Always convert to B16, even though it is not a legal type. This tests // that values are unmapped correctly. @@ -283,7 +284,7 @@ struct TestUpdateConsumerType : public ConversionPattern { TestUpdateConsumerType(MLIRContext *ctx) : ConversionPattern("test.type_consumer", 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef operands, + matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { // Verify that the incoming operand has been successfully remapped to F64. if (!operands[0]->getType().isF64()) @@ -344,7 +345,7 @@ struct TestTypeConverter : public TypeConverter { /// Override the hook to materialize a conversion. This is necessary because /// we generate 1->N type mappings. Operation *materializeConversion(PatternRewriter &rewriter, Type resultType, - ArrayRef inputs, + ArrayRef inputs, Location loc) override { return rewriter.create(loc, resultType, inputs); } @@ -467,13 +468,13 @@ struct OneVResOneVOperandOp1Converter using OpConversionPattern::OpConversionPattern; PatternMatchResult - matchAndRewrite(OneVResOneVOperandOp1 op, ArrayRef operands, + matchAndRewrite(OneVResOneVOperandOp1 op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto origOps = op.getOperands(); assert(std::distance(origOps.begin(), origOps.end()) == 1 && "One operand expected"); - Value *origOp = *origOps.begin(); - SmallVector remappedOperands; + ValuePtr origOp = *origOps.begin(); + SmallVector remappedOperands; // Replicate the remapped original operand twice. Note that we don't used // the remapped 'operand' since the goal is testing 'getRemappedValue'. remappedOperands.push_back(rewriter.getRemappedValue(origOp)); diff --git a/mlir/test/lib/Transforms/TestLoopMapping.cpp b/mlir/test/lib/Transforms/TestLoopMapping.cpp index c25fea9aa13..7f587fc3170 100644 --- a/mlir/test/lib/Transforms/TestLoopMapping.cpp +++ b/mlir/test/lib/Transforms/TestLoopMapping.cpp @@ -41,7 +41,7 @@ public: // SSA values for the transformation are created out of thin air by // unregistered "new_processor_id_and_range" operations. This is enough to // emulate mapping conditions. - SmallVector processorIds, numProcessors; + SmallVector processorIds, numProcessors; func.walk([&processorIds, &numProcessors](Operation *op) { if (op->getName().getStringRef() != "new_processor_id_and_range") return; diff --git a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp index 7efc74f2304..35df0631ca7 100644 --- a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp +++ b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp @@ -245,7 +245,7 @@ void VectorizerTestPass::testNormalizeMaps() { for (auto m : matches) { auto app = cast(m.getMatchedOperation()); OpBuilder b(m.getMatchedOperation()); - SmallVector operands(app.getOperands()); + SmallVector operands(app.getOperands()); makeComposedAffineApply(b, app.getLoc(), app.getAffineMap(), operands); } } diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td index fa73697dba8..004e7662299 100644 --- a/mlir/test/mlir-tblgen/op-attribute.td +++ b/mlir/test/mlir-tblgen/op-attribute.td @@ -216,9 +216,9 @@ def MixOperandsAndAttrs : NS_Op<"mix_operands_and_attrs", []> { } // DEF-LABEL: MixOperandsAndAttrs definitions -// DEF-DAG: Value *MixOperandsAndAttrs::operand() -// DEF-DAG: Value *MixOperandsAndAttrs::otherArg() -// DEF-DAG: void MixOperandsAndAttrs::build(Builder *tblgen_builder, OperationState &tblgen_state, FloatAttr attr, Value *operand, FloatAttr otherAttr, Value *otherArg) +// DEF-DAG: ValuePtr MixOperandsAndAttrs::operand() +// DEF-DAG: ValuePtr MixOperandsAndAttrs::otherArg() +// DEF-DAG: void MixOperandsAndAttrs::build(Builder *tblgen_builder, OperationState &tblgen_state, FloatAttr attr, ValuePtr operand, FloatAttr otherAttr, ValuePtr otherArg) // DEF-DAG: APFloat MixOperandsAndAttrs::attr() // DEF-DAG: APFloat MixOperandsAndAttrs::otherAttr() diff --git a/mlir/test/mlir-tblgen/op-decl.td b/mlir/test/mlir-tblgen/op-decl.td index a217a139848..55952236429 100644 --- a/mlir/test/mlir-tblgen/op-decl.td +++ b/mlir/test/mlir-tblgen/op-decl.td @@ -26,7 +26,7 @@ def NS_AOp : NS_Op<"a_op", [NoSideEffect, NoSideEffect]> { ); let regions = (region AnyRegion:$someRegion); - let builders = [OpBuilder<"Value *val">]; + let builders = [OpBuilder<"ValuePtr val">]; let parser = [{ foo }]; let printer = [{ bar }]; let verifier = [{ baz }]; @@ -46,12 +46,12 @@ def NS_AOp : NS_Op<"a_op", [NoSideEffect, NoSideEffect]> { // CHECK: class AOpOperandAdaptor { // CHECK: public: -// CHECK: AOpOperandAdaptor(ArrayRef values); -// CHECK: ArrayRef getODSOperands(unsigned index); -// CHECK: Value *a(); -// CHECK: ArrayRef b(); +// CHECK: AOpOperandAdaptor(ArrayRef values); +// CHECK: ArrayRef getODSOperands(unsigned index); +// CHECK: ValuePtr a(); +// CHECK: ArrayRef b(); // CHECK: private: -// CHECK: ArrayRef tblgen_operands; +// CHECK: ArrayRef tblgen_operands; // CHECK: }; // CHECK: class AOp : public Op::Impl, OpTrait::HasNoSideEffect, OpTrait::AtLeastNOperands<1>::Impl @@ -60,18 +60,18 @@ def NS_AOp : NS_Op<"a_op", [NoSideEffect, NoSideEffect]> { // CHECK: using OperandAdaptor = AOpOperandAdaptor; // CHECK: static StringRef getOperationName(); // CHECK: Operation::operand_range getODSOperands(unsigned index); -// CHECK: Value *a(); +// CHECK: ValuePtr a(); // CHECK: Operation::operand_range b(); // CHECK: Operation::result_range getODSResults(unsigned index); -// CHECK: Value *r(); +// CHECK: ValuePtr r(); // CHECK: Region &someRegion(); // CHECK: IntegerAttr attr1Attr() // CHECK: APInt attr1(); // CHECK: FloatAttr attr2Attr() // CHECK: Optional< APFloat > attr2(); -// CHECK: static void build(Value *val); -// CHECK: static void build(Builder *tblgen_builder, OperationState &tblgen_state, Type r, ArrayRef s, Value *a, ValueRange b, IntegerAttr attr1, /*optional*/FloatAttr attr2) -// CHECK: static void build(Builder *tblgen_builder, OperationState &tblgen_state, Type r, ArrayRef s, Value *a, ValueRange b, APInt attr1, /*optional*/FloatAttr attr2) +// CHECK: static void build(ValuePtr val); +// CHECK: static void build(Builder *tblgen_builder, OperationState &tblgen_state, Type r, ArrayRef s, ValuePtr a, ValueRange b, IntegerAttr attr1, /*optional*/FloatAttr attr2) +// CHECK: static void build(Builder *tblgen_builder, OperationState &tblgen_state, Type r, ArrayRef s, ValuePtr a, ValueRange b, APInt attr1, /*optional*/FloatAttr attr2) // CHECK: static void build(Builder *, OperationState &tblgen_state, ArrayRef resultTypes, ValueRange operands, ArrayRef attributes) // CHECK: static ParseResult parse(OpAsmParser &parser, OperationState &result); // CHECK: void print(OpAsmPrinter &p); @@ -111,7 +111,7 @@ def NS_DOp : NS_Op<"op_with_two_operands", []> { def NS_SkipDefaultBuildersOp : NS_Op<"skip_default_builders", []> { let skipDefaultBuilders = 1; - let builders = [OpBuilder<"Value *val">]; + let builders = [OpBuilder<"ValuePtr val">]; } // CHECK-LABEL: NS::SkipDefaultBuildersOp declarations diff --git a/mlir/test/mlir-tblgen/op-operand.td b/mlir/test/mlir-tblgen/op-operand.td index 872cc474a06..c592686ebd3 100644 --- a/mlir/test/mlir-tblgen/op-operand.td +++ b/mlir/test/mlir-tblgen/op-operand.td @@ -18,7 +18,7 @@ def OpA : NS_Op<"one_normal_operand_op", []> { // CHECK-NEXT: tblgen_operands = values // CHECK: void OpA::build -// CHECK: Value *input +// CHECK: ValuePtr input // CHECK: tblgen_state.addOperands(input); // CHECK: void OpA::build @@ -39,19 +39,19 @@ def OpD : NS_Op<"mix_variadic_and_normal_inputs_op", [SameVariadicOperandSize]> let arguments = (ins Variadic:$input1, AnyTensor:$input2, Variadic:$input3); } -// CHECK-LABEL: ArrayRef OpDOperandAdaptor::input1 +// CHECK-LABEL: ArrayRef OpDOperandAdaptor::input1 // CHECK-NEXT: return getODSOperands(0); -// CHECK-LABEL: Value *OpDOperandAdaptor::input2 +// CHECK-LABEL: ValuePtr OpDOperandAdaptor::input2 // CHECK-NEXT: return *getODSOperands(1).begin(); -// CHECK-LABEL: ArrayRef OpDOperandAdaptor::input3 +// CHECK-LABEL: ArrayRef OpDOperandAdaptor::input3 // CHECK-NEXT: return getODSOperands(2); // CHECK-LABEL: Operation::operand_range OpD::input1 // CHECK-NEXT: return getODSOperands(0); -// CHECK-LABEL: Value *OpD::input2 +// CHECK-LABEL: ValuePtr OpD::input2 // CHECK-NEXT: return *getODSOperands(1).begin(); // CHECK-LABEL: OpD::build diff --git a/mlir/test/mlir-tblgen/op-result.td b/mlir/test/mlir-tblgen/op-result.td index 4ee631986cc..f9a77ea492e 100644 --- a/mlir/test/mlir-tblgen/op-result.td +++ b/mlir/test/mlir-tblgen/op-result.td @@ -23,9 +23,9 @@ def OpB : NS_Op<"same_input_output_type_op", [SameOperandsAndResultType]> { } // CHECK-LABEL: OpB definitions -// CHECK: void OpB::build(Builder *tblgen_builder, OperationState &tblgen_state, Type y, Value *x) +// CHECK: void OpB::build(Builder *tblgen_builder, OperationState &tblgen_state, Type y, ValuePtr x) // CHECK: tblgen_state.addTypes(y); -// CHECK: void OpB::build(Builder *tblgen_builder, OperationState &tblgen_state, Value *x) +// CHECK: void OpB::build(Builder *tblgen_builder, OperationState &tblgen_state, ValuePtr x) // CHECK: tblgen_state.addTypes({x->getType()}); def OpC : NS_Op<"three_normal_result_op", []> { @@ -89,7 +89,7 @@ def OpI : NS_Op<"mix_variadic_and_normal_results_op", [SameVariadicResultSize]> // CHECK-LABEL: Operation::result_range OpI::output1 // CHECK-NEXT: return getODSResults(0); -// CHECK-LABEL: Value *OpI::output2 +// CHECK-LABEL: ValuePtr OpI::output2 // CHECK-NEXT: return *getODSResults(1).begin(); // CHECK-LABEL: OpI::build diff --git a/mlir/test/mlir-tblgen/predicate.td b/mlir/test/mlir-tblgen/predicate.td index 26a5b746fb4..fef1b139dc9 100644 --- a/mlir/test/mlir-tblgen/predicate.td +++ b/mlir/test/mlir-tblgen/predicate.td @@ -16,7 +16,7 @@ def OpA : NS_Op<"op_for_CPred_containing_multiple_same_placeholder", []> { } // CHECK-LABEL: OpA::verify -// CHECK: for (Value *v : getODSOperands(0)) { +// CHECK: for (ValuePtr v : getODSOperands(0)) { // CHECK: if (!((v->getType().isInteger(32) || v->getType().isF32()))) def OpB : NS_Op<"op_for_And_PredOpTrait", [ @@ -90,5 +90,5 @@ def OpK : NS_Op<"op_for_AnyTensorOf", []> { } // CHECK-LABEL: OpK::verify -// CHECK: for (Value *v : getODSOperands(0)) { +// CHECK: for (ValuePtr v : getODSOperands(0)) { // CHECK: if (!(((v->getType().isa())) && (((v->getType().cast().getElementType().isF32())) || ((v->getType().cast().getElementType().isInteger(32)))))) diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index dd56458ccb3..df8feb855c5 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -713,11 +713,12 @@ void OpEmitter::genAttrGetters() { // Generates the named operand getter methods for the given Operator `op` and // puts them in `opClass`. Uses `rangeType` as the return type of getters that -// return a range of operands (individual operands are `Value *` and each -// element in the range must also be `Value *`); use `rangeBeginCall` to get an -// iterator to the beginning of the operand range; use `rangeSizeCall` to obtain -// the number of operands. `getOperandCallPattern` contains the code necessary -// to obtain a single operand whose position will be substituted instead of +// return a range of operands (individual operands are `ValuePtr ` and each +// element in the range must also be `ValuePtr `); use `rangeBeginCall` to get +// an iterator to the beginning of the operand range; use `rangeSizeCall` to +// obtain the number of operands. `getOperandCallPattern` contains the code +// necessary to obtain a single operand whose position will be substituted +// instead of // "{0}" marker in the pattern. Note that the pattern should work for any kind // of ops, in particular for one-operand ops that may not have the // `getOperand(unsigned)` method. @@ -790,7 +791,7 @@ static void generateNamedOperandGetters(const Operator &op, Class &opClass, auto &m = opClass.newMethod(rangeType, operand.name); m.body() << " return getODSOperands(" << i << ");"; } else { - auto &m = opClass.newMethod("Value *", operand.name); + auto &m = opClass.newMethod("ValuePtr ", operand.name); m.body() << " return *getODSOperands(" << i << ").begin();"; } } @@ -868,7 +869,7 @@ void OpEmitter::genNamedResultGetters() { auto &m = opClass.newMethod("Operation::result_range", result.name); m.body() << " return getODSResults(" << i << ");"; } else { - auto &m = opClass.newMethod("Value *", result.name); + auto &m = opClass.newMethod("ValuePtr ", result.name); m.body() << " return *getODSResults(" << i << ").begin();"; } } @@ -1246,7 +1247,7 @@ void OpEmitter::buildParamList(std::string ¶mList, auto argument = op.getArg(i); if (argument.is()) { const auto &operand = op.getOperand(numOperands); - paramList.append(operand.isVariadic() ? ", ValueRange " : ", Value *"); + paramList.append(operand.isVariadic() ? ", ValueRange " : ", ValuePtr "); paramList.append(getArgumentName(op, numOperands)); ++numOperands; } else { @@ -1535,7 +1536,7 @@ void OpEmitter::genOperandResultVerifier(OpMethodBody &body, continue; // Emit a loop to check all the dynamic values in the pack. - body << formatv(" for (Value *v : getODS{0}{1}s({2})) {{\n", + body << formatv(" for (ValuePtr v : getODS{0}{1}s({2})) {{\n", // Capitalize the first letter to match the function name valueKind.substr(0, 1).upper(), valueKind.substr(1), staticValue.index()); @@ -1690,7 +1691,7 @@ void OpEmitter::genOpAsmInterface() { namespace { // Helper class to emit Op operand adaptors to an output stream. Operand -// adaptors are wrappers around ArrayRef that provide named operand +// adaptors are wrappers around ArrayRef that provide named operand // getters identical to those defined in the Op. class OpOperandAdaptorEmitter { public: @@ -1706,12 +1707,12 @@ private: OpOperandAdaptorEmitter::OpOperandAdaptorEmitter(const Operator &op) : adapterClass(op.getCppClassName().str() + "OperandAdaptor") { - adapterClass.newField("ArrayRef", "tblgen_operands"); - auto &constructor = adapterClass.newConstructor("ArrayRef values"); + adapterClass.newField("ArrayRef", "tblgen_operands"); + auto &constructor = adapterClass.newConstructor("ArrayRef values"); constructor.body() << " tblgen_operands = values;\n"; generateNamedOperandGetters(op, adapterClass, - /*rangeType=*/"ArrayRef", + /*rangeType=*/"ArrayRef", /*rangeBeginCall=*/"tblgen_operands.begin()", /*rangeSizeCall=*/"tblgen_operands.size()", /*getOperandCallPattern=*/"tblgen_operands[{0}]"); diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index b2376e8739c..a74bc23a95a 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -576,14 +576,14 @@ void PatternEmitter::emitRewriteLogic() { os.indent(4) << "rewriter.eraseOp(op0);\n"; } else { // Process replacement result patterns. - os.indent(4) << "SmallVector tblgen_repl_values;\n"; + os.indent(4) << "SmallVector tblgen_repl_values;\n"; for (int i = replStartIndex; i < numResultPatterns; ++i) { DagNode resultTree = pattern.getResultPattern(i); auto val = handleResultPattern(resultTree, offsets[i], 0); os.indent(4) << "\n"; // Resolve each symbol for all range use so that we can loop over them. os << symbolInfoMap.getAllRangeUse( - val, " for (auto *v : {0}) {{ tblgen_repl_values.push_back(v); }", + val, " for (auto v : {0}) {{ tblgen_repl_values.push_back(v); }", "\n"); } os.indent(4) << "\n"; @@ -819,7 +819,7 @@ std::string PatternEmitter::handleOpCreation(DagNode tree, int resultIndex, int numResults = resultOp.getNumResults(); if (numResults != 0) { for (int i = 0; i < numResults; ++i) - os.indent(6) << formatv("for (auto *v : castedOp0.getODSResults({0})) {{" + os.indent(6) << formatv("for (auto v : castedOp0.getODSResults({0})) {{" "tblgen_types.push_back(v->getType()); }\n", resultIndex + i); } @@ -835,8 +835,8 @@ void PatternEmitter::createSeparateLocalVarsForOpArgs( Operator &resultOp = node.getDialectOp(opMap); // Now prepare operands used for building this op: - // * If the operand is non-variadic, we create a `Value*` local variable. - // * If the operand is variadic, we create a `SmallVector` local + // * If the operand is non-variadic, we create a `Value` local variable. + // * If the operand is variadic, we create a `SmallVector` local // variable. int valueIndex = 0; // An index for uniquing local variable names. @@ -851,7 +851,7 @@ void PatternEmitter::createSeparateLocalVarsForOpArgs( std::string varName; if (operand->isVariadic()) { varName = formatv("tblgen_values_{0}", valueIndex++); - os.indent(6) << formatv("SmallVector {0};\n", varName); + os.indent(6) << formatv("SmallVector {0};\n", varName); std::string range; if (node.isNestedDagArg(argIndex)) { range = childNodeNames[argIndex]; @@ -861,11 +861,11 @@ void PatternEmitter::createSeparateLocalVarsForOpArgs( // Resolve the symbol for all range use so that we have a uniform way of // capturing the values. range = symbolInfoMap.getValueAndRangeUse(range); - os.indent(6) << formatv("for (auto *v : {0}) {1}.push_back(v);\n", range, + os.indent(6) << formatv("for (auto v : {0}) {1}.push_back(v);\n", range, varName); } else { varName = formatv("tblgen_value_{0}", valueIndex++); - os.indent(6) << formatv("Value *{0} = ", varName); + os.indent(6) << formatv("ValuePtr {0} = ", varName); if (node.isNestedDagArg(argIndex)) { os << symbolInfoMap.getValueAndRangeUse(childNodeNames[argIndex]); } else { @@ -934,7 +934,7 @@ void PatternEmitter::createAggregateLocalVarsForOpArgs( Operator &resultOp = node.getDialectOp(opMap); os.indent(6) << formatv( - "SmallVector tblgen_values; (void)tblgen_values;\n"); + "SmallVector tblgen_values; (void)tblgen_values;\n"); os.indent(6) << formatv( "SmallVector tblgen_attrs; (void)tblgen_attrs;\n"); @@ -975,7 +975,7 @@ void PatternEmitter::createAggregateLocalVarsForOpArgs( // capturing the values. range = symbolInfoMap.getValueAndRangeUse(range); os.indent(6) << formatv( - "for (auto *v : {0}) tblgen_values.push_back(v);\n", range); + "for (auto v : {0}) tblgen_values.push_back(v);\n", range); } else { os.indent(6) << formatv("tblgen_values.push_back(", varName); if (node.isNestedDagArg(argIndex)) { diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp index f1712efb319..6d5bcc116ad 100644 --- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp +++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp @@ -470,7 +470,7 @@ static void emitDeserializationFunction(const Record *attrClass, emitResultDeserialization(op, record->getLoc(), " ", words, wordIndex, resultTypes, valueID, os); - os << formatv(" SmallVector {0};\n", operands); + os << formatv(" SmallVector {0};\n", operands); os << formatv(" SmallVector {0};\n", attributes); // Operand deserialization emitOperandDeserialization(op, record->getLoc(), " ", words, wordIndex, diff --git a/mlir/unittests/IR/OperationSupportTest.cpp b/mlir/unittests/IR/OperationSupportTest.cpp index 80f82ac3e5d..d7dae4648fe 100644 --- a/mlir/unittests/IR/OperationSupportTest.cpp +++ b/mlir/unittests/IR/OperationSupportTest.cpp @@ -25,7 +25,7 @@ using namespace mlir::detail; namespace { Operation *createOp(MLIRContext *context, bool resizableOperands, - ArrayRef operands = llvm::None, + ArrayRef operands = llvm::None, ArrayRef resultTypes = llvm::None) { return Operation::create( UnknownLoc::get(context), OperationName("foo.bar", context), resultTypes, @@ -39,7 +39,7 @@ TEST(OperandStorageTest, NonResizable) { Operation *useOp = createOp(&context, /*resizableOperands=*/false, /*operands=*/llvm::None, builder.getIntegerType(16)); - Value *operand = useOp->getResult(0); + ValuePtr operand = useOp->getResult(0); // Create a non-resizable operation with one operand. Operation *user = createOp(&context, /*resizableOperands=*/false, operand, @@ -68,7 +68,7 @@ TEST(OperandStorageDeathTest, AddToNonResizable) { Operation *useOp = createOp(&context, /*resizableOperands=*/false, /*operands=*/llvm::None, builder.getIntegerType(16)); - Value *operand = useOp->getResult(0); + ValuePtr operand = useOp->getResult(0); // Create a non-resizable operation with one operand. Operation *user = createOp(&context, /*resizableOperands=*/false, operand, @@ -88,7 +88,7 @@ TEST(OperandStorageTest, Resizable) { Operation *useOp = createOp(&context, /*resizableOperands=*/false, /*operands=*/llvm::None, builder.getIntegerType(16)); - Value *operand = useOp->getResult(0); + ValuePtr operand = useOp->getResult(0); // Create a resizable operation with one operand. Operation *user = createOp(&context, /*resizableOperands=*/true, operand, -- cgit v1.2.3 From 56222a0694e4caf35e892d70591417c39fef1185 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Mon, 23 Dec 2019 09:35:36 -0800 Subject: Adjust License.txt file to use the LLVM license PiperOrigin-RevId: 286906740 --- mlir/LICENSE.TXT | 128 ++++++++++++++++----- mlir/bindings/python/pybind.cpp | 17 +-- mlir/examples/toy/Ch1/include/toy/AST.h | 17 +-- mlir/examples/toy/Ch1/include/toy/Lexer.h | 17 +-- mlir/examples/toy/Ch1/include/toy/Parser.h | 17 +-- mlir/examples/toy/Ch1/parser/AST.cpp | 17 +-- mlir/examples/toy/Ch1/toyc.cpp | 17 +-- mlir/examples/toy/Ch2/include/toy/AST.h | 17 +-- mlir/examples/toy/Ch2/include/toy/Dialect.h | 17 +-- mlir/examples/toy/Ch2/include/toy/Lexer.h | 17 +-- mlir/examples/toy/Ch2/include/toy/MLIRGen.h | 17 +-- mlir/examples/toy/Ch2/include/toy/Ops.td | 17 +-- mlir/examples/toy/Ch2/include/toy/Parser.h | 17 +-- mlir/examples/toy/Ch2/mlir/Dialect.cpp | 17 +-- mlir/examples/toy/Ch2/mlir/MLIRGen.cpp | 17 +-- mlir/examples/toy/Ch2/parser/AST.cpp | 17 +-- mlir/examples/toy/Ch2/toyc.cpp | 17 +-- mlir/examples/toy/Ch3/include/toy/AST.h | 17 +-- mlir/examples/toy/Ch3/include/toy/Dialect.h | 17 +-- mlir/examples/toy/Ch3/include/toy/Lexer.h | 17 +-- mlir/examples/toy/Ch3/include/toy/MLIRGen.h | 17 +-- mlir/examples/toy/Ch3/include/toy/Ops.td | 17 +-- mlir/examples/toy/Ch3/include/toy/Parser.h | 17 +-- mlir/examples/toy/Ch3/mlir/Dialect.cpp | 17 +-- mlir/examples/toy/Ch3/mlir/MLIRGen.cpp | 17 +-- mlir/examples/toy/Ch3/mlir/ToyCombine.cpp | 17 +-- mlir/examples/toy/Ch3/mlir/ToyCombine.td | 17 +-- mlir/examples/toy/Ch3/parser/AST.cpp | 17 +-- mlir/examples/toy/Ch3/toyc.cpp | 17 +-- mlir/examples/toy/Ch4/include/toy/AST.h | 17 +-- mlir/examples/toy/Ch4/include/toy/Dialect.h | 17 +-- mlir/examples/toy/Ch4/include/toy/Lexer.h | 17 +-- mlir/examples/toy/Ch4/include/toy/MLIRGen.h | 17 +-- mlir/examples/toy/Ch4/include/toy/Ops.td | 17 +-- mlir/examples/toy/Ch4/include/toy/Parser.h | 17 +-- mlir/examples/toy/Ch4/include/toy/Passes.h | 17 +-- .../toy/Ch4/include/toy/ShapeInferenceInterface.h | 17 +-- .../toy/Ch4/include/toy/ShapeInferenceInterface.td | 17 +-- .../toy/Ch4/mlir/DeadFunctionEliminationPass.cpp | 17 +-- mlir/examples/toy/Ch4/mlir/Dialect.cpp | 17 +-- mlir/examples/toy/Ch4/mlir/MLIRGen.cpp | 17 +-- mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp | 17 +-- mlir/examples/toy/Ch4/mlir/ToyCombine.cpp | 17 +-- mlir/examples/toy/Ch4/mlir/ToyCombine.td | 17 +-- mlir/examples/toy/Ch4/parser/AST.cpp | 17 +-- mlir/examples/toy/Ch4/toyc.cpp | 17 +-- mlir/examples/toy/Ch5/include/toy/AST.h | 17 +-- mlir/examples/toy/Ch5/include/toy/Dialect.h | 17 +-- mlir/examples/toy/Ch5/include/toy/Lexer.h | 17 +-- mlir/examples/toy/Ch5/include/toy/MLIRGen.h | 17 +-- mlir/examples/toy/Ch5/include/toy/Ops.td | 17 +-- mlir/examples/toy/Ch5/include/toy/Parser.h | 17 +-- mlir/examples/toy/Ch5/include/toy/Passes.h | 17 +-- .../toy/Ch5/include/toy/ShapeInferenceInterface.h | 17 +-- .../toy/Ch5/include/toy/ShapeInferenceInterface.td | 17 +-- .../toy/Ch5/mlir/DeadFunctionEliminationPass.cpp | 17 +-- mlir/examples/toy/Ch5/mlir/Dialect.cpp | 17 +-- mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp | 17 +-- mlir/examples/toy/Ch5/mlir/MLIRGen.cpp | 17 +-- mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp | 17 +-- mlir/examples/toy/Ch5/mlir/ToyCombine.cpp | 17 +-- mlir/examples/toy/Ch5/mlir/ToyCombine.td | 17 +-- mlir/examples/toy/Ch5/parser/AST.cpp | 17 +-- mlir/examples/toy/Ch5/toyc.cpp | 17 +-- mlir/examples/toy/Ch6/include/toy/AST.h | 17 +-- mlir/examples/toy/Ch6/include/toy/Dialect.h | 17 +-- mlir/examples/toy/Ch6/include/toy/Lexer.h | 17 +-- mlir/examples/toy/Ch6/include/toy/MLIRGen.h | 17 +-- mlir/examples/toy/Ch6/include/toy/Ops.td | 17 +-- mlir/examples/toy/Ch6/include/toy/Parser.h | 17 +-- mlir/examples/toy/Ch6/include/toy/Passes.h | 17 +-- .../toy/Ch6/include/toy/ShapeInferenceInterface.h | 17 +-- .../toy/Ch6/include/toy/ShapeInferenceInterface.td | 17 +-- .../toy/Ch6/mlir/DeadFunctionEliminationPass.cpp | 17 +-- mlir/examples/toy/Ch6/mlir/Dialect.cpp | 17 +-- mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp | 17 +-- mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp | 17 +-- mlir/examples/toy/Ch6/mlir/MLIRGen.cpp | 17 +-- mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp | 17 +-- mlir/examples/toy/Ch6/mlir/ToyCombine.cpp | 17 +-- mlir/examples/toy/Ch6/mlir/ToyCombine.td | 17 +-- mlir/examples/toy/Ch6/parser/AST.cpp | 17 +-- mlir/examples/toy/Ch6/toyc.cpp | 17 +-- mlir/examples/toy/Ch7/include/toy/AST.h | 17 +-- mlir/examples/toy/Ch7/include/toy/Dialect.h | 17 +-- mlir/examples/toy/Ch7/include/toy/Lexer.h | 17 +-- mlir/examples/toy/Ch7/include/toy/MLIRGen.h | 17 +-- mlir/examples/toy/Ch7/include/toy/Ops.td | 17 +-- mlir/examples/toy/Ch7/include/toy/Parser.h | 17 +-- mlir/examples/toy/Ch7/include/toy/Passes.h | 17 +-- .../toy/Ch7/include/toy/ShapeInferenceInterface.h | 17 +-- .../toy/Ch7/include/toy/ShapeInferenceInterface.td | 17 +-- .../toy/Ch7/mlir/DeadFunctionEliminationPass.cpp | 17 +-- mlir/examples/toy/Ch7/mlir/Dialect.cpp | 17 +-- mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp | 17 +-- mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp | 17 +-- mlir/examples/toy/Ch7/mlir/MLIRGen.cpp | 17 +-- mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp | 17 +-- mlir/examples/toy/Ch7/mlir/ToyCombine.cpp | 17 +-- mlir/examples/toy/Ch7/mlir/ToyCombine.td | 17 +-- mlir/examples/toy/Ch7/parser/AST.cpp | 17 +-- mlir/examples/toy/Ch7/toyc.cpp | 17 +-- mlir/include/mlir-c/Core.h | 17 +-- mlir/include/mlir/ADT/TypeSwitch.h | 17 +-- mlir/include/mlir/Analysis/AffineAnalysis.h | 17 +-- mlir/include/mlir/Analysis/AffineStructures.h | 17 +-- mlir/include/mlir/Analysis/CallGraph.h | 17 +-- mlir/include/mlir/Analysis/CallInterfaces.h | 17 +-- mlir/include/mlir/Analysis/CallInterfaces.td | 17 +-- mlir/include/mlir/Analysis/Dominance.h | 17 +-- mlir/include/mlir/Analysis/InferTypeOpInterface.h | 17 +-- mlir/include/mlir/Analysis/InferTypeOpInterface.td | 17 +-- mlir/include/mlir/Analysis/Liveness.h | 17 +-- mlir/include/mlir/Analysis/LoopAnalysis.h | 17 +-- mlir/include/mlir/Analysis/NestedMatcher.h | 17 +-- mlir/include/mlir/Analysis/Passes.h | 17 +-- mlir/include/mlir/Analysis/SliceAnalysis.h | 17 +-- mlir/include/mlir/Analysis/Utils.h | 17 +-- mlir/include/mlir/Analysis/Verifier.h | 17 +-- .../Conversion/AffineToStandard/AffineToStandard.h | 17 +-- .../mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h | 17 +-- .../mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h | 17 +-- .../mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h | 17 +-- .../mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h | 17 +-- .../Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h | 17 +-- .../mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h | 17 +-- .../LoopToStandard/ConvertLoopToStandard.h | 17 +-- .../mlir/Conversion/LoopsToGPU/LoopsToGPU.h | 17 +-- .../mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h | 17 +-- .../StandardToLLVM/ConvertStandardToLLVM.h | 17 +-- .../StandardToLLVM/ConvertStandardToLLVMPass.h | 17 +-- .../StandardToSPIRV/ConvertStandardToSPIRV.h | 17 +-- .../StandardToSPIRV/ConvertStandardToSPIRVPass.h | 17 +-- .../Conversion/VectorToLLVM/ConvertVectorToLLVM.h | 17 +-- .../VectorToLoops/ConvertVectorToLoops.h | 17 +-- mlir/include/mlir/Dialect/AffineOps/AffineOps.h | 17 +-- mlir/include/mlir/Dialect/AffineOps/AffineOps.td | 17 +-- .../mlir/Dialect/AffineOps/AffineOpsBase.td | 17 +-- mlir/include/mlir/Dialect/CommonFolders.h | 17 +-- mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.h | 17 +-- mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td | 17 +-- mlir/include/mlir/Dialect/FxpMathOps/Passes.h | 17 +-- mlir/include/mlir/Dialect/GPU/GPUDialect.h | 17 +-- mlir/include/mlir/Dialect/GPU/GPUOps.td | 17 +-- mlir/include/mlir/Dialect/GPU/Passes.h | 17 +-- mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h | 17 +-- mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td | 17 +-- mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | 17 +-- mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h | 17 +-- mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td | 17 +-- mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h | 17 +-- mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td | 17 +-- .../Dialect/Linalg/Analysis/DependenceAnalysis.h | 17 +-- mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h | 17 +-- mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h | 17 +-- mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td | 17 +-- mlir/include/mlir/Dialect/Linalg/IR/LinalgDoc.td | 17 +-- .../mlir/Dialect/Linalg/IR/LinalgLibraryOps.td | 17 +-- mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h | 17 +-- mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td | 17 +-- .../mlir/Dialect/Linalg/IR/LinalgStructuredOps.td | 17 +-- mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h | 17 +-- mlir/include/mlir/Dialect/Linalg/IR/LinalgTypes.h | 17 +-- mlir/include/mlir/Dialect/Linalg/Passes.h | 17 +-- .../Linalg/Transforms/LinalgTransformPatterns.td | 17 +-- .../Dialect/Linalg/Transforms/LinalgTransforms.h | 17 +-- .../include/mlir/Dialect/Linalg/Utils/Intrinsics.h | 17 +-- mlir/include/mlir/Dialect/Linalg/Utils/Utils.h | 17 +-- mlir/include/mlir/Dialect/LoopOps/LoopOps.h | 17 +-- mlir/include/mlir/Dialect/LoopOps/LoopOps.td | 17 +-- .../mlir/Dialect/QuantOps/FakeQuantSupport.h | 17 +-- mlir/include/mlir/Dialect/QuantOps/Passes.h | 17 +-- mlir/include/mlir/Dialect/QuantOps/QuantOps.h | 17 +-- mlir/include/mlir/Dialect/QuantOps/QuantOps.td | 17 +-- .../mlir/Dialect/QuantOps/QuantPredicates.td | 17 +-- mlir/include/mlir/Dialect/QuantOps/QuantTypes.h | 17 +-- mlir/include/mlir/Dialect/QuantOps/QuantizeUtils.h | 17 +-- .../include/mlir/Dialect/QuantOps/UniformSupport.h | 17 +-- mlir/include/mlir/Dialect/SDBM/SDBM.h | 17 +-- mlir/include/mlir/Dialect/SDBM/SDBMDialect.h | 17 +-- mlir/include/mlir/Dialect/SDBM/SDBMExpr.h | 17 +-- mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h | 17 +-- mlir/include/mlir/Dialect/SPIRV/Passes.h | 17 +-- .../mlir/Dialect/SPIRV/SPIRVArithmeticOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVBinaryUtils.h | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td | 17 +-- .../mlir/Dialect/SPIRV/SPIRVCompositeOps.td | 17 +-- .../mlir/Dialect/SPIRV/SPIRVControlFlowOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.td | 17 +-- .../mlir/Dialect/SPIRV/SPIRVNonUniformOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td | 17 +-- .../mlir/Dialect/SPIRV/SPIRVStructureOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h | 17 +-- mlir/include/mlir/Dialect/SPIRV/Serialization.h | 17 +-- mlir/include/mlir/Dialect/StandardOps/Ops.h | 17 +-- mlir/include/mlir/Dialect/StandardOps/Ops.td | 17 +-- mlir/include/mlir/Dialect/Traits.h | 17 +-- .../mlir/Dialect/Utils/StructuredOpsUtils.h | 17 +-- mlir/include/mlir/Dialect/VectorOps/Utils.h | 17 +-- mlir/include/mlir/Dialect/VectorOps/VectorOps.h | 17 +-- mlir/include/mlir/Dialect/VectorOps/VectorOps.td | 17 +-- .../Dialect/VectorOps/VectorTransformPatterns.td | 17 +-- .../mlir/Dialect/VectorOps/VectorTransforms.h | 17 +-- mlir/include/mlir/EDSC/Builders.h | 17 +-- mlir/include/mlir/EDSC/Helpers.h | 17 +-- mlir/include/mlir/EDSC/Intrinsics.h | 17 +-- .../include/mlir/ExecutionEngine/ExecutionEngine.h | 17 +-- mlir/include/mlir/ExecutionEngine/OptUtils.h | 17 +-- mlir/include/mlir/IR/AffineExpr.h | 17 +-- mlir/include/mlir/IR/AffineExprVisitor.h | 17 +-- mlir/include/mlir/IR/AffineMap.h | 17 +-- mlir/include/mlir/IR/AttributeSupport.h | 17 +-- mlir/include/mlir/IR/Attributes.h | 17 +-- mlir/include/mlir/IR/Block.h | 17 +-- mlir/include/mlir/IR/BlockAndValueMapping.h | 17 +-- mlir/include/mlir/IR/BlockSupport.h | 17 +-- mlir/include/mlir/IR/Builders.h | 17 +-- mlir/include/mlir/IR/Diagnostics.h | 17 +-- mlir/include/mlir/IR/Dialect.h | 17 +-- mlir/include/mlir/IR/DialectHooks.h | 17 +-- mlir/include/mlir/IR/DialectImplementation.h | 17 +-- mlir/include/mlir/IR/DialectInterface.h | 17 +-- mlir/include/mlir/IR/DialectSymbolRegistry.def | 17 +-- mlir/include/mlir/IR/Function.h | 17 +-- mlir/include/mlir/IR/FunctionImplementation.h | 17 +-- mlir/include/mlir/IR/FunctionSupport.h | 17 +-- mlir/include/mlir/IR/Identifier.h | 17 +-- mlir/include/mlir/IR/IntegerSet.h | 17 +-- mlir/include/mlir/IR/Location.h | 17 +-- mlir/include/mlir/IR/MLIRContext.h | 17 +-- mlir/include/mlir/IR/Matchers.h | 17 +-- mlir/include/mlir/IR/Module.h | 17 +-- mlir/include/mlir/IR/OpAsmInterface.td | 17 +-- mlir/include/mlir/IR/OpBase.td | 17 +-- mlir/include/mlir/IR/OpDefinition.h | 17 +-- mlir/include/mlir/IR/OpImplementation.h | 17 +-- mlir/include/mlir/IR/Operation.h | 17 +-- mlir/include/mlir/IR/OperationSupport.h | 17 +-- mlir/include/mlir/IR/PatternMatch.h | 17 +-- mlir/include/mlir/IR/Region.h | 17 +-- mlir/include/mlir/IR/RegionGraphTraits.h | 17 +-- mlir/include/mlir/IR/StandardTypes.h | 17 +-- mlir/include/mlir/IR/StorageUniquerSupport.h | 17 +-- mlir/include/mlir/IR/SymbolTable.h | 17 +-- mlir/include/mlir/IR/TypeSupport.h | 17 +-- mlir/include/mlir/IR/TypeUtilities.h | 17 +-- mlir/include/mlir/IR/Types.h | 17 +-- mlir/include/mlir/IR/UseDefLists.h | 17 +-- mlir/include/mlir/IR/Value.h | 17 +-- mlir/include/mlir/IR/Visitors.h | 17 +-- mlir/include/mlir/Parser.h | 17 +-- mlir/include/mlir/Pass/AnalysisManager.h | 17 +-- mlir/include/mlir/Pass/Pass.h | 17 +-- mlir/include/mlir/Pass/PassInstrumentation.h | 17 +-- mlir/include/mlir/Pass/PassManager.h | 17 +-- mlir/include/mlir/Pass/PassOptions.h | 17 +-- mlir/include/mlir/Pass/PassRegistry.h | 17 +-- .../mlir/Quantizer/Configurations/FxpMathConfig.h | 17 +-- .../include/mlir/Quantizer/Support/Configuration.h | 17 +-- .../Quantizer/Support/ConstraintAnalysisGraph.h | 17 +-- .../Support/ConstraintAnalysisGraphTraits.h | 17 +-- mlir/include/mlir/Quantizer/Support/Metadata.h | 17 +-- mlir/include/mlir/Quantizer/Support/Rules.h | 17 +-- mlir/include/mlir/Quantizer/Support/Statistics.h | 17 +-- mlir/include/mlir/Quantizer/Support/TypeUtils.h | 17 +-- .../mlir/Quantizer/Support/UniformConstraints.h | 17 +-- .../mlir/Quantizer/Support/UniformSolvers.h | 17 +-- mlir/include/mlir/Quantizer/Transforms/Passes.h | 17 +-- mlir/include/mlir/Support/DebugStringHelper.h | 17 +-- mlir/include/mlir/Support/FileUtilities.h | 17 +-- mlir/include/mlir/Support/Functional.h | 17 +-- mlir/include/mlir/Support/JitRunner.h | 17 +-- mlir/include/mlir/Support/LLVM.h | 17 +-- mlir/include/mlir/Support/LogicalResult.h | 17 +-- mlir/include/mlir/Support/MathExtras.h | 17 +-- mlir/include/mlir/Support/MlirOptMain.h | 17 +-- mlir/include/mlir/Support/STLExtras.h | 17 +-- mlir/include/mlir/Support/StorageUniquer.h | 17 +-- mlir/include/mlir/Support/StringExtras.h | 17 +-- mlir/include/mlir/Support/ToolUtilities.h | 17 +-- mlir/include/mlir/Support/TranslateClParser.h | 17 +-- mlir/include/mlir/TableGen/Argument.h | 17 +-- mlir/include/mlir/TableGen/Attribute.h | 17 +-- mlir/include/mlir/TableGen/Constraint.h | 17 +-- mlir/include/mlir/TableGen/Dialect.h | 17 +-- mlir/include/mlir/TableGen/Format.h | 17 +-- mlir/include/mlir/TableGen/GenInfo.h | 17 +-- mlir/include/mlir/TableGen/GenNameParser.h | 17 +-- mlir/include/mlir/TableGen/OpInterfaces.h | 17 +-- mlir/include/mlir/TableGen/OpTrait.h | 17 +-- mlir/include/mlir/TableGen/Operator.h | 17 +-- mlir/include/mlir/TableGen/Pattern.h | 17 +-- mlir/include/mlir/TableGen/Predicate.h | 17 +-- mlir/include/mlir/TableGen/Region.h | 17 +-- mlir/include/mlir/TableGen/Type.h | 17 +-- mlir/include/mlir/Target/LLVMIR.h | 17 +-- .../include/mlir/Target/LLVMIR/ModuleTranslation.h | 17 +-- mlir/include/mlir/Target/NVVMIR.h | 17 +-- mlir/include/mlir/Target/ROCDLIR.h | 17 +-- mlir/include/mlir/Transforms/DialectConversion.h | 17 +-- mlir/include/mlir/Transforms/FoldUtils.h | 17 +-- mlir/include/mlir/Transforms/InliningUtils.h | 17 +-- mlir/include/mlir/Transforms/LoopFusionUtils.h | 17 +-- mlir/include/mlir/Transforms/LoopLikeInterface.h | 17 +-- mlir/include/mlir/Transforms/LoopLikeInterface.td | 17 +-- mlir/include/mlir/Transforms/LoopUtils.h | 17 +-- mlir/include/mlir/Transforms/Passes.h | 17 +-- mlir/include/mlir/Transforms/RegionUtils.h | 17 +-- .../include/mlir/Transforms/SideEffectsInterface.h | 17 +-- mlir/include/mlir/Transforms/Utils.h | 17 +-- mlir/include/mlir/Transforms/ViewOpGraph.h | 17 +-- mlir/include/mlir/Transforms/ViewRegionGraph.h | 17 +-- mlir/include/mlir/Translation.h | 17 +-- mlir/lib/Analysis/AffineAnalysis.cpp | 17 +-- mlir/lib/Analysis/AffineStructures.cpp | 17 +-- mlir/lib/Analysis/CallGraph.cpp | 17 +-- mlir/lib/Analysis/Dominance.cpp | 17 +-- mlir/lib/Analysis/InferTypeOpInterface.cpp | 17 +-- mlir/lib/Analysis/Liveness.cpp | 17 +-- mlir/lib/Analysis/LoopAnalysis.cpp | 17 +-- mlir/lib/Analysis/MemRefBoundCheck.cpp | 17 +-- mlir/lib/Analysis/NestedMatcher.cpp | 17 +-- mlir/lib/Analysis/OpStats.cpp | 17 +-- mlir/lib/Analysis/SliceAnalysis.cpp | 17 +-- mlir/lib/Analysis/TestMemRefDependenceCheck.cpp | 17 +-- mlir/lib/Analysis/TestParallelismDetection.cpp | 17 +-- mlir/lib/Analysis/Utils.cpp | 17 +-- mlir/lib/Analysis/VectorAnalysis.cpp | 17 +-- mlir/lib/Analysis/Verifier.cpp | 17 +-- .../AffineToStandard/AffineToStandard.cpp | 17 +-- .../GPUCommon/IndexIntrinsicsOpLowering.h | 17 +-- .../Conversion/GPUCommon/OpToFuncCallLowering.h | 17 +-- .../GPUToCUDA/ConvertKernelFuncToCubin.cpp | 17 +-- .../GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp | 17 +-- mlir/lib/Conversion/GPUToNVVM/GPUToNVVM.td | 17 +-- .../Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp | 17 +-- .../GPUToROCDL/LowerGpuOpsToROCDLOps.cpp | 17 +-- .../Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp | 17 +-- .../GPUToSPIRV/ConvertGPUToSPIRVPass.cpp | 17 +-- mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp | 17 +-- .../LoopToStandard/ConvertLoopToStandard.cpp | 17 +-- mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp | 17 +-- mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp | 17 +-- .../StandardToLLVM/ConvertStandardToLLVM.cpp | 17 +-- .../StandardToSPIRV/ConvertStandardToSPIRV.cpp | 17 +-- .../StandardToSPIRV/ConvertStandardToSPIRVPass.cpp | 17 +-- .../StandardToSPIRV/LegalizeStandardForSPIRV.cpp | 17 +-- .../VectorToLLVM/ConvertVectorToLLVM.cpp | 17 +-- .../VectorToLoops/ConvertVectorToLoops.cpp | 17 +-- mlir/lib/Dialect/AffineOps/AffineOps.cpp | 17 +-- mlir/lib/Dialect/AffineOps/DialectRegistration.cpp | 17 +-- .../Dialect/FxpMathOps/IR/DialectRegistration.cpp | 17 +-- mlir/lib/Dialect/FxpMathOps/IR/FxpMathOps.cpp | 17 +-- .../FxpMathOps/Transforms/LowerUniformRealMath.cpp | 17 +-- .../FxpMathOps/Transforms/UniformKernelUtils.h | 17 +-- mlir/lib/Dialect/GPU/IR/DialectRegistration.cpp | 17 +-- mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | 17 +-- .../lib/Dialect/GPU/Transforms/KernelOutlining.cpp | 17 +-- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 17 +-- mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp | 17 +-- mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp | 17 +-- .../Dialect/Linalg/Analysis/DependenceAnalysis.cpp | 17 +-- mlir/lib/Dialect/Linalg/EDSC/Builders.cpp | 17 +-- mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | 17 +-- mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp | 17 +-- mlir/lib/Dialect/Linalg/LinalgRegistration.cpp | 17 +-- mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp | 17 +-- .../Dialect/Linalg/Transforms/LinalgToLoops.cpp | 17 +-- .../Dialect/Linalg/Transforms/LinalgTransforms.cpp | 17 +-- mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp | 17 +-- mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp | 17 +-- mlir/lib/Dialect/Linalg/Utils/Utils.cpp | 17 +-- mlir/lib/Dialect/LoopOps/DialectRegistration.cpp | 17 +-- mlir/lib/Dialect/LoopOps/LoopOps.cpp | 17 +-- .../Dialect/QuantOps/IR/DialectRegistration.cpp | 17 +-- mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp | 17 +-- mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp | 17 +-- mlir/lib/Dialect/QuantOps/IR/TypeDetail.h | 17 +-- mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp | 17 +-- .../Dialect/QuantOps/Transforms/ConvertConst.cpp | 17 +-- .../QuantOps/Transforms/ConvertSimQuant.cpp | 17 +-- .../Dialect/QuantOps/Utils/FakeQuantSupport.cpp | 17 +-- mlir/lib/Dialect/QuantOps/Utils/QuantizeUtils.cpp | 17 +-- mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp | 17 +-- mlir/lib/Dialect/SDBM/SDBM.cpp | 17 +-- mlir/lib/Dialect/SDBM/SDBMDialect.cpp | 17 +-- mlir/lib/Dialect/SDBM/SDBMExpr.cpp | 17 +-- mlir/lib/Dialect/SDBM/SDBMExprDetail.h | 17 +-- mlir/lib/Dialect/SPIRV/DialectRegistration.cpp | 17 +-- mlir/lib/Dialect/SPIRV/LayoutUtils.cpp | 17 +-- mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp | 17 +-- mlir/lib/Dialect/SPIRV/SPIRVOps.cpp | 17 +-- mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp | 17 +-- .../Dialect/SPIRV/Serialization/Deserializer.cpp | 17 +-- .../SPIRV/Serialization/SPIRVBinaryUtils.cpp | 17 +-- .../lib/Dialect/SPIRV/Serialization/Serializer.cpp | 17 +-- .../SPIRV/Serialization/TranslateRegistration.cpp | 17 +-- .../DecorateSPIRVCompositeTypeLayoutPass.cpp | 17 +-- .../SPIRV/Transforms/LowerABIAttributesPass.cpp | 17 +-- .../Dialect/StandardOps/DialectRegistration.cpp | 17 +-- mlir/lib/Dialect/StandardOps/Ops.cpp | 17 +-- mlir/lib/Dialect/Traits.cpp | 17 +-- mlir/lib/Dialect/VectorOps/DialectRegistration.cpp | 17 +-- mlir/lib/Dialect/VectorOps/VectorOps.cpp | 17 +-- mlir/lib/Dialect/VectorOps/VectorTransforms.cpp | 17 +-- mlir/lib/EDSC/Builders.cpp | 17 +-- mlir/lib/EDSC/CoreAPIs.cpp | 17 +-- mlir/lib/EDSC/Helpers.cpp | 17 +-- mlir/lib/EDSC/Intrinsics.cpp | 17 +-- mlir/lib/ExecutionEngine/ExecutionEngine.cpp | 17 +-- mlir/lib/ExecutionEngine/OptUtils.cpp | 17 +-- mlir/lib/IR/AffineExpr.cpp | 17 +-- mlir/lib/IR/AffineExprDetail.h | 17 +-- mlir/lib/IR/AffineMap.cpp | 17 +-- mlir/lib/IR/AffineMapDetail.h | 17 +-- mlir/lib/IR/AsmPrinter.cpp | 17 +-- mlir/lib/IR/AttributeDetail.h | 17 +-- mlir/lib/IR/Attributes.cpp | 17 +-- mlir/lib/IR/Block.cpp | 17 +-- mlir/lib/IR/Builders.cpp | 17 +-- mlir/lib/IR/Diagnostics.cpp | 17 +-- mlir/lib/IR/Dialect.cpp | 17 +-- mlir/lib/IR/Function.cpp | 17 +-- mlir/lib/IR/FunctionImplementation.cpp | 17 +-- mlir/lib/IR/IntegerSet.cpp | 17 +-- mlir/lib/IR/IntegerSetDetail.h | 17 +-- mlir/lib/IR/Location.cpp | 17 +-- mlir/lib/IR/LocationDetail.h | 17 +-- mlir/lib/IR/MLIRContext.cpp | 17 +-- mlir/lib/IR/Module.cpp | 17 +-- mlir/lib/IR/Operation.cpp | 17 +-- mlir/lib/IR/OperationSupport.cpp | 17 +-- mlir/lib/IR/PatternMatch.cpp | 17 +-- mlir/lib/IR/Region.cpp | 17 +-- mlir/lib/IR/StandardTypes.cpp | 17 +-- mlir/lib/IR/SymbolTable.cpp | 17 +-- mlir/lib/IR/TypeDetail.h | 17 +-- mlir/lib/IR/TypeUtilities.cpp | 17 +-- mlir/lib/IR/Types.cpp | 17 +-- mlir/lib/IR/Value.cpp | 17 +-- mlir/lib/IR/Visitors.cpp | 17 +-- mlir/lib/Parser/Lexer.cpp | 17 +-- mlir/lib/Parser/Lexer.h | 17 +-- mlir/lib/Parser/Parser.cpp | 17 +-- mlir/lib/Parser/Token.cpp | 17 +-- mlir/lib/Parser/Token.h | 17 +-- mlir/lib/Parser/TokenKinds.def | 17 +-- mlir/lib/Pass/IRPrinting.cpp | 17 +-- mlir/lib/Pass/Pass.cpp | 17 +-- mlir/lib/Pass/PassDetail.h | 17 +-- mlir/lib/Pass/PassManagerOptions.cpp | 17 +-- mlir/lib/Pass/PassRegistry.cpp | 17 +-- mlir/lib/Pass/PassStatistics.cpp | 17 +-- mlir/lib/Pass/PassTiming.cpp | 17 +-- .../lib/Quantizer/Configurations/FxpMathConfig.cpp | 17 +-- mlir/lib/Quantizer/Support/Configuration.cpp | 17 +-- .../Quantizer/Support/ConstraintAnalysisGraph.cpp | 17 +-- mlir/lib/Quantizer/Support/Metadata.cpp | 17 +-- mlir/lib/Quantizer/Support/Statistics.cpp | 17 +-- mlir/lib/Quantizer/Support/TypeUtils.cpp | 17 +-- mlir/lib/Quantizer/Support/UniformConstraints.cpp | 17 +-- mlir/lib/Quantizer/Support/UniformSolvers.cpp | 17 +-- .../Transforms/AddDefaultStatsTestPass.cpp | 17 +-- .../Transforms/InferQuantizedTypesPass.cpp | 17 +-- .../Transforms/RemoveInstrumentationPass.cpp | 17 +-- mlir/lib/Support/FileUtilities.cpp | 17 +-- mlir/lib/Support/JitRunner.cpp | 17 +-- mlir/lib/Support/MlirOptMain.cpp | 17 +-- mlir/lib/Support/StorageUniquer.cpp | 17 +-- mlir/lib/Support/ToolUtilities.cpp | 17 +-- mlir/lib/Support/TranslateClParser.cpp | 17 +-- mlir/lib/TableGen/Argument.cpp | 17 +-- mlir/lib/TableGen/Attribute.cpp | 17 +-- mlir/lib/TableGen/Constraint.cpp | 17 +-- mlir/lib/TableGen/Dialect.cpp | 17 +-- mlir/lib/TableGen/Format.cpp | 17 +-- mlir/lib/TableGen/OpInterfaces.cpp | 17 +-- mlir/lib/TableGen/OpTrait.cpp | 17 +-- mlir/lib/TableGen/Operator.cpp | 17 +-- mlir/lib/TableGen/Pattern.cpp | 17 +-- mlir/lib/TableGen/Predicate.cpp | 17 +-- mlir/lib/TableGen/Type.cpp | 17 +-- mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp | 17 +-- mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp | 17 +-- mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp | 17 +-- mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp | 17 +-- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 17 +-- mlir/lib/Transforms/AffineDataCopyGeneration.cpp | 17 +-- .../Transforms/AffineLoopInvariantCodeMotion.cpp | 17 +-- mlir/lib/Transforms/CSE.cpp | 17 +-- mlir/lib/Transforms/Canonicalizer.cpp | 17 +-- mlir/lib/Transforms/DialectConversion.cpp | 17 +-- mlir/lib/Transforms/Inliner.cpp | 17 +-- mlir/lib/Transforms/LoopCoalescing.cpp | 17 +-- mlir/lib/Transforms/LoopFusion.cpp | 17 +-- mlir/lib/Transforms/LoopInvariantCodeMotion.cpp | 17 +-- mlir/lib/Transforms/LoopTiling.cpp | 17 +-- mlir/lib/Transforms/LoopUnroll.cpp | 17 +-- mlir/lib/Transforms/LoopUnrollAndJam.cpp | 17 +-- mlir/lib/Transforms/MemRefDataFlowOpt.cpp | 17 +-- mlir/lib/Transforms/PipelineDataTransfer.cpp | 17 +-- mlir/lib/Transforms/SimplifyAffineStructures.cpp | 17 +-- mlir/lib/Transforms/StripDebugInfo.cpp | 17 +-- mlir/lib/Transforms/Utils/FoldUtils.cpp | 17 +-- .../Utils/GreedyPatternRewriteDriver.cpp | 17 +-- mlir/lib/Transforms/Utils/InliningUtils.cpp | 17 +-- mlir/lib/Transforms/Utils/LoopFusionUtils.cpp | 17 +-- mlir/lib/Transforms/Utils/LoopUtils.cpp | 17 +-- mlir/lib/Transforms/Utils/RegionUtils.cpp | 17 +-- mlir/lib/Transforms/Utils/Utils.cpp | 17 +-- mlir/lib/Transforms/Vectorize.cpp | 17 +-- mlir/lib/Transforms/ViewOpGraph.cpp | 17 +-- mlir/lib/Transforms/ViewRegionGraph.cpp | 17 +-- mlir/lib/Translation/Translation.cpp | 17 +-- mlir/test/APITest.h | 17 +-- mlir/test/EDSC/builder-api-test.cpp | 17 +-- mlir/test/SDBM/sdbm-api-test.cpp | 17 +-- .../TestLinalgTransformPatterns.td | 17 +-- .../TestVectorTransformPatterns.td | 17 +-- mlir/test/lib/IR/TestFunc.cpp | 17 +-- mlir/test/lib/IR/TestMatchers.cpp | 17 +-- mlir/test/lib/IR/TestSymbolUses.cpp | 17 +-- mlir/test/lib/Pass/TestPassManager.cpp | 17 +-- mlir/test/lib/TestDialect/TestDialect.cpp | 17 +-- mlir/test/lib/TestDialect/TestDialect.h | 17 +-- mlir/test/lib/TestDialect/TestOps.td | 17 +-- mlir/test/lib/TestDialect/TestPatterns.cpp | 17 +-- mlir/test/lib/Transforms/TestCallGraph.cpp | 17 +-- mlir/test/lib/Transforms/TestConstantFold.cpp | 17 +-- mlir/test/lib/Transforms/TestInlining.cpp | 17 +-- mlir/test/lib/Transforms/TestLinalgTransforms.cpp | 17 +-- mlir/test/lib/Transforms/TestLiveness.cpp | 17 +-- mlir/test/lib/Transforms/TestLoopFusion.cpp | 17 +-- mlir/test/lib/Transforms/TestLoopMapping.cpp | 17 +-- .../lib/Transforms/TestLoopParametricTiling.cpp | 17 +-- .../lib/Transforms/TestMemRefStrideCalculation.cpp | 17 +-- mlir/test/lib/Transforms/TestOpaqueLoc.cpp | 17 +-- .../lib/Transforms/TestVectorToLoopsConversion.cpp | 17 +-- mlir/test/lib/Transforms/TestVectorTransforms.cpp | 17 +-- .../test/lib/Transforms/TestVectorizationUtils.cpp | 17 +-- mlir/test/mlir-cpu-runner/cblas.cpp | 17 +-- mlir/test/mlir-cpu-runner/cblas_interface.cpp | 17 +-- mlir/test/mlir-cpu-runner/include/cblas.h | 17 +-- .../mlir-cpu-runner/include/mlir_runner_utils.h | 17 +-- mlir/test/mlir-cpu-runner/mlir_runner_utils.cpp | 17 +-- mlir/tools/mlir-cpu-runner/mlir-cpu-runner.cpp | 17 +-- .../mlir-cuda-runner/cuda-runtime-wrappers.cpp | 17 +-- mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp | 17 +-- mlir/tools/mlir-opt/mlir-opt.cpp | 17 +-- mlir/tools/mlir-tblgen/DocGenUtilities.h | 17 +-- mlir/tools/mlir-tblgen/EnumsGen.cpp | 17 +-- mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp | 17 +-- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 17 +-- mlir/tools/mlir-tblgen/OpDocGen.cpp | 17 +-- mlir/tools/mlir-tblgen/OpInterfacesGen.cpp | 17 +-- mlir/tools/mlir-tblgen/ReferenceImplGen.cpp | 17 +-- mlir/tools/mlir-tblgen/RewriterGen.cpp | 17 +-- mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp | 17 +-- mlir/tools/mlir-tblgen/StructsGen.cpp | 17 +-- mlir/tools/mlir-tblgen/mlir-tblgen.cpp | 17 +-- mlir/tools/mlir-translate/mlir-translate.cpp | 17 +-- mlir/unittests/ADT/TypeSwitchTest.cpp | 17 +-- mlir/unittests/Dialect/BroadcastShapeTest.cpp | 17 +-- .../Dialect/QuantOps/QuantizationUtilsTest.cpp | 17 +-- .../Dialect/SPIRV/DeserializationTest.cpp | 17 +-- mlir/unittests/Dialect/SPIRV/SerializationTest.cpp | 17 +-- mlir/unittests/IR/AttributeTest.cpp | 17 +-- mlir/unittests/IR/DialectTest.cpp | 17 +-- mlir/unittests/IR/OperationSupportTest.cpp | 17 +-- mlir/unittests/IR/StringExtrasTest.cpp | 17 +-- mlir/unittests/Pass/AnalysisManagerTest.cpp | 17 +-- mlir/unittests/Quantizer/Support/RulesTest.cpp | 17 +-- .../Quantizer/Support/UniformSolversTest.cpp | 17 +-- mlir/unittests/SDBM/SDBMTest.cpp | 17 +-- mlir/unittests/TableGen/EnumsGenTest.cpp | 17 +-- mlir/unittests/TableGen/FormatTest.cpp | 17 +-- mlir/unittests/TableGen/StructsGenTest.cpp | 17 +-- mlir/unittests/TableGen/enums.td | 17 +-- mlir/unittests/TableGen/structs.td | 17 +-- mlir/utils/generate-test-checks.py | 16 +-- mlir/utils/spirv/define_enum.sh | 16 +-- mlir/utils/spirv/define_inst.sh | 16 +-- mlir/utils/spirv/define_opcodes.sh | 16 +-- mlir/utils/spirv/gen_spirv_dialect.py | 16 +-- 593 files changed, 2464 insertions(+), 7723 deletions(-) (limited to 'mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp') diff --git a/mlir/LICENSE.TXT b/mlir/LICENSE.TXT index a4b160b6e33..fa6ac540007 100644 --- a/mlir/LICENSE.TXT +++ b/mlir/LICENSE.TXT @@ -1,12 +1,14 @@ -Copyright 2019 The MLIR Authors. +============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - 1. Definitions. + 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. @@ -65,14 +67,14 @@ Copyright 2019 The MLIR Authors. on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. - 2. Grant of Copyright License. Subject to the terms and conditions of + 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. - 3. Grant of Patent License. Subject to the terms and conditions of + 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, @@ -88,7 +90,7 @@ Copyright 2019 The MLIR Authors. granted to You under this License for that Work shall terminate as of the date such litigation is filed. - 4. Redistribution. You may reproduce and distribute copies of the + 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: @@ -129,7 +131,7 @@ Copyright 2019 The MLIR Authors. reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. - 5. Submission of Contributions. Unless You explicitly state otherwise, + 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. @@ -137,12 +139,12 @@ Copyright 2019 The MLIR Authors. the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. - 6. Trademarks. This License does not grant permission to use the trade + 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. - 7. Disclaimer of Warranty. Unless required by applicable law or + 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or @@ -152,7 +154,7 @@ Copyright 2019 The MLIR Authors. appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. - 8. Limitation of Liability. In no event and under no legal theory, + 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be @@ -164,7 +166,7 @@ Copyright 2019 The MLIR Authors. other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - 9. Accepting Warranty or Additional Liability. While redistributing + 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this @@ -175,9 +177,9 @@ Copyright 2019 The MLIR Authors. incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - END OF TERMS AND CONDITIONS + END OF TERMS AND CONDITIONS - APPENDIX: How to apply the Apache License to your work. + APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" @@ -188,18 +190,90 @@ Copyright 2019 The MLIR Authors. same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. + +============================================================================== +Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): +============================================================================== +University of Illinois/NCSA +Open Source License + +Copyright (c) 2003-2019 University of Illinois at Urbana-Champaign. +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. diff --git a/mlir/bindings/python/pybind.cpp b/mlir/bindings/python/pybind.cpp index 54646cbe800..10445edaf12 100644 --- a/mlir/bindings/python/pybind.cpp +++ b/mlir/bindings/python/pybind.cpp @@ -1,19 +1,10 @@ //===- pybind.cpp - MLIR Python bindings ----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" diff --git a/mlir/examples/toy/Ch1/include/toy/AST.h b/mlir/examples/toy/Ch1/include/toy/AST.h index 901164b0f39..820600b5b1c 100644 --- a/mlir/examples/toy/Ch1/include/toy/AST.h +++ b/mlir/examples/toy/Ch1/include/toy/AST.h @@ -1,19 +1,10 @@ //===- AST.h - Node definition for the Toy AST ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST for the Toy language. It is optimized for // simplicity, not efficiency. The AST forms a tree structure where each node diff --git a/mlir/examples/toy/Ch1/include/toy/Lexer.h b/mlir/examples/toy/Ch1/include/toy/Lexer.h index 2e19cd09b20..a77a91bb564 100644 --- a/mlir/examples/toy/Ch1/include/toy/Lexer.h +++ b/mlir/examples/toy/Ch1/include/toy/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - Lexer for the Toy language -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple Lexer for the Toy language. // diff --git a/mlir/examples/toy/Ch1/include/toy/Parser.h b/mlir/examples/toy/Ch1/include/toy/Parser.h index 9e219e56551..4557ea26859 100644 --- a/mlir/examples/toy/Ch1/include/toy/Parser.h +++ b/mlir/examples/toy/Ch1/include/toy/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - Toy Language Parser -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the Toy language. It processes the Token // provided by the Lexer and returns an AST. diff --git a/mlir/examples/toy/Ch1/parser/AST.cpp b/mlir/examples/toy/Ch1/parser/AST.cpp index 3ec91a4300d..0d6d9359529 100644 --- a/mlir/examples/toy/Ch1/parser/AST.cpp +++ b/mlir/examples/toy/Ch1/parser/AST.cpp @@ -1,19 +1,10 @@ //===- AST.cpp - Helper for printing out the Toy AST ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST dump for the Toy language. // diff --git a/mlir/examples/toy/Ch1/toyc.cpp b/mlir/examples/toy/Ch1/toyc.cpp index 37794d5c4d9..48863fa931c 100644 --- a/mlir/examples/toy/Ch1/toyc.cpp +++ b/mlir/examples/toy/Ch1/toyc.cpp @@ -1,19 +1,10 @@ //===- toyc.cpp - The Toy Compiler ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the entry point for the Toy compiler. // diff --git a/mlir/examples/toy/Ch2/include/toy/AST.h b/mlir/examples/toy/Ch2/include/toy/AST.h index 901164b0f39..820600b5b1c 100644 --- a/mlir/examples/toy/Ch2/include/toy/AST.h +++ b/mlir/examples/toy/Ch2/include/toy/AST.h @@ -1,19 +1,10 @@ //===- AST.h - Node definition for the Toy AST ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST for the Toy language. It is optimized for // simplicity, not efficiency. The AST forms a tree structure where each node diff --git a/mlir/examples/toy/Ch2/include/toy/Dialect.h b/mlir/examples/toy/Ch2/include/toy/Dialect.h index 91dd631d2ff..385d6ddb95a 100644 --- a/mlir/examples/toy/Ch2/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch2/include/toy/Dialect.h @@ -1,19 +1,10 @@ //===- Dialect.h - Dialect definition for the Toy IR ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the IR Dialect for the Toy language. // See g3doc/Tutorials/Toy/Ch-2.md for more information. diff --git a/mlir/examples/toy/Ch2/include/toy/Lexer.h b/mlir/examples/toy/Ch2/include/toy/Lexer.h index 144388c460c..6eff64ee5f0 100644 --- a/mlir/examples/toy/Ch2/include/toy/Lexer.h +++ b/mlir/examples/toy/Ch2/include/toy/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - Lexer for the Toy language -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple Lexer for the Toy language. // diff --git a/mlir/examples/toy/Ch2/include/toy/MLIRGen.h b/mlir/examples/toy/Ch2/include/toy/MLIRGen.h index 287f432c847..e1c8ca1201d 100644 --- a/mlir/examples/toy/Ch2/include/toy/MLIRGen.h +++ b/mlir/examples/toy/Ch2/include/toy/MLIRGen.h @@ -1,19 +1,10 @@ //===- MLIRGen.h - MLIR Generation from a Toy AST -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares a simple interface to perform IR generation targeting MLIR // from a Module AST for the Toy language. diff --git a/mlir/examples/toy/Ch2/include/toy/Ops.td b/mlir/examples/toy/Ch2/include/toy/Ops.td index dd88b097ab1..20c4a7463d9 100644 --- a/mlir/examples/toy/Ch2/include/toy/Ops.td +++ b/mlir/examples/toy/Ch2/include/toy/Ops.td @@ -1,19 +1,10 @@ //===- Ops.td - Toy dialect operation definitions ----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Toy dialect. // diff --git a/mlir/examples/toy/Ch2/include/toy/Parser.h b/mlir/examples/toy/Ch2/include/toy/Parser.h index 9e219e56551..4557ea26859 100644 --- a/mlir/examples/toy/Ch2/include/toy/Parser.h +++ b/mlir/examples/toy/Ch2/include/toy/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - Toy Language Parser -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the Toy language. It processes the Token // provided by the Lexer and returns an AST. diff --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp index 4a3232dabe3..b33cb5cbfe9 100644 --- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Toy IR Dialect registration in MLIR ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the dialect for the Toy IR: custom type parsing and // operation verification. diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp index 902c634a954..e9987ff2c77 100644 --- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp @@ -1,19 +1,10 @@ //===- MLIRGen.cpp - MLIR Generation from a Toy AST -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple IR generation targeting MLIR from a Module AST // for the Toy language. diff --git a/mlir/examples/toy/Ch2/parser/AST.cpp b/mlir/examples/toy/Ch2/parser/AST.cpp index 3ec91a4300d..0d6d9359529 100644 --- a/mlir/examples/toy/Ch2/parser/AST.cpp +++ b/mlir/examples/toy/Ch2/parser/AST.cpp @@ -1,19 +1,10 @@ //===- AST.cpp - Helper for printing out the Toy AST ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST dump for the Toy language. // diff --git a/mlir/examples/toy/Ch2/toyc.cpp b/mlir/examples/toy/Ch2/toyc.cpp index 19def702589..3e3db97b4ae 100644 --- a/mlir/examples/toy/Ch2/toyc.cpp +++ b/mlir/examples/toy/Ch2/toyc.cpp @@ -1,19 +1,10 @@ //===- toyc.cpp - The Toy Compiler ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the entry point for the Toy compiler. // diff --git a/mlir/examples/toy/Ch3/include/toy/AST.h b/mlir/examples/toy/Ch3/include/toy/AST.h index 901164b0f39..820600b5b1c 100644 --- a/mlir/examples/toy/Ch3/include/toy/AST.h +++ b/mlir/examples/toy/Ch3/include/toy/AST.h @@ -1,19 +1,10 @@ //===- AST.h - Node definition for the Toy AST ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST for the Toy language. It is optimized for // simplicity, not efficiency. The AST forms a tree structure where each node diff --git a/mlir/examples/toy/Ch3/include/toy/Dialect.h b/mlir/examples/toy/Ch3/include/toy/Dialect.h index 91dd631d2ff..385d6ddb95a 100644 --- a/mlir/examples/toy/Ch3/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch3/include/toy/Dialect.h @@ -1,19 +1,10 @@ //===- Dialect.h - Dialect definition for the Toy IR ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the IR Dialect for the Toy language. // See g3doc/Tutorials/Toy/Ch-2.md for more information. diff --git a/mlir/examples/toy/Ch3/include/toy/Lexer.h b/mlir/examples/toy/Ch3/include/toy/Lexer.h index 144388c460c..6eff64ee5f0 100644 --- a/mlir/examples/toy/Ch3/include/toy/Lexer.h +++ b/mlir/examples/toy/Ch3/include/toy/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - Lexer for the Toy language -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple Lexer for the Toy language. // diff --git a/mlir/examples/toy/Ch3/include/toy/MLIRGen.h b/mlir/examples/toy/Ch3/include/toy/MLIRGen.h index 287f432c847..e1c8ca1201d 100644 --- a/mlir/examples/toy/Ch3/include/toy/MLIRGen.h +++ b/mlir/examples/toy/Ch3/include/toy/MLIRGen.h @@ -1,19 +1,10 @@ //===- MLIRGen.h - MLIR Generation from a Toy AST -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares a simple interface to perform IR generation targeting MLIR // from a Module AST for the Toy language. diff --git a/mlir/examples/toy/Ch3/include/toy/Ops.td b/mlir/examples/toy/Ch3/include/toy/Ops.td index 6c400169da2..a6c93ccba10 100644 --- a/mlir/examples/toy/Ch3/include/toy/Ops.td +++ b/mlir/examples/toy/Ch3/include/toy/Ops.td @@ -1,19 +1,10 @@ //===- Ops.td - Toy dialect operation definitions ----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Toy dialect. // diff --git a/mlir/examples/toy/Ch3/include/toy/Parser.h b/mlir/examples/toy/Ch3/include/toy/Parser.h index 9e219e56551..4557ea26859 100644 --- a/mlir/examples/toy/Ch3/include/toy/Parser.h +++ b/mlir/examples/toy/Ch3/include/toy/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - Toy Language Parser -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the Toy language. It processes the Token // provided by the Lexer and returns an AST. diff --git a/mlir/examples/toy/Ch3/mlir/Dialect.cpp b/mlir/examples/toy/Ch3/mlir/Dialect.cpp index 4a3232dabe3..b33cb5cbfe9 100644 --- a/mlir/examples/toy/Ch3/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch3/mlir/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Toy IR Dialect registration in MLIR ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the dialect for the Toy IR: custom type parsing and // operation verification. diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp index 902c634a954..e9987ff2c77 100644 --- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp @@ -1,19 +1,10 @@ //===- MLIRGen.cpp - MLIR Generation from a Toy AST -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple IR generation targeting MLIR from a Module AST // for the Toy language. diff --git a/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp index 42a10397513..d52a2c173c1 100644 --- a/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp @@ -1,19 +1,10 @@ //===- ToyCombine.cpp - Toy High Level Optimizer --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a set of simple combiners for optimizing operations in // the Toy dialect. diff --git a/mlir/examples/toy/Ch3/mlir/ToyCombine.td b/mlir/examples/toy/Ch3/mlir/ToyCombine.td index 1ca143a913c..e6e33e84d7e 100644 --- a/mlir/examples/toy/Ch3/mlir/ToyCombine.td +++ b/mlir/examples/toy/Ch3/mlir/ToyCombine.td @@ -1,19 +1,10 @@ //===- ToyCombine.td - Pattern Match Optimizations for Toy -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines language-specific pattern match optimizations for Toy using // Declarative Rewrite Rules (DRR) specified using TableGen records. diff --git a/mlir/examples/toy/Ch3/parser/AST.cpp b/mlir/examples/toy/Ch3/parser/AST.cpp index 3ec91a4300d..0d6d9359529 100644 --- a/mlir/examples/toy/Ch3/parser/AST.cpp +++ b/mlir/examples/toy/Ch3/parser/AST.cpp @@ -1,19 +1,10 @@ //===- AST.cpp - Helper for printing out the Toy AST ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST dump for the Toy language. // diff --git a/mlir/examples/toy/Ch3/toyc.cpp b/mlir/examples/toy/Ch3/toyc.cpp index 410a9d677e8..e8b6e94786b 100644 --- a/mlir/examples/toy/Ch3/toyc.cpp +++ b/mlir/examples/toy/Ch3/toyc.cpp @@ -1,19 +1,10 @@ //===- toyc.cpp - The Toy Compiler ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the entry point for the Toy compiler. // diff --git a/mlir/examples/toy/Ch4/include/toy/AST.h b/mlir/examples/toy/Ch4/include/toy/AST.h index 901164b0f39..820600b5b1c 100644 --- a/mlir/examples/toy/Ch4/include/toy/AST.h +++ b/mlir/examples/toy/Ch4/include/toy/AST.h @@ -1,19 +1,10 @@ //===- AST.h - Node definition for the Toy AST ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST for the Toy language. It is optimized for // simplicity, not efficiency. The AST forms a tree structure where each node diff --git a/mlir/examples/toy/Ch4/include/toy/Dialect.h b/mlir/examples/toy/Ch4/include/toy/Dialect.h index 556ae972b84..5e8b91dcf48 100644 --- a/mlir/examples/toy/Ch4/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch4/include/toy/Dialect.h @@ -1,19 +1,10 @@ //===- Dialect.h - Dialect definition for the Toy IR ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the IR Dialect for the Toy language. // See g3doc/Tutorials/Toy/Ch-2.md for more information. diff --git a/mlir/examples/toy/Ch4/include/toy/Lexer.h b/mlir/examples/toy/Ch4/include/toy/Lexer.h index 144388c460c..6eff64ee5f0 100644 --- a/mlir/examples/toy/Ch4/include/toy/Lexer.h +++ b/mlir/examples/toy/Ch4/include/toy/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - Lexer for the Toy language -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple Lexer for the Toy language. // diff --git a/mlir/examples/toy/Ch4/include/toy/MLIRGen.h b/mlir/examples/toy/Ch4/include/toy/MLIRGen.h index 287f432c847..e1c8ca1201d 100644 --- a/mlir/examples/toy/Ch4/include/toy/MLIRGen.h +++ b/mlir/examples/toy/Ch4/include/toy/MLIRGen.h @@ -1,19 +1,10 @@ //===- MLIRGen.h - MLIR Generation from a Toy AST -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares a simple interface to perform IR generation targeting MLIR // from a Module AST for the Toy language. diff --git a/mlir/examples/toy/Ch4/include/toy/Ops.td b/mlir/examples/toy/Ch4/include/toy/Ops.td index ef5b30a862b..71167664bbc 100644 --- a/mlir/examples/toy/Ch4/include/toy/Ops.td +++ b/mlir/examples/toy/Ch4/include/toy/Ops.td @@ -1,19 +1,10 @@ //===- Ops.td - Toy dialect operation definitions ----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Toy dialect. // diff --git a/mlir/examples/toy/Ch4/include/toy/Parser.h b/mlir/examples/toy/Ch4/include/toy/Parser.h index 9e219e56551..4557ea26859 100644 --- a/mlir/examples/toy/Ch4/include/toy/Parser.h +++ b/mlir/examples/toy/Ch4/include/toy/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - Toy Language Parser -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the Toy language. It processes the Token // provided by the Lexer and returns an AST. diff --git a/mlir/examples/toy/Ch4/include/toy/Passes.h b/mlir/examples/toy/Ch4/include/toy/Passes.h index 8c8365d6882..93c51309008 100644 --- a/mlir/examples/toy/Ch4/include/toy/Passes.h +++ b/mlir/examples/toy/Ch4/include/toy/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Toy Passes Definition -----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file exposes the entry points to create compiler passes for Toy. // diff --git a/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.h b/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.h index fc36b5b100d..da0fb66018e 100644 --- a/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.h +++ b/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.h @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.h - Interface definitions for ShapeInference -=// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the declarations of the shape inference interfaces defined // in ShapeInferenceInterface.td. diff --git a/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.td b/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.td index 6974575a63c..1b38ada1622 100644 --- a/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.td +++ b/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.td @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.td - Shape Inference Interface -*- tablegen -==// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Shape Inference Op Interface. // diff --git a/mlir/examples/toy/Ch4/mlir/DeadFunctionEliminationPass.cpp b/mlir/examples/toy/Ch4/mlir/DeadFunctionEliminationPass.cpp index b58adb5d52f..1ee34547860 100644 --- a/mlir/examples/toy/Ch4/mlir/DeadFunctionEliminationPass.cpp +++ b/mlir/examples/toy/Ch4/mlir/DeadFunctionEliminationPass.cpp @@ -1,19 +1,10 @@ //===- DeadFunctionEliminationPass.cpp - Eliminate inlined functions ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Module level pass performing dead function // elimination. This is required as a post-processing step after function diff --git a/mlir/examples/toy/Ch4/mlir/Dialect.cpp b/mlir/examples/toy/Ch4/mlir/Dialect.cpp index 8be1094cf15..50116b14bea 100644 --- a/mlir/examples/toy/Ch4/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch4/mlir/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Toy IR Dialect registration in MLIR ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the dialect for the Toy IR: custom type parsing and // operation verification. diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp index 902c634a954..e9987ff2c77 100644 --- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp @@ -1,19 +1,10 @@ //===- MLIRGen.cpp - MLIR Generation from a Toy AST -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple IR generation targeting MLIR from a Module AST // for the Toy language. diff --git a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp index 1f572015c39..517a1f07530 100644 --- a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp @@ -1,19 +1,10 @@ //===- ShapeInferencePass.cpp - Shape Inference ---------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Function level pass performing interprocedural // propagation of array shapes through function specialization. diff --git a/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp index 604e9fa6c83..2cbf8bdac9b 100644 --- a/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp @@ -1,19 +1,10 @@ //===- ToyCombine.cpp - Toy High Level Optimizer --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a set of simple combiners for optimizing operations in // the Toy dialect. diff --git a/mlir/examples/toy/Ch4/mlir/ToyCombine.td b/mlir/examples/toy/Ch4/mlir/ToyCombine.td index 1ca143a913c..e6e33e84d7e 100644 --- a/mlir/examples/toy/Ch4/mlir/ToyCombine.td +++ b/mlir/examples/toy/Ch4/mlir/ToyCombine.td @@ -1,19 +1,10 @@ //===- ToyCombine.td - Pattern Match Optimizations for Toy -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines language-specific pattern match optimizations for Toy using // Declarative Rewrite Rules (DRR) specified using TableGen records. diff --git a/mlir/examples/toy/Ch4/parser/AST.cpp b/mlir/examples/toy/Ch4/parser/AST.cpp index 3ec91a4300d..0d6d9359529 100644 --- a/mlir/examples/toy/Ch4/parser/AST.cpp +++ b/mlir/examples/toy/Ch4/parser/AST.cpp @@ -1,19 +1,10 @@ //===- AST.cpp - Helper for printing out the Toy AST ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST dump for the Toy language. // diff --git a/mlir/examples/toy/Ch4/toyc.cpp b/mlir/examples/toy/Ch4/toyc.cpp index 5ec514ac5b9..e7b584407f6 100644 --- a/mlir/examples/toy/Ch4/toyc.cpp +++ b/mlir/examples/toy/Ch4/toyc.cpp @@ -1,19 +1,10 @@ //===- toyc.cpp - The Toy Compiler ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the entry point for the Toy compiler. // diff --git a/mlir/examples/toy/Ch5/include/toy/AST.h b/mlir/examples/toy/Ch5/include/toy/AST.h index 901164b0f39..820600b5b1c 100644 --- a/mlir/examples/toy/Ch5/include/toy/AST.h +++ b/mlir/examples/toy/Ch5/include/toy/AST.h @@ -1,19 +1,10 @@ //===- AST.h - Node definition for the Toy AST ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST for the Toy language. It is optimized for // simplicity, not efficiency. The AST forms a tree structure where each node diff --git a/mlir/examples/toy/Ch5/include/toy/Dialect.h b/mlir/examples/toy/Ch5/include/toy/Dialect.h index 556ae972b84..5e8b91dcf48 100644 --- a/mlir/examples/toy/Ch5/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch5/include/toy/Dialect.h @@ -1,19 +1,10 @@ //===- Dialect.h - Dialect definition for the Toy IR ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the IR Dialect for the Toy language. // See g3doc/Tutorials/Toy/Ch-2.md for more information. diff --git a/mlir/examples/toy/Ch5/include/toy/Lexer.h b/mlir/examples/toy/Ch5/include/toy/Lexer.h index 144388c460c..6eff64ee5f0 100644 --- a/mlir/examples/toy/Ch5/include/toy/Lexer.h +++ b/mlir/examples/toy/Ch5/include/toy/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - Lexer for the Toy language -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple Lexer for the Toy language. // diff --git a/mlir/examples/toy/Ch5/include/toy/MLIRGen.h b/mlir/examples/toy/Ch5/include/toy/MLIRGen.h index 287f432c847..e1c8ca1201d 100644 --- a/mlir/examples/toy/Ch5/include/toy/MLIRGen.h +++ b/mlir/examples/toy/Ch5/include/toy/MLIRGen.h @@ -1,19 +1,10 @@ //===- MLIRGen.h - MLIR Generation from a Toy AST -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares a simple interface to perform IR generation targeting MLIR // from a Module AST for the Toy language. diff --git a/mlir/examples/toy/Ch5/include/toy/Ops.td b/mlir/examples/toy/Ch5/include/toy/Ops.td index b3bda1d647b..bb98ae19a09 100644 --- a/mlir/examples/toy/Ch5/include/toy/Ops.td +++ b/mlir/examples/toy/Ch5/include/toy/Ops.td @@ -1,19 +1,10 @@ //===- Ops.td - Toy dialect operation definitions ----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Toy dialect. // diff --git a/mlir/examples/toy/Ch5/include/toy/Parser.h b/mlir/examples/toy/Ch5/include/toy/Parser.h index 9e219e56551..4557ea26859 100644 --- a/mlir/examples/toy/Ch5/include/toy/Parser.h +++ b/mlir/examples/toy/Ch5/include/toy/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - Toy Language Parser -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the Toy language. It processes the Token // provided by the Lexer and returns an AST. diff --git a/mlir/examples/toy/Ch5/include/toy/Passes.h b/mlir/examples/toy/Ch5/include/toy/Passes.h index b6a79eda176..97a5d0db46c 100644 --- a/mlir/examples/toy/Ch5/include/toy/Passes.h +++ b/mlir/examples/toy/Ch5/include/toy/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Toy Passes Definition -----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file exposes the entry points to create compiler passes for Toy. // diff --git a/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.h b/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.h index fc36b5b100d..da0fb66018e 100644 --- a/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.h +++ b/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.h @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.h - Interface definitions for ShapeInference -=// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the declarations of the shape inference interfaces defined // in ShapeInferenceInterface.td. diff --git a/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.td b/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.td index 6974575a63c..1b38ada1622 100644 --- a/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.td +++ b/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.td @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.td - Shape Inference Interface -*- tablegen -==// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Shape Inference Op Interface. // diff --git a/mlir/examples/toy/Ch5/mlir/DeadFunctionEliminationPass.cpp b/mlir/examples/toy/Ch5/mlir/DeadFunctionEliminationPass.cpp index b58adb5d52f..1ee34547860 100644 --- a/mlir/examples/toy/Ch5/mlir/DeadFunctionEliminationPass.cpp +++ b/mlir/examples/toy/Ch5/mlir/DeadFunctionEliminationPass.cpp @@ -1,19 +1,10 @@ //===- DeadFunctionEliminationPass.cpp - Eliminate inlined functions ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Module level pass performing dead function // elimination. This is required as a post-processing step after function diff --git a/mlir/examples/toy/Ch5/mlir/Dialect.cpp b/mlir/examples/toy/Ch5/mlir/Dialect.cpp index 8be1094cf15..50116b14bea 100644 --- a/mlir/examples/toy/Ch5/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch5/mlir/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Toy IR Dialect registration in MLIR ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the dialect for the Toy IR: custom type parsing and // operation verification. diff --git a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp index 3fa761c7404..cba838a2928 100644 --- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp @@ -1,19 +1,10 @@ //====- LowerToAffineLoops.cpp - Partial lowering from Toy to Affine+Std --===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a partial lowering of Toy operations to a combination of // affine loops and standard operations. This lowering expects that all calls diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp index 902c634a954..e9987ff2c77 100644 --- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp @@ -1,19 +1,10 @@ //===- MLIRGen.cpp - MLIR Generation from a Toy AST -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple IR generation targeting MLIR from a Module AST // for the Toy language. diff --git a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp index 1f572015c39..517a1f07530 100644 --- a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp @@ -1,19 +1,10 @@ //===- ShapeInferencePass.cpp - Shape Inference ---------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Function level pass performing interprocedural // propagation of array shapes through function specialization. diff --git a/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp index 604e9fa6c83..2cbf8bdac9b 100644 --- a/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp @@ -1,19 +1,10 @@ //===- ToyCombine.cpp - Toy High Level Optimizer --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a set of simple combiners for optimizing operations in // the Toy dialect. diff --git a/mlir/examples/toy/Ch5/mlir/ToyCombine.td b/mlir/examples/toy/Ch5/mlir/ToyCombine.td index 1ca143a913c..e6e33e84d7e 100644 --- a/mlir/examples/toy/Ch5/mlir/ToyCombine.td +++ b/mlir/examples/toy/Ch5/mlir/ToyCombine.td @@ -1,19 +1,10 @@ //===- ToyCombine.td - Pattern Match Optimizations for Toy -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines language-specific pattern match optimizations for Toy using // Declarative Rewrite Rules (DRR) specified using TableGen records. diff --git a/mlir/examples/toy/Ch5/parser/AST.cpp b/mlir/examples/toy/Ch5/parser/AST.cpp index 3ec91a4300d..0d6d9359529 100644 --- a/mlir/examples/toy/Ch5/parser/AST.cpp +++ b/mlir/examples/toy/Ch5/parser/AST.cpp @@ -1,19 +1,10 @@ //===- AST.cpp - Helper for printing out the Toy AST ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST dump for the Toy language. // diff --git a/mlir/examples/toy/Ch5/toyc.cpp b/mlir/examples/toy/Ch5/toyc.cpp index e1ab8c0ce55..836968e2188 100644 --- a/mlir/examples/toy/Ch5/toyc.cpp +++ b/mlir/examples/toy/Ch5/toyc.cpp @@ -1,19 +1,10 @@ //===- toyc.cpp - The Toy Compiler ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the entry point for the Toy compiler. // diff --git a/mlir/examples/toy/Ch6/include/toy/AST.h b/mlir/examples/toy/Ch6/include/toy/AST.h index 901164b0f39..820600b5b1c 100644 --- a/mlir/examples/toy/Ch6/include/toy/AST.h +++ b/mlir/examples/toy/Ch6/include/toy/AST.h @@ -1,19 +1,10 @@ //===- AST.h - Node definition for the Toy AST ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST for the Toy language. It is optimized for // simplicity, not efficiency. The AST forms a tree structure where each node diff --git a/mlir/examples/toy/Ch6/include/toy/Dialect.h b/mlir/examples/toy/Ch6/include/toy/Dialect.h index 556ae972b84..5e8b91dcf48 100644 --- a/mlir/examples/toy/Ch6/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch6/include/toy/Dialect.h @@ -1,19 +1,10 @@ //===- Dialect.h - Dialect definition for the Toy IR ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the IR Dialect for the Toy language. // See g3doc/Tutorials/Toy/Ch-2.md for more information. diff --git a/mlir/examples/toy/Ch6/include/toy/Lexer.h b/mlir/examples/toy/Ch6/include/toy/Lexer.h index 144388c460c..6eff64ee5f0 100644 --- a/mlir/examples/toy/Ch6/include/toy/Lexer.h +++ b/mlir/examples/toy/Ch6/include/toy/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - Lexer for the Toy language -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple Lexer for the Toy language. // diff --git a/mlir/examples/toy/Ch6/include/toy/MLIRGen.h b/mlir/examples/toy/Ch6/include/toy/MLIRGen.h index 287f432c847..e1c8ca1201d 100644 --- a/mlir/examples/toy/Ch6/include/toy/MLIRGen.h +++ b/mlir/examples/toy/Ch6/include/toy/MLIRGen.h @@ -1,19 +1,10 @@ //===- MLIRGen.h - MLIR Generation from a Toy AST -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares a simple interface to perform IR generation targeting MLIR // from a Module AST for the Toy language. diff --git a/mlir/examples/toy/Ch6/include/toy/Ops.td b/mlir/examples/toy/Ch6/include/toy/Ops.td index b3bda1d647b..bb98ae19a09 100644 --- a/mlir/examples/toy/Ch6/include/toy/Ops.td +++ b/mlir/examples/toy/Ch6/include/toy/Ops.td @@ -1,19 +1,10 @@ //===- Ops.td - Toy dialect operation definitions ----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Toy dialect. // diff --git a/mlir/examples/toy/Ch6/include/toy/Parser.h b/mlir/examples/toy/Ch6/include/toy/Parser.h index 9e219e56551..4557ea26859 100644 --- a/mlir/examples/toy/Ch6/include/toy/Parser.h +++ b/mlir/examples/toy/Ch6/include/toy/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - Toy Language Parser -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the Toy language. It processes the Token // provided by the Lexer and returns an AST. diff --git a/mlir/examples/toy/Ch6/include/toy/Passes.h b/mlir/examples/toy/Ch6/include/toy/Passes.h index 00fe4ffe49b..33c2021c8db 100644 --- a/mlir/examples/toy/Ch6/include/toy/Passes.h +++ b/mlir/examples/toy/Ch6/include/toy/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Toy Passes Definition -----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file exposes the entry points to create compiler passes for Toy. // diff --git a/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.h b/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.h index fc36b5b100d..da0fb66018e 100644 --- a/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.h +++ b/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.h @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.h - Interface definitions for ShapeInference -=// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the declarations of the shape inference interfaces defined // in ShapeInferenceInterface.td. diff --git a/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.td b/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.td index 6974575a63c..1b38ada1622 100644 --- a/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.td +++ b/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.td @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.td - Shape Inference Interface -*- tablegen -==// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Shape Inference Op Interface. // diff --git a/mlir/examples/toy/Ch6/mlir/DeadFunctionEliminationPass.cpp b/mlir/examples/toy/Ch6/mlir/DeadFunctionEliminationPass.cpp index b58adb5d52f..1ee34547860 100644 --- a/mlir/examples/toy/Ch6/mlir/DeadFunctionEliminationPass.cpp +++ b/mlir/examples/toy/Ch6/mlir/DeadFunctionEliminationPass.cpp @@ -1,19 +1,10 @@ //===- DeadFunctionEliminationPass.cpp - Eliminate inlined functions ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Module level pass performing dead function // elimination. This is required as a post-processing step after function diff --git a/mlir/examples/toy/Ch6/mlir/Dialect.cpp b/mlir/examples/toy/Ch6/mlir/Dialect.cpp index 8be1094cf15..50116b14bea 100644 --- a/mlir/examples/toy/Ch6/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch6/mlir/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Toy IR Dialect registration in MLIR ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the dialect for the Toy IR: custom type parsing and // operation verification. diff --git a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp index 3fa761c7404..cba838a2928 100644 --- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp @@ -1,19 +1,10 @@ //====- LowerToAffineLoops.cpp - Partial lowering from Toy to Affine+Std --===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a partial lowering of Toy operations to a combination of // affine loops and standard operations. This lowering expects that all calls diff --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp index c3180b4a92d..377bc11dd27 100644 --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -1,19 +1,10 @@ //====- LowerToLLVM.cpp - Lowering from Toy+Affine+Std to LLVM ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a partial lowering of Toy operations to a combination of // affine loops and standard operations. This lowering expects that all calls diff --git a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp index 902c634a954..e9987ff2c77 100644 --- a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp @@ -1,19 +1,10 @@ //===- MLIRGen.cpp - MLIR Generation from a Toy AST -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple IR generation targeting MLIR from a Module AST // for the Toy language. diff --git a/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp index 1f572015c39..517a1f07530 100644 --- a/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp @@ -1,19 +1,10 @@ //===- ShapeInferencePass.cpp - Shape Inference ---------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Function level pass performing interprocedural // propagation of array shapes through function specialization. diff --git a/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp index 604e9fa6c83..2cbf8bdac9b 100644 --- a/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp @@ -1,19 +1,10 @@ //===- ToyCombine.cpp - Toy High Level Optimizer --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a set of simple combiners for optimizing operations in // the Toy dialect. diff --git a/mlir/examples/toy/Ch6/mlir/ToyCombine.td b/mlir/examples/toy/Ch6/mlir/ToyCombine.td index 1ca143a913c..e6e33e84d7e 100644 --- a/mlir/examples/toy/Ch6/mlir/ToyCombine.td +++ b/mlir/examples/toy/Ch6/mlir/ToyCombine.td @@ -1,19 +1,10 @@ //===- ToyCombine.td - Pattern Match Optimizations for Toy -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines language-specific pattern match optimizations for Toy using // Declarative Rewrite Rules (DRR) specified using TableGen records. diff --git a/mlir/examples/toy/Ch6/parser/AST.cpp b/mlir/examples/toy/Ch6/parser/AST.cpp index 3ec91a4300d..0d6d9359529 100644 --- a/mlir/examples/toy/Ch6/parser/AST.cpp +++ b/mlir/examples/toy/Ch6/parser/AST.cpp @@ -1,19 +1,10 @@ //===- AST.cpp - Helper for printing out the Toy AST ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST dump for the Toy language. // diff --git a/mlir/examples/toy/Ch6/toyc.cpp b/mlir/examples/toy/Ch6/toyc.cpp index 60e3d0f9791..4e5b2afb7c6 100644 --- a/mlir/examples/toy/Ch6/toyc.cpp +++ b/mlir/examples/toy/Ch6/toyc.cpp @@ -1,19 +1,10 @@ //===- toyc.cpp - The Toy Compiler ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the entry point for the Toy compiler. // diff --git a/mlir/examples/toy/Ch7/include/toy/AST.h b/mlir/examples/toy/Ch7/include/toy/AST.h index 558d9deab8e..3d3ae89dbeb 100644 --- a/mlir/examples/toy/Ch7/include/toy/AST.h +++ b/mlir/examples/toy/Ch7/include/toy/AST.h @@ -1,19 +1,10 @@ //===- AST.h - Node definition for the Toy AST ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST for the Toy language. It is optimized for // simplicity, not efficiency. The AST forms a tree structure where each node diff --git a/mlir/examples/toy/Ch7/include/toy/Dialect.h b/mlir/examples/toy/Ch7/include/toy/Dialect.h index b96ff99a5b6..77481b1884f 100644 --- a/mlir/examples/toy/Ch7/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch7/include/toy/Dialect.h @@ -1,19 +1,10 @@ //===- Dialect.h - Dialect definition for the Toy IR ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the IR Dialect for the Toy language. // See g3doc/Tutorials/Toy/Ch-2.md for more information. diff --git a/mlir/examples/toy/Ch7/include/toy/Lexer.h b/mlir/examples/toy/Ch7/include/toy/Lexer.h index 89dc6cba9ff..b41b82f2a0a 100644 --- a/mlir/examples/toy/Ch7/include/toy/Lexer.h +++ b/mlir/examples/toy/Ch7/include/toy/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - Lexer for the Toy language -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple Lexer for the Toy language. // diff --git a/mlir/examples/toy/Ch7/include/toy/MLIRGen.h b/mlir/examples/toy/Ch7/include/toy/MLIRGen.h index 287f432c847..e1c8ca1201d 100644 --- a/mlir/examples/toy/Ch7/include/toy/MLIRGen.h +++ b/mlir/examples/toy/Ch7/include/toy/MLIRGen.h @@ -1,19 +1,10 @@ //===- MLIRGen.h - MLIR Generation from a Toy AST -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares a simple interface to perform IR generation targeting MLIR // from a Module AST for the Toy language. diff --git a/mlir/examples/toy/Ch7/include/toy/Ops.td b/mlir/examples/toy/Ch7/include/toy/Ops.td index 94f1bcf3e82..801aef06934 100644 --- a/mlir/examples/toy/Ch7/include/toy/Ops.td +++ b/mlir/examples/toy/Ch7/include/toy/Ops.td @@ -1,19 +1,10 @@ //===- Ops.td - Toy dialect operation definitions ----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Toy dialect. // diff --git a/mlir/examples/toy/Ch7/include/toy/Parser.h b/mlir/examples/toy/Ch7/include/toy/Parser.h index df6c4fb2f60..d2659e04dac 100644 --- a/mlir/examples/toy/Ch7/include/toy/Parser.h +++ b/mlir/examples/toy/Ch7/include/toy/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - Toy Language Parser -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the Toy language. It processes the Token // provided by the Lexer and returns an AST. diff --git a/mlir/examples/toy/Ch7/include/toy/Passes.h b/mlir/examples/toy/Ch7/include/toy/Passes.h index 00fe4ffe49b..33c2021c8db 100644 --- a/mlir/examples/toy/Ch7/include/toy/Passes.h +++ b/mlir/examples/toy/Ch7/include/toy/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Toy Passes Definition -----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file exposes the entry points to create compiler passes for Toy. // diff --git a/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.h b/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.h index fc36b5b100d..da0fb66018e 100644 --- a/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.h +++ b/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.h @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.h - Interface definitions for ShapeInference -=// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the declarations of the shape inference interfaces defined // in ShapeInferenceInterface.td. diff --git a/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.td b/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.td index 6974575a63c..1b38ada1622 100644 --- a/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.td +++ b/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.td @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.td - Shape Inference Interface -*- tablegen -==// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Shape Inference Op Interface. // diff --git a/mlir/examples/toy/Ch7/mlir/DeadFunctionEliminationPass.cpp b/mlir/examples/toy/Ch7/mlir/DeadFunctionEliminationPass.cpp index b58adb5d52f..1ee34547860 100644 --- a/mlir/examples/toy/Ch7/mlir/DeadFunctionEliminationPass.cpp +++ b/mlir/examples/toy/Ch7/mlir/DeadFunctionEliminationPass.cpp @@ -1,19 +1,10 @@ //===- DeadFunctionEliminationPass.cpp - Eliminate inlined functions ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Module level pass performing dead function // elimination. This is required as a post-processing step after function diff --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp index 0ce896db5de..4f4cbdf2f0f 100644 --- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Toy IR Dialect registration in MLIR ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the dialect for the Toy IR: custom type parsing and // operation verification. diff --git a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp index 3fa761c7404..cba838a2928 100644 --- a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp @@ -1,19 +1,10 @@ //====- LowerToAffineLoops.cpp - Partial lowering from Toy to Affine+Std --===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a partial lowering of Toy operations to a combination of // affine loops and standard operations. This lowering expects that all calls diff --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp index c3180b4a92d..377bc11dd27 100644 --- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp @@ -1,19 +1,10 @@ //====- LowerToLLVM.cpp - Lowering from Toy+Affine+Std to LLVM ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a partial lowering of Toy operations to a combination of // affine loops and standard operations. This lowering expects that all calls diff --git a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp index 590b21e53a1..62e8c553709 100644 --- a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp @@ -1,19 +1,10 @@ //===- MLIRGen.cpp - MLIR Generation from a Toy AST -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple IR generation targeting MLIR from a Module AST // for the Toy language. diff --git a/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp index 1f572015c39..517a1f07530 100644 --- a/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp @@ -1,19 +1,10 @@ //===- ShapeInferencePass.cpp - Shape Inference ---------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Function level pass performing interprocedural // propagation of array shapes through function specialization. diff --git a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp index d18396c63bb..2fb0a1c5b69 100644 --- a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp @@ -1,19 +1,10 @@ //===- ToyCombine.cpp - Toy High Level Optimizer --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a set of simple combiners for optimizing operations in // the Toy dialect. diff --git a/mlir/examples/toy/Ch7/mlir/ToyCombine.td b/mlir/examples/toy/Ch7/mlir/ToyCombine.td index 1ca143a913c..e6e33e84d7e 100644 --- a/mlir/examples/toy/Ch7/mlir/ToyCombine.td +++ b/mlir/examples/toy/Ch7/mlir/ToyCombine.td @@ -1,19 +1,10 @@ //===- ToyCombine.td - Pattern Match Optimizations for Toy -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines language-specific pattern match optimizations for Toy using // Declarative Rewrite Rules (DRR) specified using TableGen records. diff --git a/mlir/examples/toy/Ch7/parser/AST.cpp b/mlir/examples/toy/Ch7/parser/AST.cpp index 391757f711f..669bc9dbec2 100644 --- a/mlir/examples/toy/Ch7/parser/AST.cpp +++ b/mlir/examples/toy/Ch7/parser/AST.cpp @@ -1,19 +1,10 @@ //===- AST.cpp - Helper for printing out the Toy AST ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST dump for the Toy language. // diff --git a/mlir/examples/toy/Ch7/toyc.cpp b/mlir/examples/toy/Ch7/toyc.cpp index ec5a4f8056b..c6afab594e1 100644 --- a/mlir/examples/toy/Ch7/toyc.cpp +++ b/mlir/examples/toy/Ch7/toyc.cpp @@ -1,19 +1,10 @@ //===- toyc.cpp - The Toy Compiler ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the entry point for the Toy compiler. // diff --git a/mlir/include/mlir-c/Core.h b/mlir/include/mlir-c/Core.h index c205e898901..5e3e2087f8b 100644 --- a/mlir/include/mlir-c/Core.h +++ b/mlir/include/mlir-c/Core.h @@ -1,18 +1,9 @@ /*===-- mlir-c/Core.h - Core Library C Interface ------------------*- C -*-===*\ |* *| -|* Copyright 2019 The MLIR Authors. *| -|* *| -|* Licensed under the Apache License, Version 2.0 (the "License"); *| -|* you may not use this file except in compliance with the License. *| -|* You may obtain a copy of the License at *| -|* *| -|* http://www.apache.org/licenses/LICENSE-2.0 *| -|* *| -|* Unless required by applicable law or agreed to in writing, software *| -|* distributed under the License is distributed on an "AS IS" BASIS, *| -|* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *| -|* See the License for the specific language governing permissions and *| -|* limitations under the License. *| +|* Part of the MLIR 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 *| |* *| |*===----------------------------------------------------------------------===*| |* *| diff --git a/mlir/include/mlir/ADT/TypeSwitch.h b/mlir/include/mlir/ADT/TypeSwitch.h index 75051b6a539..2dbc611f557 100644 --- a/mlir/include/mlir/ADT/TypeSwitch.h +++ b/mlir/include/mlir/ADT/TypeSwitch.h @@ -1,19 +1,10 @@ //===- TypeSwitch.h - Switch functionality for RTTI casting -*- C++ -*-----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the TypeSwitch template, which mimics a switch() // statement whose cases are type names. diff --git a/mlir/include/mlir/Analysis/AffineAnalysis.h b/mlir/include/mlir/Analysis/AffineAnalysis.h index f506470f36a..5d9422883c1 100644 --- a/mlir/include/mlir/Analysis/AffineAnalysis.h +++ b/mlir/include/mlir/Analysis/AffineAnalysis.h @@ -1,19 +1,10 @@ //===- AffineAnalysis.h - analyses for affine structures --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes for methods that perform analysis // involving affine structures (AffineExprStorage, AffineMap, IntegerSet, etc.) diff --git a/mlir/include/mlir/Analysis/AffineStructures.h b/mlir/include/mlir/Analysis/AffineStructures.h index 65cf13a0ce6..770bf686f50 100644 --- a/mlir/include/mlir/Analysis/AffineStructures.h +++ b/mlir/include/mlir/Analysis/AffineStructures.h @@ -1,19 +1,10 @@ //===- AffineStructures.h - MLIR Affine Structures Class --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Structures for affine/polyhedral analysis of ML functions. // diff --git a/mlir/include/mlir/Analysis/CallGraph.h b/mlir/include/mlir/Analysis/CallGraph.h index 700a016e836..8f954161921 100644 --- a/mlir/include/mlir/Analysis/CallGraph.h +++ b/mlir/include/mlir/Analysis/CallGraph.h @@ -1,19 +1,10 @@ //===- CallGraph.h - CallGraph analysis for MLIR ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains an analysis for computing the multi-level callgraph from a // given top-level operation. This nodes within this callgraph are defined by diff --git a/mlir/include/mlir/Analysis/CallInterfaces.h b/mlir/include/mlir/Analysis/CallInterfaces.h index a18cfa7aba4..a9806bfb8c6 100644 --- a/mlir/include/mlir/Analysis/CallInterfaces.h +++ b/mlir/include/mlir/Analysis/CallInterfaces.h @@ -1,19 +1,10 @@ //===- CallInterfaces.h - Call Interfaces for MLIR --------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the definitions of the call interfaces defined in // `CallInterfaces.td`. diff --git a/mlir/include/mlir/Analysis/CallInterfaces.td b/mlir/include/mlir/Analysis/CallInterfaces.td index 043f009a8e2..3e5b599baf8 100644 --- a/mlir/include/mlir/Analysis/CallInterfaces.td +++ b/mlir/include/mlir/Analysis/CallInterfaces.td @@ -1,19 +1,10 @@ //===- CallInterfaces.td - Call Interfaces for ops -*- tablegen ---------*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains a set of interfaces that can be used to define information // related to call-like and callable operations. Each of which are defined along diff --git a/mlir/include/mlir/Analysis/Dominance.h b/mlir/include/mlir/Analysis/Dominance.h index f46241e2af0..5c42dbe12c2 100644 --- a/mlir/include/mlir/Analysis/Dominance.h +++ b/mlir/include/mlir/Analysis/Dominance.h @@ -1,19 +1,10 @@ //===- Dominance.h - Dominator analysis for CFGs ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_ANALYSIS_DOMINANCE_H #define MLIR_ANALYSIS_DOMINANCE_H diff --git a/mlir/include/mlir/Analysis/InferTypeOpInterface.h b/mlir/include/mlir/Analysis/InferTypeOpInterface.h index 2d68ada0d13..baf16162a0b 100644 --- a/mlir/include/mlir/Analysis/InferTypeOpInterface.h +++ b/mlir/include/mlir/Analysis/InferTypeOpInterface.h @@ -1,19 +1,10 @@ //===- InferTypeOpInterface.h - Infer Type Interfaces -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the definitions of the infer op interfaces defined in // `InferTypeOpInterface.td`. diff --git a/mlir/include/mlir/Analysis/InferTypeOpInterface.td b/mlir/include/mlir/Analysis/InferTypeOpInterface.td index 14d580962e1..bbcea6be7eb 100644 --- a/mlir/include/mlir/Analysis/InferTypeOpInterface.td +++ b/mlir/include/mlir/Analysis/InferTypeOpInterface.td @@ -1,19 +1,10 @@ //===- InferTypeOpInterface.td - Infer Type interfaces -----*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains a set of interfaces that can be used to define information // related to type inference. diff --git a/mlir/include/mlir/Analysis/Liveness.h b/mlir/include/mlir/Analysis/Liveness.h index 0aa9d9693e4..791c164c7d2 100644 --- a/mlir/include/mlir/Analysis/Liveness.h +++ b/mlir/include/mlir/Analysis/Liveness.h @@ -1,19 +1,10 @@ //===- Liveness.h - Liveness analysis for MLIR ------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains an analysis for computing liveness information from a // given top-level operation. The current version of the analysis uses a diff --git a/mlir/include/mlir/Analysis/LoopAnalysis.h b/mlir/include/mlir/Analysis/LoopAnalysis.h index ad7dc6d6092..66f0033bf2f 100644 --- a/mlir/include/mlir/Analysis/LoopAnalysis.h +++ b/mlir/include/mlir/Analysis/LoopAnalysis.h @@ -1,19 +1,10 @@ //===- LoopAnalysis.h - loop analysis methods -------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes for methods to analyze loops. // diff --git a/mlir/include/mlir/Analysis/NestedMatcher.h b/mlir/include/mlir/Analysis/NestedMatcher.h index 9af26e8842a..2da64e88e14 100644 --- a/mlir/include/mlir/Analysis/NestedMatcher.h +++ b/mlir/include/mlir/Analysis/NestedMatcher.h @@ -1,19 +1,10 @@ //===- NestedMacher.h - Nested matcher for Function -------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_ANALYSIS_MLFUNCTIONMATCHER_H_ #define MLIR_ANALYSIS_MLFUNCTIONMATCHER_H_ diff --git a/mlir/include/mlir/Analysis/Passes.h b/mlir/include/mlir/Analysis/Passes.h index b233ab5f209..0bbc850e6c9 100644 --- a/mlir/include/mlir/Analysis/Passes.h +++ b/mlir/include/mlir/Analysis/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes that expose pass constructors in the // analysis library. diff --git a/mlir/include/mlir/Analysis/SliceAnalysis.h b/mlir/include/mlir/Analysis/SliceAnalysis.h index ad6b65387be..d7b6e957014 100644 --- a/mlir/include/mlir/Analysis/SliceAnalysis.h +++ b/mlir/include/mlir/Analysis/SliceAnalysis.h @@ -1,19 +1,10 @@ //===- SliceAnalysis.h - Analysis for Transitive UseDef chains --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_ANALYSIS_SLICEANALYSIS_H_ #define MLIR_ANALYSIS_SLICEANALYSIS_H_ diff --git a/mlir/include/mlir/Analysis/Utils.h b/mlir/include/mlir/Analysis/Utils.h index ea0987df3fe..d06e003faae 100644 --- a/mlir/include/mlir/Analysis/Utils.h +++ b/mlir/include/mlir/Analysis/Utils.h @@ -1,19 +1,10 @@ //===- Utils.h - General analysis utilities ---------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes for various transformation utilities for // memref's and non-loop IR structures. These are not passes by themselves but diff --git a/mlir/include/mlir/Analysis/Verifier.h b/mlir/include/mlir/Analysis/Verifier.h index daaff57683e..b7075b4f157 100644 --- a/mlir/include/mlir/Analysis/Verifier.h +++ b/mlir/include/mlir/Analysis/Verifier.h @@ -1,19 +1,10 @@ //===- Verifier.h - Verifier analysis for MLIR structures -------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_ANALYSIS_VERIFIER_H #define MLIR_ANALYSIS_VERIFIER_H diff --git a/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h b/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h index 4bbe6610e31..8e873bfb1c3 100644 --- a/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h +++ b/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h @@ -1,19 +1,10 @@ //===- AffineToStandard.h - Convert Affine to Standard dialect --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_AFFINETOSTANDARD_AFFINETOSTANDARD_H #define MLIR_CONVERSION_AFFINETOSTANDARD_AFFINETOSTANDARD_H diff --git a/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h b/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h index 6b9b08ed7d5..4eb6379adf6 100644 --- a/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h +++ b/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h @@ -1,19 +1,10 @@ //===- GPUToCUDAPass.h - MLIR CUDA runtime support --------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_GPUTOCUDA_GPUTOCUDAPASS_H_ #define MLIR_CONVERSION_GPUTOCUDA_GPUTOCUDAPASS_H_ diff --git a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h index 635d4366e83..75e4f7e374c 100644 --- a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h +++ b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h @@ -1,19 +1,10 @@ //===- GPUToNVVMPass.h - Convert GPU kernel to NVVM dialect -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_GPUTONVVM_GPUTONVVMPASS_H_ #define MLIR_CONVERSION_GPUTONVVM_GPUTONVVMPASS_H_ diff --git a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h index 54cda41afa1..e913c2e1131 100644 --- a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h +++ b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h @@ -1,19 +1,10 @@ //===- GPUToROCDLPass.h - Convert GPU kernel to ROCDL dialect ---*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_GPUTOROCDL_GPUTOROCDLPASS_H_ #define MLIR_CONVERSION_GPUTOROCDL_GPUTOROCDLPASS_H_ diff --git a/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h b/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h index 134dbf40b4d..762a6e502d4 100644 --- a/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h +++ b/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h @@ -1,19 +1,10 @@ //===- ConvertGPUToSPIRV.h - GPU Ops to SPIR-V dialect patterns ----C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides patterns for lowering GPU Ops to SPIR-V dialect. // diff --git a/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h b/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h index 8f0a910c74d..37230f4c0e1 100644 --- a/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h +++ b/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h @@ -1,19 +1,10 @@ //===- ConvertGPUToSPIRVPass.h - GPU to SPIR-V conversion pass --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides a pass to convert GPU ops to SPIRV ops. // diff --git a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h index 6bae08e13be..27950177c1d 100644 --- a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h +++ b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h @@ -1,19 +1,10 @@ //===- LinalgToLLVM.h - Utils to convert from the linalg dialect ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_LINALGTOLLVM_LINALGTOLLVM_H_ #define MLIR_CONVERSION_LINALGTOLLVM_LINALGTOLLVM_H_ diff --git a/mlir/include/mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h b/mlir/include/mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h index 095c9f470b3..5cb8f59e6f7 100644 --- a/mlir/include/mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h +++ b/mlir/include/mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h @@ -1,19 +1,10 @@ //===- ConvertLoopToStandard.h - Pass entrypoint ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_LOOPTOSTANDARD_CONVERTLOOPTOSTANDARD_H_ #define MLIR_CONVERSION_LOOPTOSTANDARD_CONVERTLOOPTOSTANDARD_H_ diff --git a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h index 58d49a13391..5f3ea87f3cc 100644 --- a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h +++ b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h @@ -1,19 +1,10 @@ //===- LoopsToGPU.h - Convert loop nests to GPU kernels ---------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_LOOPSTOGPU_LOOPSTOGPU_H_ #define MLIR_CONVERSION_LOOPSTOGPU_LOOPSTOGPU_H_ diff --git a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h index a42320c9bdf..a3d663ae3d7 100644 --- a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h +++ b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h @@ -1,19 +1,10 @@ //===- LoopsToGPUPass.h - Pass converting loops to GPU kernels --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_LOOPSTOGPU_LOOPSTOGPUPASS_H_ #define MLIR_CONVERSION_LOOPSTOGPU_LOOPSTOGPUPASS_H_ diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h index 6f41fb68633..5c8a8e6e494 100644 --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h @@ -1,19 +1,10 @@ //===- ConvertStandardToLLVM.h - Convert to the LLVM dialect ----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides a dialect conversion targeting the LLVM IR dialect. By default, it // converts Standard ops and types and provides hooks for dialect-specific diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h index d49c1c22530..a4d95da6a75 100644 --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h @@ -1,19 +1,10 @@ //===- ConvertStandardToLLVMPass.h - Pass entrypoint ------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_STANDARDTOLLVM_CONVERTSTANDARDTOLLVMPASS_H_ #define MLIR_CONVERSION_STANDARDTOLLVM_CONVERTSTANDARDTOLLVMPASS_H_ diff --git a/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h b/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h index 4caa6d9de77..e0e874027bf 100644 --- a/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h +++ b/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h @@ -1,19 +1,10 @@ //===- ConvertStandardToSPIRV.h - Convert to SPIR-V dialect -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides patterns to lower StandardOps to SPIR-V dialect. // diff --git a/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h b/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h index e8a71feb8b2..7dbaf1c0418 100644 --- a/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h +++ b/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h @@ -1,19 +1,10 @@ //===- ConvertStandardToSPIRVPass.h - StdOps to SPIR-V pass -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides a pass to lower from StandardOps to SPIR-V dialect. // diff --git a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h index a87e1c658a6..b8b97c21a3e 100644 --- a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h +++ b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h @@ -1,19 +1,10 @@ //===- ConvertVectorToLLVM.h - Utils to convert from the vector dialect ---===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLLVM_H_ #define MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLLVM_H_ diff --git a/mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h b/mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h index 198eaceda41..4f7d0843b73 100644 --- a/mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h +++ b/mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h @@ -1,19 +1,10 @@ //===- ConvertVectorToLoops.h - Utils to convert from the vector dialect --===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLOOPS_H_ #define MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLOOPS_H_ diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOps.h b/mlir/include/mlir/Dialect/AffineOps/AffineOps.h index 764f439e020..09408d2efc8 100644 --- a/mlir/include/mlir/Dialect/AffineOps/AffineOps.h +++ b/mlir/include/mlir/Dialect/AffineOps/AffineOps.h @@ -1,19 +1,10 @@ //===- AffineOps.h - MLIR Affine Operations -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines convenience types for working with Affine operations // in the MLIR operation set. diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOps.td b/mlir/include/mlir/Dialect/AffineOps/AffineOps.td index befdc2f6237..715e3807a95 100644 --- a/mlir/include/mlir/Dialect/AffineOps/AffineOps.td +++ b/mlir/include/mlir/Dialect/AffineOps/AffineOps.td @@ -1,19 +1,10 @@ //===- AffineOps.td - Affine operation definitions ---------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines MLIR affine operations. // diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOpsBase.td b/mlir/include/mlir/Dialect/AffineOps/AffineOpsBase.td index 755f65c338e..6aee5f3cd4a 100644 --- a/mlir/include/mlir/Dialect/AffineOps/AffineOpsBase.td +++ b/mlir/include/mlir/Dialect/AffineOps/AffineOpsBase.td @@ -1,19 +1,10 @@ //===- AffineOpsBase.td - Affine operation definitions -----*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines base support for MLIR affine operations. // diff --git a/mlir/include/mlir/Dialect/CommonFolders.h b/mlir/include/mlir/Dialect/CommonFolders.h index 45552945f0d..d667de73d41 100644 --- a/mlir/include/mlir/Dialect/CommonFolders.h +++ b/mlir/include/mlir/Dialect/CommonFolders.h @@ -1,19 +1,10 @@ //===- CommonFolders.h - Common Operation Folders----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file declares various common operation folders. These folders // are intended to be used by dialects to support common folding behavior diff --git a/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.h b/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.h index 88a42344c3b..8c0e7aa1aad 100644 --- a/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.h +++ b/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.h @@ -1,19 +1,10 @@ //===- FxpMathOps.h - Fixed point ops ---------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_FXPMATHOPS_FXPMATHOPS_H_ #define MLIR_DIALECT_FXPMATHOPS_FXPMATHOPS_H_ diff --git a/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td b/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td index b1bfb2706cf..d527b759a10 100644 --- a/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td +++ b/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td @@ -1,19 +1,10 @@ //===- FxpMathOps.td - Fixed point ops --------------------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the operation definition file for fixed point ops (and real // equivalents). diff --git a/mlir/include/mlir/Dialect/FxpMathOps/Passes.h b/mlir/include/mlir/Dialect/FxpMathOps/Passes.h index 415b1c0b253..aec21c4c186 100644 --- a/mlir/include/mlir/Dialect/FxpMathOps/Passes.h +++ b/mlir/include/mlir/Dialect/FxpMathOps/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Fixed point math passes -----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines all of the passes owned by the FxpMathOps dialect. // diff --git a/mlir/include/mlir/Dialect/GPU/GPUDialect.h b/mlir/include/mlir/Dialect/GPU/GPUDialect.h index 12c2aa1bbd1..c3ab6ec5729 100644 --- a/mlir/include/mlir/Dialect/GPU/GPUDialect.h +++ b/mlir/include/mlir/Dialect/GPU/GPUDialect.h @@ -1,19 +1,10 @@ //===- GPUDialect.h - MLIR Dialect for GPU Kernels --------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the GPU kernel-related operations and puts them in the // corresponding dialect. diff --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td b/mlir/include/mlir/Dialect/GPU/GPUOps.td index def1ff2b8a1..037664d0d9b 100644 --- a/mlir/include/mlir/Dialect/GPU/GPUOps.td +++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td @@ -1,19 +1,10 @@ //===-- GPUOps.td - GPU dialect operation definitions ------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines some operations of the GPU dialect. // diff --git a/mlir/include/mlir/Dialect/GPU/Passes.h b/mlir/include/mlir/Dialect/GPU/Passes.h index 7c8ce02db90..daf6d28d452 100644 --- a/mlir/include/mlir/Dialect/GPU/Passes.h +++ b/mlir/include/mlir/Dialect/GPU/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes that expose pass constructors. // diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h index a599d51b31f..bef1f2dbf20 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h @@ -1,19 +1,10 @@ //===- LLVMDialect.h - MLIR LLVM IR dialect ---------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the LLVM IR dialect in MLIR, containing LLVM operations and // LLVM type system. diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td index 6257b4a51d9..ed935d5b7f7 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td @@ -1,19 +1,10 @@ //===-- LLVMOpBase.td - LLVM IR dialect shared definitions -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains shared definitions for the LLVM IR dialect and its // subdialects. diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td index cfbbf7da65d..46f63206ef5 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -1,19 +1,10 @@ //===-- LLVMOps.td - LLVM IR dialect op definition file ----*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the LLVM IR operation definition file. // diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h b/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h index 0328cf4ba94..afb6d4ab627 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h +++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h @@ -1,19 +1,10 @@ //===- NVVMDialect.h - MLIR NVVM IR dialect ---------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the NVVM IR dialect in MLIR, containing NVVM operations and // NVVM specific extensions to the LLVM type system. diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td index bc6887da8e4..f35b7798149 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td @@ -1,19 +1,10 @@ //===-- NVVMOps.td - NVVM IR dialect op definition file ----*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the NVVM IR operation definition file. // diff --git a/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h b/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h index a34c11223f3..dab32d30e8f 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h +++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h @@ -1,19 +1,10 @@ //===- ROCDLDialect.h - MLIR ROCDL IR dialect -------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the ROCDL dialect in MLIR, containing ROCDL operations // and ROCDL specific extensions to the LLVM type system. diff --git a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td index 79d4136d6f5..697ff9740a8 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td @@ -1,19 +1,10 @@ //===-- ROCDLOps.td - ROCDL IR dialect op definition file --*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the ROCDL IR operation definition file. // diff --git a/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h b/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h index 426708b14a8..1a2d6b9b3ba 100644 --- a/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h +++ b/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h @@ -1,19 +1,10 @@ //===- DependenceAnalysis.h - Dependence analysis on SSA views --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_LINALG_ANALYSIS_DEPENDENCEANALYSIS_H_ #define MLIR_DIALECT_LINALG_ANALYSIS_DEPENDENCEANALYSIS_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h index 8375e750a5c..d0f6c942b95 100644 --- a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h @@ -1,19 +1,10 @@ //===- Builders.h - MLIR Declarative Linalg Builders ------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides intuitive composable interfaces for building structured MLIR // snippets in a declarative fashion. diff --git a/mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h b/mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h index f1acab69a4d..b04c11f22bb 100644 --- a/mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h @@ -1,19 +1,10 @@ //===- Intrinsics.h - MLIR EDSC Intrinsics for Linalg -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_LINALG_EDSC_INTRINSICS_H_ #define MLIR_DIALECT_LINALG_EDSC_INTRINSICS_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td index 4e77b0ac0a8..c1adc8b4d05 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td @@ -1,19 +1,10 @@ //===- LinalgBase.td - Linalg dialect base support ---------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the definition file for base linear algebra support. // diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgDoc.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgDoc.td index a3163f50476..819d02d396d 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgDoc.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgDoc.td @@ -1,19 +1,10 @@ //===- LinalgDoc.td - Linalg documentation -----------------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This documentation files exists to circumvent limitations on mixing different // .td files in cases one does not want to have all ops belong to the same diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td index 18ca31cc376..e52019d7992 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td @@ -1,19 +1,10 @@ //===- LinalgLibraryOps.td - Linalg dialect library ops -*- tablegen ----*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the operation definition file for linear algebra operations that // correspond to underlying library calls (e.g. BLAS). diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h index c5f1f01d0c7..3249edb48e0 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h @@ -1,19 +1,10 @@ //===- LinalgOps.h - Linalg Operations --------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_LINALG_LINALGOPS_H_ #define MLIR_DIALECT_LINALG_LINALGOPS_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td index 5d402a9ded9..728fa619dbe 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td @@ -1,19 +1,10 @@ //===- LinalgOps.td - Linalg dialect ops -------------------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the operation definition file for linear algebra operations. // diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td index 774be6616cd..8674c277e4a 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td @@ -1,19 +1,10 @@ //===- LinalgStructuredOps.td - Linalg dialect library ops -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the operation definition file for structured operations on buffers // that correspond to underlying library calls (e.g. BLAS). diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h index d196e6ccf94..7399aad6663 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h @@ -1,19 +1,10 @@ //===- LinalgTraits.h - Linalg Traits ---------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_LINALG_LINALGTRAITS_H_ #define MLIR_DIALECT_LINALG_LINALGTRAITS_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTypes.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTypes.h index f779c3de6ae..abeda3e0552 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTypes.h +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTypes.h @@ -1,19 +1,10 @@ //===- LinalgTypes.h - Linalg Types ---------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_LINALG_LINALGTYPES_H_ #define MLIR_DIALECT_LINALG_LINALGTYPES_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.h b/mlir/include/mlir/Dialect/Linalg/Passes.h index 7ae3877f01e..86cf6fdd027 100644 --- a/mlir/include/mlir/Dialect/Linalg/Passes.h +++ b/mlir/include/mlir/Dialect/Linalg/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Linalg pass entry points ----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes that expose pass constructors. // diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td index dbc162f4132..448ffdf7d4b 100644 --- a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td @@ -1,19 +1,10 @@ //===- LinalgPatterns.td - Linalg transformation patterns --*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the pattern definition file for declarative Linalg transformation. // diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h index a1a7458ae7f..a88dc4105e2 100644 --- a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h @@ -1,19 +1,10 @@ //===- LinalgTransforms.h - Linalg transformations as patterns --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef DIALECT_LINALG_TRANSFORMS_LINALGTRANSFORMS_H_ #define DIALECT_LINALG_TRANSFORMS_LINALGTRANSFORMS_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/Utils/Intrinsics.h b/mlir/include/mlir/Dialect/Linalg/Utils/Intrinsics.h index 5a815ba158e..778d853aeef 100644 --- a/mlir/include/mlir/Dialect/Linalg/Utils/Intrinsics.h +++ b/mlir/include/mlir/Dialect/Linalg/Utils/Intrinsics.h @@ -1,19 +1,10 @@ //===- Intrinsics.h - Linalg intrinsics definitions -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_LINALG_INTRINSICS_H_ #define MLIR_DIALECT_LINALG_INTRINSICS_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h index 50039dd9336..1b45179bc9e 100644 --- a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h @@ -1,19 +1,10 @@ //===- Utils.h - Utilities to support the Linalg dialect --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_LINALG_UTILS_H_ #define MLIR_DIALECT_LINALG_UTILS_H_ diff --git a/mlir/include/mlir/Dialect/LoopOps/LoopOps.h b/mlir/include/mlir/Dialect/LoopOps/LoopOps.h index e7ff6f84977..dba5e819986 100644 --- a/mlir/include/mlir/Dialect/LoopOps/LoopOps.h +++ b/mlir/include/mlir/Dialect/LoopOps/LoopOps.h @@ -1,19 +1,10 @@ //===- Ops.h - Loop MLIR Operations -----------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines convenience types for working with loop operations. // diff --git a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td index e0f5b896309..3b0f120441a 100644 --- a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td +++ b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td @@ -1,19 +1,10 @@ //===- Ops.td - Loop operation definitions ---------------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines MLIR loop operations. // diff --git a/mlir/include/mlir/Dialect/QuantOps/FakeQuantSupport.h b/mlir/include/mlir/Dialect/QuantOps/FakeQuantSupport.h index 23e2967bd77..1a141e3b1b3 100644 --- a/mlir/include/mlir/Dialect/QuantOps/FakeQuantSupport.h +++ b/mlir/include/mlir/Dialect/QuantOps/FakeQuantSupport.h @@ -1,19 +1,10 @@ //===- FakeQuantSupport.h - Support utilities for FakeQuant ops -*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines support utilities for interoperating with FakeQuant* based // QAT (Quantized Aware Training) computations, as implemented by TFLite. Note diff --git a/mlir/include/mlir/Dialect/QuantOps/Passes.h b/mlir/include/mlir/Dialect/QuantOps/Passes.h index c57d7bf41fe..d3109775db2 100644 --- a/mlir/include/mlir/Dialect/QuantOps/Passes.h +++ b/mlir/include/mlir/Dialect/QuantOps/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Quantization Passes ------ --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines all of the passes owned by the quantization dialect. As // things mature, it is expected that passes specific to certain frontend or diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantOps.h b/mlir/include/mlir/Dialect/QuantOps/QuantOps.h index 020d34918d4..9a4eec67c74 100644 --- a/mlir/include/mlir/Dialect/QuantOps/QuantOps.h +++ b/mlir/include/mlir/Dialect/QuantOps/QuantOps.h @@ -1,19 +1,10 @@ //===- QuantOps.h - Quantization Ops and Types ------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_QUANTOPS_QUANTOPS_H_ #define MLIR_DIALECT_QUANTOPS_QUANTOPS_H_ diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantOps.td b/mlir/include/mlir/Dialect/QuantOps/QuantOps.td index 072715d65aa..bbeb9419cc4 100644 --- a/mlir/include/mlir/Dialect/QuantOps/QuantOps.td +++ b/mlir/include/mlir/Dialect/QuantOps/QuantOps.td @@ -1,19 +1,10 @@ //===- QuantOps.td - Quantization operation definition -----*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the operation definition file for Quantization. // diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantPredicates.td b/mlir/include/mlir/Dialect/QuantOps/QuantPredicates.td index 2fbb7995dd4..7225dcc72db 100644 --- a/mlir/include/mlir/Dialect/QuantOps/QuantPredicates.td +++ b/mlir/include/mlir/Dialect/QuantOps/QuantPredicates.td @@ -1,19 +1,10 @@ //===- QuantPredicates.td - Predicates for dialect types ---*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Predicates for types in the Quantization dialect. // diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantTypes.h b/mlir/include/mlir/Dialect/QuantOps/QuantTypes.h index 55e921ff8fb..daeb0374460 100644 --- a/mlir/include/mlir/Dialect/QuantOps/QuantTypes.h +++ b/mlir/include/mlir/Dialect/QuantOps/QuantTypes.h @@ -1,19 +1,10 @@ //===- QuantTypes.h - Quantization Ops and Types ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_QUANTOPS_QUANT_TYPES_H_ #define MLIR_DIALECT_QUANTOPS_QUANT_TYPES_H_ diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantizeUtils.h b/mlir/include/mlir/Dialect/QuantOps/QuantizeUtils.h index de87ca1e67c..c40b9e6f026 100644 --- a/mlir/include/mlir/Dialect/QuantOps/QuantizeUtils.h +++ b/mlir/include/mlir/Dialect/QuantOps/QuantizeUtils.h @@ -1,19 +1,10 @@ //===- QuantizeUtils.h - Support utilities for quantization -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_QUANTOPS_QUANTIZEUTILS_H_ #define MLIR_DIALECT_QUANTOPS_QUANTIZEUTILS_H_ diff --git a/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h b/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h index 0416db34e17..7c74fc56b8f 100644 --- a/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h +++ b/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h @@ -1,19 +1,10 @@ //===- UniformSupport.h - Support utilities for uniform quant ---*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_QUANTOPS_UNIFORMSUPPORT_H_ #define MLIR_DIALECT_QUANTOPS_UNIFORMSUPPORT_H_ diff --git a/mlir/include/mlir/Dialect/SDBM/SDBM.h b/mlir/include/mlir/Dialect/SDBM/SDBM.h index f95a51e407a..c8a0eec8ca8 100644 --- a/mlir/include/mlir/Dialect/SDBM/SDBM.h +++ b/mlir/include/mlir/Dialect/SDBM/SDBM.h @@ -1,19 +1,10 @@ //===- SDBM.h - MLIR SDBM declaration ---------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // A striped difference-bound matrix (SDBM) is a set in Z^N (or R^N) defined // as {(x_1, ... x_n) | f(x_1, ... x_n) >= 0} where f is an SDBM expression. diff --git a/mlir/include/mlir/Dialect/SDBM/SDBMDialect.h b/mlir/include/mlir/Dialect/SDBM/SDBMDialect.h index e3573ba604d..501c66140f0 100644 --- a/mlir/include/mlir/Dialect/SDBM/SDBMDialect.h +++ b/mlir/include/mlir/Dialect/SDBM/SDBMDialect.h @@ -1,19 +1,10 @@ //===- SDBMDialect.h - Dialect for striped DBMs -----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_SDBM_SDBMDIALECT_H #define MLIR_DIALECT_SDBM_SDBMDIALECT_H diff --git a/mlir/include/mlir/Dialect/SDBM/SDBMExpr.h b/mlir/include/mlir/Dialect/SDBM/SDBMExpr.h index 8cb5ef0be10..84a9a8405a8 100644 --- a/mlir/include/mlir/Dialect/SDBM/SDBMExpr.h +++ b/mlir/include/mlir/Dialect/SDBM/SDBMExpr.h @@ -1,19 +1,10 @@ //===- SDBMExpr.h - MLIR SDBM Expression ------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // A striped difference-bound matrix (SDBM) expression is a constant expression, // an identifier, a binary expression with constant RHS and +, stripe operators diff --git a/mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h b/mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h index 7537e5f654b..329caa2d3aa 100644 --- a/mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h +++ b/mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h @@ -1,19 +1,10 @@ //===-- LayoutUtils.h - Decorate composite type with layout information ---===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines utilities used to get alignment and layout information for // types in SPIR-V dialect. diff --git a/mlir/include/mlir/Dialect/SPIRV/Passes.h b/mlir/include/mlir/Dialect/SPIRV/Passes.h index fe029ff27ea..68f149b54d5 100644 --- a/mlir/include/mlir/Dialect/SPIRV/Passes.h +++ b/mlir/include/mlir/Dialect/SPIRV/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - SPIR-V pass entry points ----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes that expose pass constructors. // diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td index f15d274922a..39858f357ff 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td @@ -1,19 +1,10 @@ //===-- SPIRVArithmeticOps.td - MLIR SPIR-V Arithmetic Ops -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains arithmetic ops for the SPIR-V dialect. It corresponds // to "3.32.13. Arithmetic Instructions" of the SPIR-V specification. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td index 15b6ab0105c..c2ea100c121 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td @@ -1,19 +1,10 @@ //===-- SPIRVAtomicOps.td - MLIR SPIR-V Atomic Ops ---------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains atomic ops for the SPIR-V dialect. It corresponds to // "3.32.18. Atomic Instructions" of the SPIR-V specification. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td index 838398823ad..5751a32e169 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td @@ -1,19 +1,10 @@ //===- SPIRVBase.td - MLIR SPIR-V Op Definitions Base file -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the base file for SPIR-V operation definition specification. // This file defines the SPIR-V dialect, common SPIR-V types, and utilities diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVBinaryUtils.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVBinaryUtils.h index 3229e28ef1a..6a426488423 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVBinaryUtils.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVBinaryUtils.h @@ -1,19 +1,10 @@ //===- SPIRVBinaryUtils.cpp - SPIR-V Binary Module Utils --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares common utilities for SPIR-V binary module. // diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td index d76a1e3854b..360edeec52d 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td @@ -1,19 +1,10 @@ //===-- SPIRVBitOps.td - MLIR SPIR-V Bit Ops -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains bit ops for the SPIR-V dialect. It corresponds // to "3.32.13. Bit Instructions" of the SPIR-V specification. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td index e4fe526e420..99fe0bbbf5f 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td @@ -1,19 +1,10 @@ //===-- SPIRVCastOps.td - MLIR SPIR-V Cast Ops -------*- tablegen -*-------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains cast ops for the SPIR-V dialect. It corresponds // to "3.32.11. Convertion Instructions" of the SPIR-V specification. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td index d19fd974684..7bd88ab66e0 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td @@ -1,19 +1,10 @@ //===-- SPIRVCompositeOps.td - MLIR SPIR-V Composite Ops ---*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains composite ops for SPIR-V dialect. It corresponds // to "3.32.12. Composite Instructions" of the SPIR-V spec. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td index 32a78024560..bc06c0289db 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td @@ -1,19 +1,10 @@ //===-- SPIRVControlFlowOps.td - SPIR-V Control Flow Ops ---*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains control flow ops for the SPIR-V dialect. It corresponds // to "3.32.17. Control-Flow Instructions" of the SPIR-V specification. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h index 2571e5d8928..0c0eebd34d1 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h @@ -1,19 +1,10 @@ //===- SPIRVDialect.h - MLIR SPIR-V dialect ---------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the SPIR-V dialect in MLIR. // diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td index a031facdf5a..b2eacbf306a 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td @@ -1,19 +1,10 @@ //===- SPIRVGLSLOps.td - GLSL extended insts spec file -----*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the op definition spec of GLSL extension ops. // diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td index c0388fe4e23..827636afbaf 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td @@ -1,19 +1,10 @@ //===-- SPIRVGroupOps.td - MLIR SPIR-V (Sub)Group Ops ------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains group and subgroup ops for the SPIR-V dialect. It // corresponds to "3.32.21. Group and Subgroup Instructions" of the SPIR-V diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td index e1e94bcd861..4057f47931c 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td @@ -1,19 +1,10 @@ //===-- SPIRVLogicalOps.td - MLIR SPIR-V Logical Ops -------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains arithmetic ops for the SPIR-V dialect. It corresponds // to "3.32.15. Relational and Logical Instructions" of the SPIR-V spec. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h index 37b4ee24237..e7cf250cc3a 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h @@ -1,19 +1,10 @@ //===- SPIRVLowering.h - SPIR-V lowering utilities -------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines utilities to use while targeting SPIR-V dialect. // diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.td index d9cf0a752b8..91a8ff68bbf 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.td @@ -1,19 +1,10 @@ //===- SPIRVBase.td - MLIR SPIR-V Op Definitions Base file -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the base file for supporting lowering to SPIR-V dialect. This // file defines SPIR-V attributes used for specifying the shader diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td index 1b3174c9e9f..f3a9a61a9e9 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td @@ -1,19 +1,10 @@ //===-- SPIRVNonUniformOps.td - MLIR SPIR-V NonUniform Ops -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains non-uniform ops for the SPIR-V dialect. It corresponds to // "3.32.24. Non-Uniform Instructions" of the SPIR-V specification. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h index cb33146286a..2fa417bfe25 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h @@ -1,19 +1,10 @@ //===- SPIRVOps.h - MLIR SPIR-V operations ----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the operations in the SPIR-V dialect. // diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td index 777e5750486..f657d5847d0 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td @@ -1,19 +1,10 @@ //===-- SPIRVOps.td - MLIR SPIR-V Op Definitions Spec ------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the main operation definition specification file for SPIR-V // operations. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td index d1dacf3d63d..c37796b9f60 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td @@ -1,19 +1,10 @@ //===-- SPIRVStructureOps.td - MLIR SPIR-V Structure Ops ---*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains ops for defining the SPIR-V structure: module, function, // and module-level operations. The representational form of these ops deviate diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h index bc3083e8d7c..001d3130778 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h @@ -1,19 +1,10 @@ //===- SPIRVTypes.h - MLIR SPIR-V Types -------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the types in the SPIR-V dialect. // diff --git a/mlir/include/mlir/Dialect/SPIRV/Serialization.h b/mlir/include/mlir/Dialect/SPIRV/Serialization.h index bad7355791f..e8240b0072e 100644 --- a/mlir/include/mlir/Dialect/SPIRV/Serialization.h +++ b/mlir/include/mlir/Dialect/SPIRV/Serialization.h @@ -1,19 +1,10 @@ //===- Serialization.h - MLIR SPIR-V (De)serialization ----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the entry points for serialize and deserialize SPIR-V // binary modules. diff --git a/mlir/include/mlir/Dialect/StandardOps/Ops.h b/mlir/include/mlir/Dialect/StandardOps/Ops.h index 563116823d9..e3ec6f1f7d6 100644 --- a/mlir/include/mlir/Dialect/StandardOps/Ops.h +++ b/mlir/include/mlir/Dialect/StandardOps/Ops.h @@ -1,19 +1,10 @@ //===- Ops.h - Standard MLIR Operations -------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines convenience types for working with standard operations // in the MLIR operation set. diff --git a/mlir/include/mlir/Dialect/StandardOps/Ops.td b/mlir/include/mlir/Dialect/StandardOps/Ops.td index e00674708f6..c31b3dc9395 100644 --- a/mlir/include/mlir/Dialect/StandardOps/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/Ops.td @@ -1,19 +1,10 @@ //===- Ops.td - Standard operation definitions -------------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines some MLIR standard operations. // diff --git a/mlir/include/mlir/Dialect/Traits.h b/mlir/include/mlir/Dialect/Traits.h index e04eb829e88..87c8e662a65 100644 --- a/mlir/include/mlir/Dialect/Traits.h +++ b/mlir/include/mlir/Dialect/Traits.h @@ -1,19 +1,10 @@ //===- Traits.h - Common op traits shared by dialects -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares common op traits that are not core to MLIR but can be // shared by multiple dialects. diff --git a/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h b/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h index b7e3990a333..9e7cbba0f43 100644 --- a/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h +++ b/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h @@ -1,19 +1,10 @@ //===- StructuredOpsUtils.h - Utilities used by structured ops --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file define utilities that operate on standard types and are // useful across multiple dialects that use structured ops abstractions. These diff --git a/mlir/include/mlir/Dialect/VectorOps/Utils.h b/mlir/include/mlir/Dialect/VectorOps/Utils.h index 68c62cc7ec7..b4d8ad65e60 100644 --- a/mlir/include/mlir/Dialect/VectorOps/Utils.h +++ b/mlir/include/mlir/Dialect/VectorOps/Utils.h @@ -1,19 +1,10 @@ //===- Utils.h - VectorOps Utils ----------------------------*- C++ -*-=======// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_VECTOROPS_UTILS_H_ #define MLIR_DIALECT_VECTOROPS_UTILS_H_ diff --git a/mlir/include/mlir/Dialect/VectorOps/VectorOps.h b/mlir/include/mlir/Dialect/VectorOps/VectorOps.h index 29ad6eecaf9..7234d46b765 100644 --- a/mlir/include/mlir/Dialect/VectorOps/VectorOps.h +++ b/mlir/include/mlir/Dialect/VectorOps/VectorOps.h @@ -1,19 +1,10 @@ //===- VectorOps.h - MLIR Super Vectorizer Operations -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the Vector dialect. // diff --git a/mlir/include/mlir/Dialect/VectorOps/VectorOps.td b/mlir/include/mlir/Dialect/VectorOps/VectorOps.td index 94262e6f1ff..87ed28caf80 100644 --- a/mlir/include/mlir/Dialect/VectorOps/VectorOps.td +++ b/mlir/include/mlir/Dialect/VectorOps/VectorOps.td @@ -1,19 +1,10 @@ //===- VectorOps.td - Vector op definitions ---------------*- tablegen -*-====// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines MLIR vector operations. // diff --git a/mlir/include/mlir/Dialect/VectorOps/VectorTransformPatterns.td b/mlir/include/mlir/Dialect/VectorOps/VectorTransformPatterns.td index 86ff9b505d5..5d0244f6989 100644 --- a/mlir/include/mlir/Dialect/VectorOps/VectorTransformPatterns.td +++ b/mlir/include/mlir/Dialect/VectorOps/VectorTransformPatterns.td @@ -1,19 +1,10 @@ //===- VectorTransformPatterns.td - Vector-Vector patterns -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the pattern definition file for declarative Vector transformations. // diff --git a/mlir/include/mlir/Dialect/VectorOps/VectorTransforms.h b/mlir/include/mlir/Dialect/VectorOps/VectorTransforms.h index b48cb51533f..a73444d2023 100644 --- a/mlir/include/mlir/Dialect/VectorOps/VectorTransforms.h +++ b/mlir/include/mlir/Dialect/VectorOps/VectorTransforms.h @@ -1,19 +1,10 @@ //===- VectorTransforms.h - Vector transformations as patterns --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef DIALECT_VECTOROPS_VECTORTRANSFORMS_H_ #define DIALECT_VECTOROPS_VECTORTRANSFORMS_H_ diff --git a/mlir/include/mlir/EDSC/Builders.h b/mlir/include/mlir/EDSC/Builders.h index 11ee0bff342..6607f267057 100644 --- a/mlir/include/mlir/EDSC/Builders.h +++ b/mlir/include/mlir/EDSC/Builders.h @@ -1,19 +1,10 @@ //===- Builders.h - MLIR Declarative Builder Classes ------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides intuitive composable interfaces for building structured MLIR // snippets in a declarative fashion. diff --git a/mlir/include/mlir/EDSC/Helpers.h b/mlir/include/mlir/EDSC/Helpers.h index c18307e7121..0be8a6045f7 100644 --- a/mlir/include/mlir/EDSC/Helpers.h +++ b/mlir/include/mlir/EDSC/Helpers.h @@ -1,19 +1,10 @@ //===- Helpers.h - MLIR Declarative Helper Functionality --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides helper classes and syntactic sugar for declarative builders. // diff --git a/mlir/include/mlir/EDSC/Intrinsics.h b/mlir/include/mlir/EDSC/Intrinsics.h index dc0c1186c7a..5edbf9600fb 100644 --- a/mlir/include/mlir/EDSC/Intrinsics.h +++ b/mlir/include/mlir/EDSC/Intrinsics.h @@ -1,19 +1,10 @@ //===- Intrinsics.h - MLIR Operations for Declarative Builders ---*- C++-*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides intuitive composable intrinsics for building snippets of MLIR // declaratively diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h index 4e70a21f6ec..4f218bd0d9b 100644 --- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h +++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h @@ -1,19 +1,10 @@ //===- ExecutionEngine.h - MLIR Execution engine and utils -----*- C++ -*--===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file provides a JIT-backed execution engine for MLIR modules. // diff --git a/mlir/include/mlir/ExecutionEngine/OptUtils.h b/mlir/include/mlir/ExecutionEngine/OptUtils.h index 8c0249d5c09..7b7b2598db5 100644 --- a/mlir/include/mlir/ExecutionEngine/OptUtils.h +++ b/mlir/include/mlir/ExecutionEngine/OptUtils.h @@ -1,19 +1,10 @@ //===- OptUtils.h - MLIR Execution Engine opt pass utilities ----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the utility functions to trigger LLVM optimizations from // MLIR Execution Engine. diff --git a/mlir/include/mlir/IR/AffineExpr.h b/mlir/include/mlir/IR/AffineExpr.h index b66933df408..7059489ed4c 100644 --- a/mlir/include/mlir/IR/AffineExpr.h +++ b/mlir/include/mlir/IR/AffineExpr.h @@ -1,19 +1,10 @@ //===- AffineExpr.h - MLIR Affine Expr Class --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // An affine expression is an affine combination of dimension identifiers and // symbols, including ceildiv/floordiv/mod by a constant integer. diff --git a/mlir/include/mlir/IR/AffineExprVisitor.h b/mlir/include/mlir/IR/AffineExprVisitor.h index 9fa40218b5f..7866d6bb996 100644 --- a/mlir/include/mlir/IR/AffineExprVisitor.h +++ b/mlir/include/mlir/IR/AffineExprVisitor.h @@ -1,19 +1,10 @@ //===- AffineExprVisitor.h - MLIR AffineExpr Visitor Class ------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the AffineExpr visitor class. // diff --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h index abd3712b0e1..3f9116cb168 100644 --- a/mlir/include/mlir/IR/AffineMap.h +++ b/mlir/include/mlir/IR/AffineMap.h @@ -1,19 +1,10 @@ //===- AffineMap.h - MLIR Affine Map Class ----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Affine maps are mathematical functions which map a list of dimension // identifiers and symbols, to multidimensional affine expressions. diff --git a/mlir/include/mlir/IR/AttributeSupport.h b/mlir/include/mlir/IR/AttributeSupport.h index 78b3a2779d3..9804d6866f8 100644 --- a/mlir/include/mlir/IR/AttributeSupport.h +++ b/mlir/include/mlir/IR/AttributeSupport.h @@ -1,19 +1,10 @@ //===- AttributeSupport.h ---------------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines support types for registering dialect extended attributes. // diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h index b5f4b1a7d7c..b8398580f61 100644 --- a/mlir/include/mlir/IR/Attributes.h +++ b/mlir/include/mlir/IR/Attributes.h @@ -1,19 +1,10 @@ //===- Attributes.h - MLIR Attribute Classes --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_ATTRIBUTES_H #define MLIR_IR_ATTRIBUTES_H diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h index 87c77160e1d..b5189b48a85 100644 --- a/mlir/include/mlir/IR/Block.h +++ b/mlir/include/mlir/IR/Block.h @@ -1,19 +1,10 @@ //===- Block.h - MLIR Block Class -------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the Block class. // diff --git a/mlir/include/mlir/IR/BlockAndValueMapping.h b/mlir/include/mlir/IR/BlockAndValueMapping.h index 287dd508fa6..82173c34368 100644 --- a/mlir/include/mlir/IR/BlockAndValueMapping.h +++ b/mlir/include/mlir/IR/BlockAndValueMapping.h @@ -1,19 +1,10 @@ //===- BlockAndValueMapping.h -----------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a utility class for maintaining a mapping for multiple // value types. diff --git a/mlir/include/mlir/IR/BlockSupport.h b/mlir/include/mlir/IR/BlockSupport.h index fd30c36aaa3..7cefe870c22 100644 --- a/mlir/include/mlir/IR/BlockSupport.h +++ b/mlir/include/mlir/IR/BlockSupport.h @@ -1,19 +1,10 @@ //===- BlockSupport.h -------------------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a number of support types for the Block class. // diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h index c199c09feb5..038664f0186 100644 --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -1,19 +1,10 @@ //===- Builders.h - Helpers for constructing MLIR Classes -------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_BUILDERS_H #define MLIR_IR_BUILDERS_H diff --git a/mlir/include/mlir/IR/Diagnostics.h b/mlir/include/mlir/IR/Diagnostics.h index 9385de9ac4f..e3d0f838208 100644 --- a/mlir/include/mlir/IR/Diagnostics.h +++ b/mlir/include/mlir/IR/Diagnostics.h @@ -1,19 +1,10 @@ //===- Diagnostics.h - MLIR Diagnostics -------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines utilities for emitting diagnostics. // diff --git a/mlir/include/mlir/IR/Dialect.h b/mlir/include/mlir/IR/Dialect.h index a1855e797e8..d3b4b055bc0 100644 --- a/mlir/include/mlir/IR/Dialect.h +++ b/mlir/include/mlir/IR/Dialect.h @@ -1,19 +1,10 @@ //===- Dialect.h - IR Dialect Description -----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the 'dialect' abstraction. // diff --git a/mlir/include/mlir/IR/DialectHooks.h b/mlir/include/mlir/IR/DialectHooks.h index c51fafb6180..7e4e1d8335b 100644 --- a/mlir/include/mlir/IR/DialectHooks.h +++ b/mlir/include/mlir/IR/DialectHooks.h @@ -1,19 +1,10 @@ //===- DialectHooks.h - MLIR DialectHooks mechanism -------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines abstraction and registration mechanism for dialect hooks. // diff --git a/mlir/include/mlir/IR/DialectImplementation.h b/mlir/include/mlir/IR/DialectImplementation.h index c645a2427b2..1eada8f264b 100644 --- a/mlir/include/mlir/IR/DialectImplementation.h +++ b/mlir/include/mlir/IR/DialectImplementation.h @@ -1,19 +1,10 @@ //===- DialectImplementation.h ----------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains utilities classes for implementing dialect attributes and // types. diff --git a/mlir/include/mlir/IR/DialectInterface.h b/mlir/include/mlir/IR/DialectInterface.h index 4eb41105032..ff1f8fb015a 100644 --- a/mlir/include/mlir/IR/DialectInterface.h +++ b/mlir/include/mlir/IR/DialectInterface.h @@ -1,19 +1,10 @@ //===- DialectInterface.h - IR Dialect Interfaces ---------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_DIALECTINTERFACE_H #define MLIR_IR_DIALECTINTERFACE_H diff --git a/mlir/include/mlir/IR/DialectSymbolRegistry.def b/mlir/include/mlir/IR/DialectSymbolRegistry.def index c1056bd4da0..14b876a2ce9 100644 --- a/mlir/include/mlir/IR/DialectSymbolRegistry.def +++ b/mlir/include/mlir/IR/DialectSymbolRegistry.def @@ -1,19 +1,10 @@ //===- DialectSymbolRegistry.def - MLIR Dialect Symbol Registry -*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file enumerates the different dialects that define custom classes // within the attribute or type system. diff --git a/mlir/include/mlir/IR/Function.h b/mlir/include/mlir/IR/Function.h index 6731f5430fa..3f788bbeeba 100644 --- a/mlir/include/mlir/IR/Function.h +++ b/mlir/include/mlir/IR/Function.h @@ -1,19 +1,10 @@ //===- Function.h - MLIR Function Class -------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Functions are the basic unit of composition in MLIR. // diff --git a/mlir/include/mlir/IR/FunctionImplementation.h b/mlir/include/mlir/IR/FunctionImplementation.h index c557d58429c..9d3e438f67e 100644 --- a/mlir/include/mlir/IR/FunctionImplementation.h +++ b/mlir/include/mlir/IR/FunctionImplementation.h @@ -1,19 +1,10 @@ //===- FunctionImplementation.h - Function-like Op utilities ----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file provides utility functions for implementing function-like // operations, in particular, parsing, printing and verification components diff --git a/mlir/include/mlir/IR/FunctionSupport.h b/mlir/include/mlir/IR/FunctionSupport.h index 1ba85d73df9..49175ba5e75 100644 --- a/mlir/include/mlir/IR/FunctionSupport.h +++ b/mlir/include/mlir/IR/FunctionSupport.h @@ -1,19 +1,10 @@ //===- FunctionSupport.h - Utility types for function-like ops --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines support types for Operations that represent function-like // constructs to use. diff --git a/mlir/include/mlir/IR/Identifier.h b/mlir/include/mlir/IR/Identifier.h index bc84c200545..604eebf341e 100644 --- a/mlir/include/mlir/IR/Identifier.h +++ b/mlir/include/mlir/IR/Identifier.h @@ -1,19 +1,10 @@ //===- Identifier.h - MLIR Identifier Class ---------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_IDENTIFIER_H #define MLIR_IR_IDENTIFIER_H diff --git a/mlir/include/mlir/IR/IntegerSet.h b/mlir/include/mlir/IR/IntegerSet.h index 6ffe830883b..1238511df34 100644 --- a/mlir/include/mlir/IR/IntegerSet.h +++ b/mlir/include/mlir/IR/IntegerSet.h @@ -1,19 +1,10 @@ //===- IntegerSet.h - MLIR Integer Set Class --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Integer sets are sets of points from the integer lattice constrained by // affine equality/inequality constraints. This class is meant to represent diff --git a/mlir/include/mlir/IR/Location.h b/mlir/include/mlir/IR/Location.h index bb55ad69057..c36bcb30735 100644 --- a/mlir/include/mlir/IR/Location.h +++ b/mlir/include/mlir/IR/Location.h @@ -1,19 +1,10 @@ //===- Location.h - MLIR Location Classes -----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // These classes provide the ability to relate MLIR objects back to source // location position information. diff --git a/mlir/include/mlir/IR/MLIRContext.h b/mlir/include/mlir/IR/MLIRContext.h index a93cb8b3353..e0761bcaaf1 100644 --- a/mlir/include/mlir/IR/MLIRContext.h +++ b/mlir/include/mlir/IR/MLIRContext.h @@ -1,19 +1,10 @@ //===- MLIRContext.h - MLIR Global Context Class ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_MLIRCONTEXT_H #define MLIR_IR_MLIRCONTEXT_H diff --git a/mlir/include/mlir/IR/Matchers.h b/mlir/include/mlir/IR/Matchers.h index 3b36f2fb5eb..5ce2cc7a8a8 100644 --- a/mlir/include/mlir/IR/Matchers.h +++ b/mlir/include/mlir/IR/Matchers.h @@ -1,19 +1,10 @@ //===- Matchers.h - Various common matchers ---------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file provides a simple and efficient mechanism for performing general // tree-based pattern matching over MLIR. This mechanism is inspired by LLVM's diff --git a/mlir/include/mlir/IR/Module.h b/mlir/include/mlir/IR/Module.h index 52d2455c7ae..babc51aad0d 100644 --- a/mlir/include/mlir/IR/Module.h +++ b/mlir/include/mlir/IR/Module.h @@ -1,19 +1,10 @@ //===- Module.h - MLIR Module Class -----------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Module is the top-level container for code in an MLIR program. // diff --git a/mlir/include/mlir/IR/OpAsmInterface.td b/mlir/include/mlir/IR/OpAsmInterface.td index 85726a8c64d..7e31c07575e 100644 --- a/mlir/include/mlir/IR/OpAsmInterface.td +++ b/mlir/include/mlir/IR/OpAsmInterface.td @@ -1,19 +1,10 @@ //===- OpAsmInterface.td - Asm Interfaces for opse ---------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains Interfaces for interacting with the AsmParser and // AsmPrinter. diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 24e48b329d5..c457d25fc51 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -1,19 +1,10 @@ //===-- OpBase.td - Base op definition file ----------------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the base operation definition file. // diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index 437540117c4..84f3cf2f444 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -1,19 +1,10 @@ //===- OpDefinition.h - Classes for defining concrete Op types --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements helper classes for implementing the "Op" types. This // includes the Op type, which is the base class for Op class definitions, diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h index fcadce9ab16..e58a5b07038 100644 --- a/mlir/include/mlir/IR/OpImplementation.h +++ b/mlir/include/mlir/IR/OpImplementation.h @@ -1,19 +1,10 @@ //===- OpImplementation.h - Classes for implementing Op types ---*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This classes used by the implementation details of Op types. // diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index ad0dc600f8f..9ab900c8761 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -1,19 +1,10 @@ //===- Operation.h - MLIR Operation Class -----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the Operation class. // diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h index b7f63218ba5..14681663372 100644 --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -1,19 +1,10 @@ //===- OperationSupport.h ---------------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a number of support types that Operation and related // classes build on top of. diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h index 707bb7c139f..e6b5e7a5eb7 100644 --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -1,19 +1,10 @@ //===- PatternMatch.h - PatternMatcher classes -------==---------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_PATTERNMATCHER_H #define MLIR_PATTERNMATCHER_H diff --git a/mlir/include/mlir/IR/Region.h b/mlir/include/mlir/IR/Region.h index c1390adb40b..00f3ca7fba1 100644 --- a/mlir/include/mlir/IR/Region.h +++ b/mlir/include/mlir/IR/Region.h @@ -1,19 +1,10 @@ //===- Region.h - MLIR Region Class -----------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the Region class. // diff --git a/mlir/include/mlir/IR/RegionGraphTraits.h b/mlir/include/mlir/IR/RegionGraphTraits.h index f45dcc41a4a..b11c87dbd0c 100644 --- a/mlir/include/mlir/IR/RegionGraphTraits.h +++ b/mlir/include/mlir/IR/RegionGraphTraits.h @@ -1,19 +1,10 @@ //===- RegionGraphTraits.h - llvm::GraphTraits for CFGs ---------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements specializations of llvm::GraphTraits for various MLIR // CFG data types. This allows the generic LLVM graph algorithms to be applied diff --git a/mlir/include/mlir/IR/StandardTypes.h b/mlir/include/mlir/IR/StandardTypes.h index b6b4b6ea52c..89ffc45e547 100644 --- a/mlir/include/mlir/IR/StandardTypes.h +++ b/mlir/include/mlir/IR/StandardTypes.h @@ -1,19 +1,10 @@ //===- StandardTypes.h - MLIR Standard Type Classes -------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_STANDARDTYPES_H #define MLIR_IR_STANDARDTYPES_H diff --git a/mlir/include/mlir/IR/StorageUniquerSupport.h b/mlir/include/mlir/IR/StorageUniquerSupport.h index 1a730731f32..f9288197072 100644 --- a/mlir/include/mlir/IR/StorageUniquerSupport.h +++ b/mlir/include/mlir/IR/StorageUniquerSupport.h @@ -1,19 +1,10 @@ //===- StorageUniquerSupport.h - MLIR Storage Uniquer Utilities -*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines utility classes for interfacing with StorageUniquer. // diff --git a/mlir/include/mlir/IR/SymbolTable.h b/mlir/include/mlir/IR/SymbolTable.h index e04beac6bc6..07829186cbf 100644 --- a/mlir/include/mlir/IR/SymbolTable.h +++ b/mlir/include/mlir/IR/SymbolTable.h @@ -1,19 +1,10 @@ //===- SymbolTable.h - MLIR Symbol Table Class ------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_SYMBOLTABLE_H #define MLIR_IR_SYMBOLTABLE_H diff --git a/mlir/include/mlir/IR/TypeSupport.h b/mlir/include/mlir/IR/TypeSupport.h index 86620da0b5c..8cc811cb916 100644 --- a/mlir/include/mlir/IR/TypeSupport.h +++ b/mlir/include/mlir/IR/TypeSupport.h @@ -1,19 +1,10 @@ //===- TypeSupport.h --------------------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines support types for registering dialect extended types. // diff --git a/mlir/include/mlir/IR/TypeUtilities.h b/mlir/include/mlir/IR/TypeUtilities.h index af22f9c4a9f..b4713226559 100644 --- a/mlir/include/mlir/IR/TypeUtilities.h +++ b/mlir/include/mlir/IR/TypeUtilities.h @@ -1,19 +1,10 @@ //===- TypeUtilities.h - Helper function for type queries -------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines generic type utilities. // diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h index 2ab36353dc4..6246e9bedd0 100644 --- a/mlir/include/mlir/IR/Types.h +++ b/mlir/include/mlir/IR/Types.h @@ -1,19 +1,10 @@ //===- Types.h - MLIR Type Classes ------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_TYPES_H #define MLIR_IR_TYPES_H diff --git a/mlir/include/mlir/IR/UseDefLists.h b/mlir/include/mlir/IR/UseDefLists.h index 96e4ace2529..898d0da2b28 100644 --- a/mlir/include/mlir/IR/UseDefLists.h +++ b/mlir/include/mlir/IR/UseDefLists.h @@ -1,19 +1,10 @@ //===- UseDefLists.h --------------------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines generic use/def list machinery and manipulation utilities. // diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h index 11cb8cdcbc7..030e6fa58b1 100644 --- a/mlir/include/mlir/IR/Value.h +++ b/mlir/include/mlir/IR/Value.h @@ -1,19 +1,10 @@ //===- Value.h - Base of the SSA Value hierarchy ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines generic Value type and manipulation utilities. // diff --git a/mlir/include/mlir/IR/Visitors.h b/mlir/include/mlir/IR/Visitors.h index 50d65627f1a..aaab933d239 100644 --- a/mlir/include/mlir/IR/Visitors.h +++ b/mlir/include/mlir/IR/Visitors.h @@ -1,19 +1,10 @@ //===- Visitors.h - Utilities for visiting operations -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines utilities for walking and visiting operations. // diff --git a/mlir/include/mlir/Parser.h b/mlir/include/mlir/Parser.h index 3a818ffa9d8..cae1e8b9ab1 100644 --- a/mlir/include/mlir/Parser.h +++ b/mlir/include/mlir/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - MLIR Parser Library Interface -----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file is contains the interface to the MLIR parser library. // diff --git a/mlir/include/mlir/Pass/AnalysisManager.h b/mlir/include/mlir/Pass/AnalysisManager.h index e233a4a5676..471cd011c40 100644 --- a/mlir/include/mlir/Pass/AnalysisManager.h +++ b/mlir/include/mlir/Pass/AnalysisManager.h @@ -1,19 +1,10 @@ //===- AnalysisManager.h - Analysis Management Infrastructure ---*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_PASS_ANALYSISMANAGER_H #define MLIR_PASS_ANALYSISMANAGER_H diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h index 380b097c78c..b4e8db86ff0 100644 --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -1,19 +1,10 @@ //===- Pass.h - Base classes for compiler passes ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_PASS_PASS_H #define MLIR_PASS_PASS_H diff --git a/mlir/include/mlir/Pass/PassInstrumentation.h b/mlir/include/mlir/Pass/PassInstrumentation.h index 4b61850c661..ef75e56ae62 100644 --- a/mlir/include/mlir/Pass/PassInstrumentation.h +++ b/mlir/include/mlir/Pass/PassInstrumentation.h @@ -1,19 +1,10 @@ //===- PassInstrumentation.h ------------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_PASS_PASSINSTRUMENTATION_H_ #define MLIR_PASS_PASSINSTRUMENTATION_H_ diff --git a/mlir/include/mlir/Pass/PassManager.h b/mlir/include/mlir/Pass/PassManager.h index 9de8ace435c..d4f3683f031 100644 --- a/mlir/include/mlir/Pass/PassManager.h +++ b/mlir/include/mlir/Pass/PassManager.h @@ -1,19 +1,10 @@ //===- PassManager.h - Pass Management Interface ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_PASS_PASSMANAGER_H #define MLIR_PASS_PASSMANAGER_H diff --git a/mlir/include/mlir/Pass/PassOptions.h b/mlir/include/mlir/Pass/PassOptions.h index eabfa73a1b6..8ebeead90c8 100644 --- a/mlir/include/mlir/Pass/PassOptions.h +++ b/mlir/include/mlir/Pass/PassOptions.h @@ -1,19 +1,10 @@ //===- PassOptions.h - Pass Option Utilities --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains utilities for registering options with compiler passes and // pipelines. diff --git a/mlir/include/mlir/Pass/PassRegistry.h b/mlir/include/mlir/Pass/PassRegistry.h index deb80ef765e..e07b9855c8d 100644 --- a/mlir/include/mlir/Pass/PassRegistry.h +++ b/mlir/include/mlir/Pass/PassRegistry.h @@ -1,19 +1,10 @@ //===- PassRegistry.h - Pass Registration Utilities -------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains utilities for registering information about compiler // passes. diff --git a/mlir/include/mlir/Quantizer/Configurations/FxpMathConfig.h b/mlir/include/mlir/Quantizer/Configurations/FxpMathConfig.h index 467512f2b77..f27d12d7f52 100644 --- a/mlir/include/mlir/Quantizer/Configurations/FxpMathConfig.h +++ b/mlir/include/mlir/Quantizer/Configurations/FxpMathConfig.h @@ -1,19 +1,10 @@ //===- FxpMathConfig.h - Reference fixed point config -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a TargetConfiguration for reference fixed-point math // quantization scheme based on the FxpMathOps (plus a small category of diff --git a/mlir/include/mlir/Quantizer/Support/Configuration.h b/mlir/include/mlir/Quantizer/Support/Configuration.h index 17a472de30a..3732fbad3a2 100644 --- a/mlir/include/mlir/Quantizer/Support/Configuration.h +++ b/mlir/include/mlir/Quantizer/Support/Configuration.h @@ -1,19 +1,10 @@ //===- Configuration.h - Configuration object base classes ------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // The quantizer is relatively agnostic to source and target dialects, with // the specific represented by configuration policy objects derived from diff --git a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h index 202e86566fc..fe66848b906 100644 --- a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h +++ b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h @@ -1,19 +1,10 @@ //===- ConstraintAnalysisGraph.h - Graphs type for constraints --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file provides graph-based data structures for representing anchors // and constraints between them. diff --git a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraphTraits.h b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraphTraits.h index 7e2b61d0496..35ec85f13b2 100644 --- a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraphTraits.h +++ b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraphTraits.h @@ -1,19 +1,10 @@ //===- ConstraintAnalysisGraphTraits.h - Traits for CAGs --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides graph traits for constraint analysis graphs. // diff --git a/mlir/include/mlir/Quantizer/Support/Metadata.h b/mlir/include/mlir/Quantizer/Support/Metadata.h index 6c327d9df7a..0545e78f917 100644 --- a/mlir/include/mlir/Quantizer/Support/Metadata.h +++ b/mlir/include/mlir/Quantizer/Support/Metadata.h @@ -1,19 +1,10 @@ //===- Metadata.h - Top level types and metadata ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains top level types needed to construct constraint graphs, // including context/allocator support and concrete metadata structs for diff --git a/mlir/include/mlir/Quantizer/Support/Rules.h b/mlir/include/mlir/Quantizer/Support/Rules.h index 9d1e53df5c0..536dd7ea07e 100644 --- a/mlir/include/mlir/Quantizer/Support/Rules.h +++ b/mlir/include/mlir/Quantizer/Support/Rules.h @@ -1,19 +1,10 @@ //===- Rules.h - Helpers for declaring facts and rules ----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines helper classes and functions for managing state (facts), // merging and tracking modification for various data types important for diff --git a/mlir/include/mlir/Quantizer/Support/Statistics.h b/mlir/include/mlir/Quantizer/Support/Statistics.h index 744c5b640ec..a24eecd3427 100644 --- a/mlir/include/mlir/Quantizer/Support/Statistics.h +++ b/mlir/include/mlir/Quantizer/Support/Statistics.h @@ -1,19 +1,10 @@ //===- Statistics.h - Collects statistics over tensors ----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines adapters for extracting various (per layer and per axis) // statistics over tensors. diff --git a/mlir/include/mlir/Quantizer/Support/TypeUtils.h b/mlir/include/mlir/Quantizer/Support/TypeUtils.h index 074f8b9e854..64ae5d65b57 100644 --- a/mlir/include/mlir/Quantizer/Support/TypeUtils.h +++ b/mlir/include/mlir/Quantizer/Support/TypeUtils.h @@ -1,19 +1,10 @@ //===- TypeUtils.h - Helper function for manipulating types -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines various helper functions for manipulating types. The // process of quantizing typically involves a number of type manipulations diff --git a/mlir/include/mlir/Quantizer/Support/UniformConstraints.h b/mlir/include/mlir/Quantizer/Support/UniformConstraints.h index 90b5fe12153..70c022c96a1 100644 --- a/mlir/include/mlir/Quantizer/Support/UniformConstraints.h +++ b/mlir/include/mlir/Quantizer/Support/UniformConstraints.h @@ -1,19 +1,10 @@ //===- UniformConstraints.h - Constraints for uniform quant -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a builder that lets you attach constraints necessary to // perform a variety of uniform quantization conversions to CAG anchors. diff --git a/mlir/include/mlir/Quantizer/Support/UniformSolvers.h b/mlir/include/mlir/Quantizer/Support/UniformSolvers.h index 98df671f81d..d6bd1a25ec3 100644 --- a/mlir/include/mlir/Quantizer/Support/UniformSolvers.h +++ b/mlir/include/mlir/Quantizer/Support/UniformSolvers.h @@ -1,19 +1,10 @@ //===- UniformSolvers.h - Uniform type solver algorithms --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines algorithms for solving uniform type parameters for various // conditions (i.e. fixed-point, affine, scale matching, etc). diff --git a/mlir/include/mlir/Quantizer/Transforms/Passes.h b/mlir/include/mlir/Quantizer/Transforms/Passes.h index 4fdea58daf4..3490f2953a4 100644 --- a/mlir/include/mlir/Quantizer/Transforms/Passes.h +++ b/mlir/include/mlir/Quantizer/Transforms/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Quantizer passes -----------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines entry points to create passes to perform various kinds // of quantization related transforms. diff --git a/mlir/include/mlir/Support/DebugStringHelper.h b/mlir/include/mlir/Support/DebugStringHelper.h index 230ed231458..0fa342686ba 100644 --- a/mlir/include/mlir/Support/DebugStringHelper.h +++ b/mlir/include/mlir/Support/DebugStringHelper.h @@ -1,19 +1,10 @@ //===- DebugStringHelper.h - helpers to generate debug strings --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Convenience functions to make it easier to get a string representation for // ops that have a print method. For use in debugging output and errors diff --git a/mlir/include/mlir/Support/FileUtilities.h b/mlir/include/mlir/Support/FileUtilities.h index 5ce97223176..c13b39efc4f 100644 --- a/mlir/include/mlir/Support/FileUtilities.h +++ b/mlir/include/mlir/Support/FileUtilities.h @@ -1,19 +1,10 @@ //===- FileUtilities.h - utilities for working with files -------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Common utilities for working with files. // diff --git a/mlir/include/mlir/Support/Functional.h b/mlir/include/mlir/Support/Functional.h index e8bf394b110..f18677f806b 100644 --- a/mlir/include/mlir/Support/Functional.h +++ b/mlir/include/mlir/Support/Functional.h @@ -1,19 +1,10 @@ //===- Functional.h - Helpers for functional-style Combinators --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_SUPPORT_FUNCTIONAL_H_ #define MLIR_SUPPORT_FUNCTIONAL_H_ diff --git a/mlir/include/mlir/Support/JitRunner.h b/mlir/include/mlir/Support/JitRunner.h index 14b66a8cebd..71c1d7d5105 100644 --- a/mlir/include/mlir/Support/JitRunner.h +++ b/mlir/include/mlir/Support/JitRunner.h @@ -1,19 +1,10 @@ //===- JitRunner.h - MLIR CPU Execution Driver Library ----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is a library that provides a shared implementation for command line // utilities that execute an MLIR file on the CPU by translating MLIR to LLVM diff --git a/mlir/include/mlir/Support/LLVM.h b/mlir/include/mlir/Support/LLVM.h index 91d145dd3ca..1885ebe609b 100644 --- a/mlir/include/mlir/Support/LLVM.h +++ b/mlir/include/mlir/Support/LLVM.h @@ -1,19 +1,10 @@ //===- LLVM.h - Import and forward declare core LLVM types ------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file forward declares and imports various common LLVM datatypes that // MLIR wants to use unqualified. diff --git a/mlir/include/mlir/Support/LogicalResult.h b/mlir/include/mlir/Support/LogicalResult.h index a9fc77ceef8..418293c0f80 100644 --- a/mlir/include/mlir/Support/LogicalResult.h +++ b/mlir/include/mlir/Support/LogicalResult.h @@ -1,19 +1,10 @@ //===- LogicalResult.h - Utilities for handling success/failure -*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_SUPPORT_LOGICAL_RESULT_H #define MLIR_SUPPORT_LOGICAL_RESULT_H diff --git a/mlir/include/mlir/Support/MathExtras.h b/mlir/include/mlir/Support/MathExtras.h index 767677fbc5d..1fd0634e9e8 100644 --- a/mlir/include/mlir/Support/MathExtras.h +++ b/mlir/include/mlir/Support/MathExtras.h @@ -1,19 +1,10 @@ //===- MathExtras.h - Math functions relevant to MLIR -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains math functions relevant to MLIR. // diff --git a/mlir/include/mlir/Support/MlirOptMain.h b/mlir/include/mlir/Support/MlirOptMain.h index be8e4328fb1..eac5ee765c2 100644 --- a/mlir/include/mlir/Support/MlirOptMain.h +++ b/mlir/include/mlir/Support/MlirOptMain.h @@ -1,19 +1,10 @@ //===- MlirOptMain.h - MLIR Optimizer Driver main ---------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Main entry function for mlir-opt for when built as standalone binary. // diff --git a/mlir/include/mlir/Support/STLExtras.h b/mlir/include/mlir/Support/STLExtras.h index 9bae7acadd6..9a128611c6e 100644 --- a/mlir/include/mlir/Support/STLExtras.h +++ b/mlir/include/mlir/Support/STLExtras.h @@ -1,19 +1,10 @@ //===- STLExtras.h - STL-like extensions that are used by MLIR --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains stuff that should be arguably sunk down to the LLVM // Support/STLExtras.h file over time. diff --git a/mlir/include/mlir/Support/StorageUniquer.h b/mlir/include/mlir/Support/StorageUniquer.h index fe1f898957a..f505731a649 100644 --- a/mlir/include/mlir/Support/StorageUniquer.h +++ b/mlir/include/mlir/Support/StorageUniquer.h @@ -1,19 +1,10 @@ //===- StorageUniquer.h - Common Storage Class Uniquer ----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_SUPPORT_STORAGEUNIQUER_H #define MLIR_SUPPORT_STORAGEUNIQUER_H diff --git a/mlir/include/mlir/Support/StringExtras.h b/mlir/include/mlir/Support/StringExtras.h index 2f75c8e5d20..5fc6769c124 100644 --- a/mlir/include/mlir/Support/StringExtras.h +++ b/mlir/include/mlir/Support/StringExtras.h @@ -1,19 +1,10 @@ //===- StringExtras.h - String utilities used by MLIR -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains string utility functions used within MLIR. // diff --git a/mlir/include/mlir/Support/ToolUtilities.h b/mlir/include/mlir/Support/ToolUtilities.h index 13a3742f849..3175ebbdba5 100644 --- a/mlir/include/mlir/Support/ToolUtilities.h +++ b/mlir/include/mlir/Support/ToolUtilities.h @@ -1,19 +1,10 @@ //===- ToolUtilities.h - MLIR Tool Utilities --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares common utilities for implementing MLIR tools. // diff --git a/mlir/include/mlir/Support/TranslateClParser.h b/mlir/include/mlir/Support/TranslateClParser.h index ccd4fb97676..822d4b1a0a4 100644 --- a/mlir/include/mlir/Support/TranslateClParser.h +++ b/mlir/include/mlir/Support/TranslateClParser.h @@ -1,19 +1,10 @@ //===- TranslateClParser.h - Translations command line parser ---*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains custom command line parser for translations. // diff --git a/mlir/include/mlir/TableGen/Argument.h b/mlir/include/mlir/TableGen/Argument.h index 83909392a43..6a0787e1b6c 100644 --- a/mlir/include/mlir/TableGen/Argument.h +++ b/mlir/include/mlir/TableGen/Argument.h @@ -1,19 +1,10 @@ //===- Argument.h - Argument definitions ------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file contains definitions for TableGen operation's arguments. // Operation arguments fall into two categories: diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 242376e24ff..747df945cea 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -1,19 +1,10 @@ //===- Attribute.h - Attribute wrapper class --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Attribute wrapper to simplify using TableGen Record defining a MLIR // Attribute. diff --git a/mlir/include/mlir/TableGen/Constraint.h b/mlir/include/mlir/TableGen/Constraint.h index 17b60da6027..fb7c1d74b64 100644 --- a/mlir/include/mlir/TableGen/Constraint.h +++ b/mlir/include/mlir/TableGen/Constraint.h @@ -1,19 +1,10 @@ //===- Constraint.h - Constraint class --------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Constraint wrapper to simplify using TableGen Record for constraints. // diff --git a/mlir/include/mlir/TableGen/Dialect.h b/mlir/include/mlir/TableGen/Dialect.h index 6861da46e88..56d17f41b56 100644 --- a/mlir/include/mlir/TableGen/Dialect.h +++ b/mlir/include/mlir/TableGen/Dialect.h @@ -1,18 +1,9 @@ // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Dialect wrapper to simplify using TableGen Record defining a MLIR dialect. // diff --git a/mlir/include/mlir/TableGen/Format.h b/mlir/include/mlir/TableGen/Format.h index 6f02c283cad..160ba5f036a 100644 --- a/mlir/include/mlir/TableGen/Format.h +++ b/mlir/include/mlir/TableGen/Format.h @@ -1,19 +1,10 @@ //===- Format.h - Utilities for String Format -------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares utilities for formatting strings. They are specially // tailored to the needs of TableGen'ing op definitions and rewrite rules, diff --git a/mlir/include/mlir/TableGen/GenInfo.h b/mlir/include/mlir/TableGen/GenInfo.h index 0b0bd192ae5..3c732c2ff49 100644 --- a/mlir/include/mlir/TableGen/GenInfo.h +++ b/mlir/include/mlir/TableGen/GenInfo.h @@ -1,19 +1,10 @@ //===- GenInfo.h - Generator info -------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_TABLEGEN_GENINFO_H_ #define MLIR_TABLEGEN_GENINFO_H_ diff --git a/mlir/include/mlir/TableGen/GenNameParser.h b/mlir/include/mlir/TableGen/GenNameParser.h index 7b1e8a36d03..65f4a8ceace 100644 --- a/mlir/include/mlir/TableGen/GenNameParser.h +++ b/mlir/include/mlir/TableGen/GenNameParser.h @@ -1,19 +1,10 @@ //===- GenNameParser.h - Command line parser for generators -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // The GenNameParser class adds all passes linked in to the system that are // creatable to the tool. diff --git a/mlir/include/mlir/TableGen/OpInterfaces.h b/mlir/include/mlir/TableGen/OpInterfaces.h index 0959f6be9bb..9bf18161564 100644 --- a/mlir/include/mlir/TableGen/OpInterfaces.h +++ b/mlir/include/mlir/TableGen/OpInterfaces.h @@ -1,19 +1,10 @@ //===- OpInterfaces.h - OpInterfaces wrapper class --------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // OpInterfaces wrapper to simplify using TableGen OpInterfaces. // diff --git a/mlir/include/mlir/TableGen/OpTrait.h b/mlir/include/mlir/TableGen/OpTrait.h index c3ea9a7bda0..59fc7acbfd7 100644 --- a/mlir/include/mlir/TableGen/OpTrait.h +++ b/mlir/include/mlir/TableGen/OpTrait.h @@ -1,19 +1,10 @@ //===- OpTrait.h - OpTrait wrapper class ------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // OpTrait wrapper to simplify using TableGen Record defining an MLIR OpTrait. // diff --git a/mlir/include/mlir/TableGen/Operator.h b/mlir/include/mlir/TableGen/Operator.h index 89fd4ed8d2e..dd5ff353bf9 100644 --- a/mlir/include/mlir/TableGen/Operator.h +++ b/mlir/include/mlir/TableGen/Operator.h @@ -1,19 +1,10 @@ //===- Operator.h - Operator class ------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Operator wrapper to simplify using TableGen Record defining a MLIR Op. // diff --git a/mlir/include/mlir/TableGen/Pattern.h b/mlir/include/mlir/TableGen/Pattern.h index 8bd1c918e31..bf89f6e7c82 100644 --- a/mlir/include/mlir/TableGen/Pattern.h +++ b/mlir/include/mlir/TableGen/Pattern.h @@ -1,19 +1,10 @@ //===- Pattern.h - Pattern wrapper class ------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Pattern wrapper class to simplify using TableGen Record defining a MLIR // Pattern. diff --git a/mlir/include/mlir/TableGen/Predicate.h b/mlir/include/mlir/TableGen/Predicate.h index 49f7ebcfe52..045b7fece2e 100644 --- a/mlir/include/mlir/TableGen/Predicate.h +++ b/mlir/include/mlir/TableGen/Predicate.h @@ -1,19 +1,10 @@ //===- Predicate.h - Predicate class ----------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Wrapper around predicates defined in TableGen. // diff --git a/mlir/include/mlir/TableGen/Region.h b/mlir/include/mlir/TableGen/Region.h index 21dffe687f4..778f68622bf 100644 --- a/mlir/include/mlir/TableGen/Region.h +++ b/mlir/include/mlir/TableGen/Region.h @@ -1,19 +1,10 @@ //===- TGRegion.h - TableGen region definitions -----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_TABLEGEN_REGION_H_ #define MLIR_TABLEGEN_REGION_H_ diff --git a/mlir/include/mlir/TableGen/Type.h b/mlir/include/mlir/TableGen/Type.h index 03cbd104dc1..35de70f52fd 100644 --- a/mlir/include/mlir/TableGen/Type.h +++ b/mlir/include/mlir/TableGen/Type.h @@ -1,19 +1,10 @@ //===- Type.h - Type class --------------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Type wrapper to simplify using TableGen Record defining a MLIR Type. // diff --git a/mlir/include/mlir/Target/LLVMIR.h b/mlir/include/mlir/Target/LLVMIR.h index 7ed7b39c4db..1cdc26ccee6 100644 --- a/mlir/include/mlir/Target/LLVMIR.h +++ b/mlir/include/mlir/Target/LLVMIR.h @@ -1,19 +1,10 @@ //===- LLVMIR.h - MLIR to LLVM IR conversion --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the entry point for the MLIR to LLVM IR conversion. // diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h index 7464e2a347d..4a5010ea09a 100644 --- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h +++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h @@ -1,19 +1,10 @@ //===- ModuleTranslation.h - MLIR to LLVM conversion ------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the translation between an MLIR LLVM dialect module and // the corresponding LLVMIR module. It only handles core LLVM IR operations. diff --git a/mlir/include/mlir/Target/NVVMIR.h b/mlir/include/mlir/Target/NVVMIR.h index ec9858e0fd7..377ee16d4e4 100644 --- a/mlir/include/mlir/Target/NVVMIR.h +++ b/mlir/include/mlir/Target/NVVMIR.h @@ -1,19 +1,10 @@ //===- NVVMIR.h - MLIR to LLVM + NVVM IR conversion -------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the entry point for the MLIR to LLVM + NVVM IR conversion. // diff --git a/mlir/include/mlir/Target/ROCDLIR.h b/mlir/include/mlir/Target/ROCDLIR.h index fd00e9458ef..25937eedd5a 100644 --- a/mlir/include/mlir/Target/ROCDLIR.h +++ b/mlir/include/mlir/Target/ROCDLIR.h @@ -1,19 +1,10 @@ //===- ROCDLIR.h - MLIR to LLVM + ROCDL IR conversion -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the entry point for the MLIR to LLVM + ROCDL IR // conversion. diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index f9f1207c0a0..dca26348689 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -1,19 +1,10 @@ //===- DialectConversion.h - MLIR dialect conversion pass -------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares a generic pass for converting between MLIR dialects. // diff --git a/mlir/include/mlir/Transforms/FoldUtils.h b/mlir/include/mlir/Transforms/FoldUtils.h index 65dd1b6df16..ed18619c44a 100644 --- a/mlir/include/mlir/Transforms/FoldUtils.h +++ b/mlir/include/mlir/Transforms/FoldUtils.h @@ -1,19 +1,10 @@ //===- FoldUtils.h - Operation Fold Utilities -------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file declares various operation folding utilities. These // utilities are intended to be used by passes to unify and simply their logic. diff --git a/mlir/include/mlir/Transforms/InliningUtils.h b/mlir/include/mlir/Transforms/InliningUtils.h index 47c4f48f468..e4739bba66b 100644 --- a/mlir/include/mlir/Transforms/InliningUtils.h +++ b/mlir/include/mlir/Transforms/InliningUtils.h @@ -1,19 +1,10 @@ //===- InliningUtils.h - Inliner utilities ----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines interfaces for various inlining utility methods. // diff --git a/mlir/include/mlir/Transforms/LoopFusionUtils.h b/mlir/include/mlir/Transforms/LoopFusionUtils.h index af84b8911eb..4c307ffeda3 100644 --- a/mlir/include/mlir/Transforms/LoopFusionUtils.h +++ b/mlir/include/mlir/Transforms/LoopFusionUtils.h @@ -1,19 +1,10 @@ //===- LoopFusionUtils.h - Loop fusion utilities ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes for various loop fusion utility // methods: these are not passes by themselves but are used either by passes, diff --git a/mlir/include/mlir/Transforms/LoopLikeInterface.h b/mlir/include/mlir/Transforms/LoopLikeInterface.h index a8bc0d11378..cba9ae78122 100644 --- a/mlir/include/mlir/Transforms/LoopLikeInterface.h +++ b/mlir/include/mlir/Transforms/LoopLikeInterface.h @@ -1,19 +1,10 @@ //===- LoopLikeInterface.h - Loop-like operations interface ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the operation interface for loop like operations. // diff --git a/mlir/include/mlir/Transforms/LoopLikeInterface.td b/mlir/include/mlir/Transforms/LoopLikeInterface.td index 583cfe26d87..089a3e19c35 100644 --- a/mlir/include/mlir/Transforms/LoopLikeInterface.td +++ b/mlir/include/mlir/Transforms/LoopLikeInterface.td @@ -1,19 +1,10 @@ //===- LoopLikeInterface.td - LoopLike interface -----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the interface for loop-like operations as used by LICM. // diff --git a/mlir/include/mlir/Transforms/LoopUtils.h b/mlir/include/mlir/Transforms/LoopUtils.h index 37434ea2ea8..a08a3fc8307 100644 --- a/mlir/include/mlir/Transforms/LoopUtils.h +++ b/mlir/include/mlir/Transforms/LoopUtils.h @@ -1,19 +1,10 @@ //===- LoopUtils.h - Loop transformation utilities --------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes for various loop transformation utility // methods: these are not passes by themselves but are used either by passes, diff --git a/mlir/include/mlir/Transforms/Passes.h b/mlir/include/mlir/Transforms/Passes.h index 5480a9a4fe1..1ea8f060e39 100644 --- a/mlir/include/mlir/Transforms/Passes.h +++ b/mlir/include/mlir/Transforms/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes that expose pass constructors in the loop // transformation library. diff --git a/mlir/include/mlir/Transforms/RegionUtils.h b/mlir/include/mlir/Transforms/RegionUtils.h index 63236d6a5a0..9639dfad857 100644 --- a/mlir/include/mlir/Transforms/RegionUtils.h +++ b/mlir/include/mlir/Transforms/RegionUtils.h @@ -1,19 +1,10 @@ //===- RegionUtils.h - Region-related transformation utilities --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_TRANSFORMS_REGIONUTILS_H_ #define MLIR_TRANSFORMS_REGIONUTILS_H_ diff --git a/mlir/include/mlir/Transforms/SideEffectsInterface.h b/mlir/include/mlir/Transforms/SideEffectsInterface.h index 443596b60c1..69c2a272c70 100644 --- a/mlir/include/mlir/Transforms/SideEffectsInterface.h +++ b/mlir/include/mlir/Transforms/SideEffectsInterface.h @@ -1,19 +1,10 @@ //===- SideEffectsInterface.h - dialect interface modeling side effects ---===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file specifies a dialect interface to model side-effects. // diff --git a/mlir/include/mlir/Transforms/Utils.h b/mlir/include/mlir/Transforms/Utils.h index 02c368ec496..a8268c1daa2 100644 --- a/mlir/include/mlir/Transforms/Utils.h +++ b/mlir/include/mlir/Transforms/Utils.h @@ -1,19 +1,10 @@ //===- Utils.h - General transformation utilities ---------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes for various transformation utilities for // memref's and non-loop IR structures. These are not passes by themselves but diff --git a/mlir/include/mlir/Transforms/ViewOpGraph.h b/mlir/include/mlir/Transforms/ViewOpGraph.h index 41f5eb5838d..c1782081adc 100644 --- a/mlir/include/mlir/Transforms/ViewOpGraph.h +++ b/mlir/include/mlir/Transforms/ViewOpGraph.h @@ -1,19 +1,10 @@ //===- ViewOpGraph.h - View/write op graphviz graphs ------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines interface to produce Graphviz outputs of MLIR op within block. // diff --git a/mlir/include/mlir/Transforms/ViewRegionGraph.h b/mlir/include/mlir/Transforms/ViewRegionGraph.h index 4378d38fae1..e8c47500c74 100644 --- a/mlir/include/mlir/Transforms/ViewRegionGraph.h +++ b/mlir/include/mlir/Transforms/ViewRegionGraph.h @@ -1,19 +1,10 @@ //===- ViewRegionGraph.h - View/write graphviz graphs -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines interface to produce Graphviz outputs of MLIR Regions. // diff --git a/mlir/include/mlir/Translation.h b/mlir/include/mlir/Translation.h index 0bf8178146a..9244b971753 100644 --- a/mlir/include/mlir/Translation.h +++ b/mlir/include/mlir/Translation.h @@ -1,19 +1,10 @@ //===- Translation.h - Translation registry ---------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Registry for user-provided translations. // diff --git a/mlir/lib/Analysis/AffineAnalysis.cpp b/mlir/lib/Analysis/AffineAnalysis.cpp index 60b2f17292b..27aa0748711 100644 --- a/mlir/lib/Analysis/AffineAnalysis.cpp +++ b/mlir/lib/Analysis/AffineAnalysis.cpp @@ -1,19 +1,10 @@ //===- AffineAnalysis.cpp - Affine structures analysis routines -----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements miscellaneous analysis routines for affine structures // (expressions, maps, sets), and other utilities relying on such analysis. diff --git a/mlir/lib/Analysis/AffineStructures.cpp b/mlir/lib/Analysis/AffineStructures.cpp index 21c2830c016..7ab547483cd 100644 --- a/mlir/lib/Analysis/AffineStructures.cpp +++ b/mlir/lib/Analysis/AffineStructures.cpp @@ -1,19 +1,10 @@ //===- AffineStructures.cpp - MLIR Affine Structures Class-----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Structures for affine/polyhedral analysis of MLIR functions. // diff --git a/mlir/lib/Analysis/CallGraph.cpp b/mlir/lib/Analysis/CallGraph.cpp index 6ec7c059526..65f6e83bcdf 100644 --- a/mlir/lib/Analysis/CallGraph.cpp +++ b/mlir/lib/Analysis/CallGraph.cpp @@ -1,19 +1,10 @@ //===- CallGraph.cpp - CallGraph analysis for MLIR ------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains interfaces and analyses for defining a nested callgraph. // diff --git a/mlir/lib/Analysis/Dominance.cpp b/mlir/lib/Analysis/Dominance.cpp index 532972b771b..060a505593a 100644 --- a/mlir/lib/Analysis/Dominance.cpp +++ b/mlir/lib/Analysis/Dominance.cpp @@ -1,19 +1,10 @@ //===- Dominance.cpp - Dominator analysis for CFGs ------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Implementation of dominance related classes and instantiations of extern // templates. diff --git a/mlir/lib/Analysis/InferTypeOpInterface.cpp b/mlir/lib/Analysis/InferTypeOpInterface.cpp index cbbd44681ba..2e52de2b3fa 100644 --- a/mlir/lib/Analysis/InferTypeOpInterface.cpp +++ b/mlir/lib/Analysis/InferTypeOpInterface.cpp @@ -1,19 +1,10 @@ //===- InferTypeOpInterface.cpp - Infer Type Interfaces ---------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the definitions of the infer op interfaces defined in // `InferTypeOpInterface.td`. diff --git a/mlir/lib/Analysis/Liveness.cpp b/mlir/lib/Analysis/Liveness.cpp index edb18e5645d..bef0b9fa385 100644 --- a/mlir/lib/Analysis/Liveness.cpp +++ b/mlir/lib/Analysis/Liveness.cpp @@ -1,19 +1,10 @@ //===- Liveness.cpp - Liveness analysis for MLIR --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Implementation of the liveness analysis. // diff --git a/mlir/lib/Analysis/LoopAnalysis.cpp b/mlir/lib/Analysis/LoopAnalysis.cpp index 9dfbfe0c542..5499f887c1e 100644 --- a/mlir/lib/Analysis/LoopAnalysis.cpp +++ b/mlir/lib/Analysis/LoopAnalysis.cpp @@ -1,19 +1,10 @@ //===- LoopAnalysis.cpp - Misc loop analysis routines //-------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements miscellaneous loop analysis routines. // diff --git a/mlir/lib/Analysis/MemRefBoundCheck.cpp b/mlir/lib/Analysis/MemRefBoundCheck.cpp index 4696ce64c22..1f7c1a1ae31 100644 --- a/mlir/lib/Analysis/MemRefBoundCheck.cpp +++ b/mlir/lib/Analysis/MemRefBoundCheck.cpp @@ -1,19 +1,10 @@ //===- MemRefBoundCheck.cpp - MLIR Affine Structures Class ----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to check memref accesses for out of bound // accesses. diff --git a/mlir/lib/Analysis/NestedMatcher.cpp b/mlir/lib/Analysis/NestedMatcher.cpp index 5f2be48b327..97eaafd37ce 100644 --- a/mlir/lib/Analysis/NestedMatcher.cpp +++ b/mlir/lib/Analysis/NestedMatcher.cpp @@ -1,19 +1,10 @@ //===- NestedMatcher.cpp - NestedMatcher Impl ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Analysis/NestedMatcher.h" #include "mlir/Dialect/AffineOps/AffineOps.h" diff --git a/mlir/lib/Analysis/OpStats.cpp b/mlir/lib/Analysis/OpStats.cpp index 1c9f6211a84..dbd938710ef 100644 --- a/mlir/lib/Analysis/OpStats.cpp +++ b/mlir/lib/Analysis/OpStats.cpp @@ -1,19 +1,10 @@ //===- OpStats.cpp - Prints stats of operations in module -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Module.h" #include "mlir/IR/Operation.h" diff --git a/mlir/lib/Analysis/SliceAnalysis.cpp b/mlir/lib/Analysis/SliceAnalysis.cpp index b09bddddd66..befe3d39759 100644 --- a/mlir/lib/Analysis/SliceAnalysis.cpp +++ b/mlir/lib/Analysis/SliceAnalysis.cpp @@ -1,19 +1,10 @@ //===- UseDefAnalysis.cpp - Analysis for Transitive UseDef chains ---------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements Analysis functions specific to slicing in Function. // diff --git a/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp b/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp index 80a579d163f..c6d7519740e 100644 --- a/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp +++ b/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp @@ -1,19 +1,10 @@ //===- TestMemRefDependenceCheck.cpp - Test dep analysis ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to run pair-wise memref access dependence checks. // diff --git a/mlir/lib/Analysis/TestParallelismDetection.cpp b/mlir/lib/Analysis/TestParallelismDetection.cpp index a9f9ea94a45..6cfc5431df3 100644 --- a/mlir/lib/Analysis/TestParallelismDetection.cpp +++ b/mlir/lib/Analysis/TestParallelismDetection.cpp @@ -1,19 +1,10 @@ //===- ParallelismDetection.cpp - Parallelism Detection pass ------------*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to detect parallel affine 'affine.for' ops. // diff --git a/mlir/lib/Analysis/Utils.cpp b/mlir/lib/Analysis/Utils.cpp index 73aa07e7d7b..0e7d10e78cf 100644 --- a/mlir/lib/Analysis/Utils.cpp +++ b/mlir/lib/Analysis/Utils.cpp @@ -1,19 +1,10 @@ //===- Utils.cpp ---- Misc utilities for analysis -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements miscellaneous analysis routines for non-loop IR // structures. diff --git a/mlir/lib/Analysis/VectorAnalysis.cpp b/mlir/lib/Analysis/VectorAnalysis.cpp index a7917eba503..cd77eff9e40 100644 --- a/mlir/lib/Analysis/VectorAnalysis.cpp +++ b/mlir/lib/Analysis/VectorAnalysis.cpp @@ -1,19 +1,10 @@ //===- VectorAnalysis.cpp - Analysis for Vectorization --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Analysis/AffineAnalysis.h" #include "mlir/Analysis/LoopAnalysis.h" diff --git a/mlir/lib/Analysis/Verifier.cpp b/mlir/lib/Analysis/Verifier.cpp index be499a93898..d4861b1a2e7 100644 --- a/mlir/lib/Analysis/Verifier.cpp +++ b/mlir/lib/Analysis/Verifier.cpp @@ -1,19 +1,10 @@ //===- Verifier.cpp - MLIR Verifier Implementation ------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the verify() methods on the various IR types, performing // (potentially expensive) checks on the holistic structure of the code. This diff --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp index 144b4a97e87..ce1e5c4a2af 100644 --- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp +++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp @@ -1,19 +1,10 @@ //===- AffineToStandard.cpp - Lower affine constructs to primitives -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file lowers affine constructs (If and For statements, AffineApply // operations) within a function into their standard If and For equivalent ops. diff --git a/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h b/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h index a408ab5b5d9..2ca9717ad86 100644 --- a/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h +++ b/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h @@ -1,19 +1,10 @@ //===- IndexIntrinsicsOpLowering.h - GPU IndexOps Lowering class *- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_GPUCOMMON_INDEXINTRINSICSOPLOWERING_H_ #define MLIR_CONVERSION_GPUCOMMON_INDEXINTRINSICSOPLOWERING_H_ diff --git a/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h b/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h index 3ab8e75633e..97881d359f6 100644 --- a/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h +++ b/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h @@ -1,19 +1,10 @@ //===- OpToFuncCallLowering.h - GPU ops lowering to custom calls *- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_ #define MLIR_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_ diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp index a91c43e1e92..66a2e66f99a 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp @@ -1,19 +1,10 @@ //===- ConvertKernelFuncToCubin.cpp - MLIR GPU lowering passes ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to convert gpu kernel functions into a // corresponding binary blob that can be executed on a CUDA GPU. Currently diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp index 840ad6ba701..3383cf13d36 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp @@ -1,19 +1,10 @@ //===- ConvertLaunchFuncToCudaCalls.cpp - MLIR CUDA lowering passes -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to convert gpu.launch_func op into a sequence of // CUDA runtime calls. As the CUDA runtime does not have a stable published ABI, diff --git a/mlir/lib/Conversion/GPUToNVVM/GPUToNVVM.td b/mlir/lib/Conversion/GPUToNVVM/GPUToNVVM.td index 8c27ba49686..0a6aec07041 100644 --- a/mlir/lib/Conversion/GPUToNVVM/GPUToNVVM.td +++ b/mlir/lib/Conversion/GPUToNVVM/GPUToNVVM.td @@ -1,19 +1,10 @@ //==-- GPUToNVVM.td - GPU Ops to NVVM Patterns ---------------*- tablegen -*==// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines Patterns to lower GPU ops to NVVM. // diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp index bf18ea03dab..e15ad823a2b 100644 --- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp +++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp @@ -1,19 +1,10 @@ //===- LowerGpuOpsToNVVMOps.cpp - MLIR GPU to NVVM lowering passes --------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to generate NVVMIR operations for higher-level // GPU operations. diff --git a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp index 59892dbcee8..83770641bd4 100644 --- a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp +++ b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp @@ -1,19 +1,10 @@ //===- LowerGpuOpsToROCDLOps.cpp - MLIR GPU to ROCDL lowering passes ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to generate ROCDLIR operations for higher-level // GPU operations. diff --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp index 0c34fc2b8e1..95c46853b1f 100644 --- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp @@ -1,19 +1,10 @@ //===- ConvertGPUToSPIRV.cpp - Convert GPU ops to SPIR-V dialect ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the conversion patterns from GPU ops to SPIR-V dialect. // diff --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp index b8fe27e92a2..115096003e1 100644 --- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp @@ -1,19 +1,10 @@ //===- ConvertGPUToSPIRVPass.cpp - GPU to SPIR-V dialect lowering passes --===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to convert a kernel function in the GPU Dialect // into a spv.module operation diff --git a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp index 8b6b9fb7930..1b70df6f8bd 100644 --- a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp +++ b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp @@ -1,19 +1,10 @@ //===- LinalgToLLVM.cpp - conversion from Linalg to LLVM dialect ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h" #include "mlir/Conversion/AffineToStandard/AffineToStandard.h" diff --git a/mlir/lib/Conversion/LoopToStandard/ConvertLoopToStandard.cpp b/mlir/lib/Conversion/LoopToStandard/ConvertLoopToStandard.cpp index d8df7487e71..59dac73de9c 100644 --- a/mlir/lib/Conversion/LoopToStandard/ConvertLoopToStandard.cpp +++ b/mlir/lib/Conversion/LoopToStandard/ConvertLoopToStandard.cpp @@ -1,19 +1,10 @@ //===- ConvertLoopToStandard.cpp - ControlFlow to CFG conversion ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to convert loop.for, loop.if and loop.terminator // ops into standard CFG ops. diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp index 3cbce7caa76..24bb8ffc462 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp @@ -1,19 +1,10 @@ //===- LoopsToGPU.cpp - Convert an affine loop nest to a GPU kernel -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This implements a straightforward conversion of an loop nest into a GPU // kernel. The caller is expected to guarantee that the conversion is correct diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp index 63836883512..4dfd26a4392 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp @@ -1,19 +1,10 @@ //===- LoopsToGPUPass.cpp - Convert a loop nest to a GPU kernel -----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h" #include "mlir/Conversion/LoopsToGPU/LoopsToGPU.h" diff --git a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp index 67b545c4ec8..160678efe9f 100644 --- a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp @@ -1,19 +1,10 @@ //===- ConvertStandardToLLVM.cpp - Standard to LLVM dialect conversion-----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to convert MLIR standard and builtin dialects // into the LLVM IR dialect. diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp index f7b0c9cb9bc..af1c92ef11d 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp @@ -1,19 +1,10 @@ //===- ConvertStandardToSPIRV.cpp - Standard to SPIR-V dialect conversion--===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements patterns to convert Standard Ops to the SPIR-V dialect. // diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp index 113789abe8a..41deec1f6ab 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp @@ -1,19 +1,10 @@ //===- ConvertStandardToSPIRVPass.cpp - Convert Std Ops to SPIR-V Ops -----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to convert MLIR standard ops into the SPIR-V // ops. diff --git a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp index 2e1a7f09ff8..5d693336c3f 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp @@ -1,19 +1,10 @@ //===- LegalizeStandardForSPIRV.cpp - Legalize ops for SPIR-V lowering ----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This transformation pass legalizes operations before the conversion to SPIR-V // dialect to handle ops that cannot be lowered directly. diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp index 5099cb01bbc..56005220d3f 100644 --- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp @@ -1,19 +1,10 @@ //===- VectorToLLVM.cpp - Conversion from Vector to the LLVM dialect ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" diff --git a/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp b/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp index 33778e42329..3ed031b985a 100644 --- a/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp +++ b/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp @@ -1,19 +1,10 @@ //===- VectorToLoops.cpp - Conversion from Vector to mix of Loops and Std -===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements target-dependent lowering of vector transfer operations. // diff --git a/mlir/lib/Dialect/AffineOps/AffineOps.cpp b/mlir/lib/Dialect/AffineOps/AffineOps.cpp index 3a21de389c7..bfe72101e85 100644 --- a/mlir/lib/Dialect/AffineOps/AffineOps.cpp +++ b/mlir/lib/Dialect/AffineOps/AffineOps.cpp @@ -1,19 +1,10 @@ //===- AffineOps.cpp - MLIR Affine Operations -----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/AffineOps/AffineOps.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/lib/Dialect/AffineOps/DialectRegistration.cpp b/mlir/lib/Dialect/AffineOps/DialectRegistration.cpp index 9197e3c619f..775e25ec8ea 100644 --- a/mlir/lib/Dialect/AffineOps/DialectRegistration.cpp +++ b/mlir/lib/Dialect/AffineOps/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - Register Affine Op dialect ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/AffineOps/AffineOps.h" using namespace mlir; diff --git a/mlir/lib/Dialect/FxpMathOps/IR/DialectRegistration.cpp b/mlir/lib/Dialect/FxpMathOps/IR/DialectRegistration.cpp index aa6782e1464..57d5ae8e789 100644 --- a/mlir/lib/Dialect/FxpMathOps/IR/DialectRegistration.cpp +++ b/mlir/lib/Dialect/FxpMathOps/IR/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - Register FxpMathOps dialect --------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/FxpMathOps/FxpMathOps.h" diff --git a/mlir/lib/Dialect/FxpMathOps/IR/FxpMathOps.cpp b/mlir/lib/Dialect/FxpMathOps/IR/FxpMathOps.cpp index 18c07b07117..30e7dc04104 100644 --- a/mlir/lib/Dialect/FxpMathOps/IR/FxpMathOps.cpp +++ b/mlir/lib/Dialect/FxpMathOps/IR/FxpMathOps.cpp @@ -1,19 +1,10 @@ //===- FxpMathOps.cpp - Op implementation for FxpMathOps ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/FxpMathOps/FxpMathOps.h" #include "mlir/Dialect/QuantOps/QuantTypes.h" diff --git a/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp b/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp index e1951ff900b..725751eb6c1 100644 --- a/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp +++ b/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp @@ -1,19 +1,10 @@ //===- LowerUniformRealMath.cpp ------------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "UniformKernelUtils.h" diff --git a/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h b/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h index 57a8422b362..bce5285a8b0 100644 --- a/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h +++ b/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h @@ -1,19 +1,10 @@ //===- UniformKernelUtils.h - Utilities for lowering uniform math - C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_FXPMATH_UNIFORM_KERNEL_UTILS_H_ #define MLIR_FXPMATH_UNIFORM_KERNEL_UTILS_H_ diff --git a/mlir/lib/Dialect/GPU/IR/DialectRegistration.cpp b/mlir/lib/Dialect/GPU/IR/DialectRegistration.cpp index af50d0270cf..511c69e0695 100644 --- a/mlir/lib/Dialect/GPU/IR/DialectRegistration.cpp +++ b/mlir/lib/Dialect/GPU/IR/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - MLIR GPU dialect registration ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/GPU/GPUDialect.h" diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp index 349c1fa4644..62d6a4b7ea4 100644 --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -1,19 +1,10 @@ //===- GPUDialect.cpp - MLIR Dialect for GPU Kernels implementation -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the GPU kernel-related dialect and its operations. // diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp index 8f5f50e4909..6a7cd290dd2 100644 --- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp @@ -1,19 +1,10 @@ //===- KernelOutlining.cpp - Implementation of GPU kernel outlining -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the GPU dialect kernel outlining pass. // diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index b94ee335bd2..b8d2d242657 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -1,19 +1,10 @@ //===- LLVMDialect.cpp - LLVM IR Ops and Dialect registration -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the types and operation details for the LLVM IR dialect in // MLIR, and the LLVM IR dialect. It also registers the dialect. diff --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp index e4708fbe535..3a8e84ea918 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp @@ -1,19 +1,10 @@ //===- NVVMDialect.cpp - NVVM IR Ops and Dialect registration -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the types and operation details for the NVVM IR dialect in // MLIR, and the LLVM IR dialect. It also registers the dialect. diff --git a/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp index 30c55b52e59..c11572cf5a2 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp @@ -1,19 +1,10 @@ //===- ROCDLDialect.cpp - ROCDL IR Ops and Dialect registration -----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the types and operation details for the ROCDL IR dialect in // MLIR, and the LLVM IR dialect. It also registers the dialect. diff --git a/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp b/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp index ee122e16037..5fbbdea60c2 100644 --- a/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp +++ b/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp @@ -1,19 +1,10 @@ //===- DependenceAnalysis.cpp - Dependence analysis on SSA views ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements view-based alias and dependence analyses. // diff --git a/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp b/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp index 7b530d7f0df..af5e576b290 100644 --- a/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp +++ b/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp @@ -1,19 +1,10 @@ //===- Builders.cpp - MLIR Declarative Linalg Builders --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/Linalg/EDSC/Builders.h" #include "mlir/Dialect/Linalg/EDSC/Intrinsics.h" diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp index c5f30b7e10b..10c37c0ec43 100644 --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -1,19 +1,10 @@ //===- LinalgOps.cpp - Implementation of the linalg operations ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a the Linalg operations. // diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp index 263a64c5cdc..32b1620f67c 100644 --- a/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Implementation of the linalg dialect and types -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the Linalg dialect types and dialect. // diff --git a/mlir/lib/Dialect/Linalg/LinalgRegistration.cpp b/mlir/lib/Dialect/Linalg/LinalgRegistration.cpp index df21ffa88ac..768b18b57f0 100644 --- a/mlir/lib/Dialect/Linalg/LinalgRegistration.cpp +++ b/mlir/lib/Dialect/Linalg/LinalgRegistration.cpp @@ -1,19 +1,10 @@ //===- LinalgRegistration.cpp - Register the linalg dialect statically ----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/Linalg/IR/LinalgOps.h" #include "mlir/Dialect/Linalg/IR/LinalgTypes.h" diff --git a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp index 49cea7e4170..27dcf663d23 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp @@ -1,19 +1,10 @@ //===- Fusion.cpp - Implementation of linalg Fusion -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the linalg dialect Fusion pass. // diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp index e468c19a0b4..0f333791dd7 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp @@ -1,19 +1,10 @@ //===- LowerToLoops.cpp - conversion from Linalg library ops to loops------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/AffineOps/AffineOps.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp index 999406e05cf..451803797f4 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp @@ -1,19 +1,10 @@ //===- LinalgTransforms.cpp - Linalg transformations as patterns ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements logic for transforming Linalg operations. // diff --git a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp index b1dae455194..08bc1518a19 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp @@ -1,19 +1,10 @@ //===- Promotion.cpp - Implementation of linalg Promotion -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the linalg dialect Promotion pass. // diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp index 07d559918cf..99645a23100 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -1,19 +1,10 @@ //===- Tiling.cpp - Implementation of linalg Tiling -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the linalg dialect Tiling pass. // diff --git a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp index 125937807f4..ae02af0ecc8 100644 --- a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp @@ -1,19 +1,10 @@ //===- Utils.cpp - Utilities to support the Linalg dialect ----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements utilities for the Linalg dialect. // diff --git a/mlir/lib/Dialect/LoopOps/DialectRegistration.cpp b/mlir/lib/Dialect/LoopOps/DialectRegistration.cpp index 5724402e690..6564e78855c 100644 --- a/mlir/lib/Dialect/LoopOps/DialectRegistration.cpp +++ b/mlir/lib/Dialect/LoopOps/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - Register loop dialect --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/LoopOps/LoopOps.h" using namespace mlir; diff --git a/mlir/lib/Dialect/LoopOps/LoopOps.cpp b/mlir/lib/Dialect/LoopOps/LoopOps.cpp index 9610a1ac270..d3040c1bbb2 100644 --- a/mlir/lib/Dialect/LoopOps/LoopOps.cpp +++ b/mlir/lib/Dialect/LoopOps/LoopOps.cpp @@ -1,19 +1,10 @@ //===- Ops.cpp - Loop MLIR Operations -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/lib/Dialect/QuantOps/IR/DialectRegistration.cpp b/mlir/lib/Dialect/QuantOps/IR/DialectRegistration.cpp index b071248f4bb..1738d6d7277 100644 --- a/mlir/lib/Dialect/QuantOps/IR/DialectRegistration.cpp +++ b/mlir/lib/Dialect/QuantOps/IR/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - Register Quantization dialect ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/QuantOps.h" diff --git a/mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp b/mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp index 51f19940dcb..faeff246bd2 100644 --- a/mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp +++ b/mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp @@ -1,19 +1,10 @@ //===- QuantOps.cpp - Quantization Type and Ops Implementation --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/QuantOps.h" #include "TypeDetail.h" diff --git a/mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp b/mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp index bc8290cda16..2e33963602c 100644 --- a/mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp +++ b/mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp @@ -1,19 +1,10 @@ //===- QuantOps.cpp - Quantization Type and Ops Implementation --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/QuantTypes.h" #include "TypeDetail.h" diff --git a/mlir/lib/Dialect/QuantOps/IR/TypeDetail.h b/mlir/lib/Dialect/QuantOps/IR/TypeDetail.h index 13a88da3043..801a0de32b4 100644 --- a/mlir/lib/Dialect/QuantOps/IR/TypeDetail.h +++ b/mlir/lib/Dialect/QuantOps/IR/TypeDetail.h @@ -1,19 +1,10 @@ //===- TypeDetail.h - QuantOps Type detail ----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef TYPE_DETAIL_H_ #define TYPE_DETAIL_H_ diff --git a/mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp b/mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp index 2bdde1f94f8..2689a2dff89 100644 --- a/mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp +++ b/mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp @@ -1,19 +1,10 @@ //===- TypeParser.h - Quantization Type Parser ------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/QuantOps.h" #include "mlir/Dialect/QuantOps/QuantTypes.h" diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp index 61636dcdd8b..08a5ec59e8d 100644 --- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp +++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp @@ -1,19 +1,10 @@ //===- ConvertConst.cpp - Quantizes constant ops --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/Passes.h" #include "mlir/Dialect/QuantOps/QuantOps.h" diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp index 83fa9237dee..2a4c14f2231 100644 --- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp +++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp @@ -1,19 +1,10 @@ //===- ConvertSimQuant.cpp - Converts simulated quant ops------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/FakeQuantSupport.h" #include "mlir/Dialect/QuantOps/Passes.h" diff --git a/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp b/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp index f4256cf25c8..cbd4315f832 100644 --- a/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp +++ b/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp @@ -1,19 +1,10 @@ //===- FakeQuantSupport.cpp - Support utilities for FakeQuant ops ---------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/FakeQuantSupport.h" #include "mlir/Dialect/QuantOps/QuantTypes.h" diff --git a/mlir/lib/Dialect/QuantOps/Utils/QuantizeUtils.cpp b/mlir/lib/Dialect/QuantOps/Utils/QuantizeUtils.cpp index 56e2cbae4f0..094fefee486 100644 --- a/mlir/lib/Dialect/QuantOps/Utils/QuantizeUtils.cpp +++ b/mlir/lib/Dialect/QuantOps/Utils/QuantizeUtils.cpp @@ -1,19 +1,10 @@ //===- QuantizeUtils.cpp - Support utilities for quantization -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/QuantizeUtils.h" #include "mlir/Dialect/QuantOps/UniformSupport.h" diff --git a/mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp b/mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp index 34e767dfee3..df002336c16 100644 --- a/mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp +++ b/mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp @@ -1,19 +1,10 @@ //===- UniformSupport.cpp - Support utilities for uniform quant -----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/UniformSupport.h" #include "mlir/IR/StandardTypes.h" diff --git a/mlir/lib/Dialect/SDBM/SDBM.cpp b/mlir/lib/Dialect/SDBM/SDBM.cpp index 510e13e8028..03ffe3ffbb9 100644 --- a/mlir/lib/Dialect/SDBM/SDBM.cpp +++ b/mlir/lib/Dialect/SDBM/SDBM.cpp @@ -1,19 +1,10 @@ //===- SDBM.cpp - MLIR SDBM implementation --------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // A striped difference-bound matrix (SDBM) is a set in Z^N (or R^N) defined // as {(x_1, ... x_n) | f(x_1, ... x_n) >= 0} where f is an SDBM expression. diff --git a/mlir/lib/Dialect/SDBM/SDBMDialect.cpp b/mlir/lib/Dialect/SDBM/SDBMDialect.cpp index d3d895fec88..fab9463a866 100644 --- a/mlir/lib/Dialect/SDBM/SDBMDialect.cpp +++ b/mlir/lib/Dialect/SDBM/SDBMDialect.cpp @@ -1,19 +1,10 @@ //===- SDBMDialect.cpp - Dialect for striped difference-bound matrices ----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/SDBM/SDBMDialect.h" diff --git a/mlir/lib/Dialect/SDBM/SDBMExpr.cpp b/mlir/lib/Dialect/SDBM/SDBMExpr.cpp index 44cdd18cf98..68e3e1c278e 100644 --- a/mlir/lib/Dialect/SDBM/SDBMExpr.cpp +++ b/mlir/lib/Dialect/SDBM/SDBMExpr.cpp @@ -1,19 +1,10 @@ //===- SDBMExpr.cpp - MLIR SDBM Expression implementation -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // A striped difference-bound matrix (SDBM) expression is a constant expression, // an identifier, a binary expression with constant RHS and +, stripe operators diff --git a/mlir/lib/Dialect/SDBM/SDBMExprDetail.h b/mlir/lib/Dialect/SDBM/SDBMExprDetail.h index 0441200754c..fb80b45902e 100644 --- a/mlir/lib/Dialect/SDBM/SDBMExprDetail.h +++ b/mlir/lib/Dialect/SDBM/SDBMExprDetail.h @@ -1,19 +1,10 @@ //===- SDBMExprDetail.h - MLIR SDBM Expression storage details --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This holds implementation details of SDBMExpr, in particular underlying // storage types. diff --git a/mlir/lib/Dialect/SPIRV/DialectRegistration.cpp b/mlir/lib/Dialect/SPIRV/DialectRegistration.cpp index 63e9e812c39..431b40ef022 100644 --- a/mlir/lib/Dialect/SPIRV/DialectRegistration.cpp +++ b/mlir/lib/Dialect/SPIRV/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - MLIR SPIR-V dialect registration ---------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/SPIRV/SPIRVDialect.h" diff --git a/mlir/lib/Dialect/SPIRV/LayoutUtils.cpp b/mlir/lib/Dialect/SPIRV/LayoutUtils.cpp index 5db478d388b..a12d04edd68 100644 --- a/mlir/lib/Dialect/SPIRV/LayoutUtils.cpp +++ b/mlir/lib/Dialect/SPIRV/LayoutUtils.cpp @@ -1,19 +1,10 @@ //===-- LayoutUtils.cpp - Decorate composite type with layout information -===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements Utilities used to get alignment and layout information // for types in SPIR-V dialect. diff --git a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp index ca9b883a703..7b6c013f9ed 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp @@ -1,19 +1,10 @@ //===- SPIRVLowering.cpp - Standard to SPIR-V dialect conversion--===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements utilities used to lower to SPIR-V dialect. // diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp index a20c18056e1..e42dc10f55d 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp @@ -1,19 +1,10 @@ //===- SPIRVOps.cpp - MLIR SPIR-V operations ------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the operations in the SPIR-V dialect. // diff --git a/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp b/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp index 15621aa5fde..18e027afb4c 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp @@ -1,19 +1,10 @@ //===- SPIRVTypes.cpp - MLIR SPIR-V Types ---------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the types in the SPIR-V dialect. // diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp index 799828cb629..9e820c6f42b 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp @@ -1,19 +1,10 @@ //===- Deserializer.cpp - MLIR SPIR-V Deserialization ---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the SPIR-V binary to MLIR SPIR-V module deserialization. // diff --git a/mlir/lib/Dialect/SPIRV/Serialization/SPIRVBinaryUtils.cpp b/mlir/lib/Dialect/SPIRV/Serialization/SPIRVBinaryUtils.cpp index ba383b2cc6c..13405c9883d 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/SPIRVBinaryUtils.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/SPIRVBinaryUtils.cpp @@ -1,19 +1,10 @@ //===- SPIRVBinaryUtils.cpp - MLIR SPIR-V Binary Module Utilities ---------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines common utilities for SPIR-V binary module. // diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp index 9b47045ea61..7ff471dfda5 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp @@ -1,19 +1,10 @@ //===- Serializer.cpp - MLIR SPIR-V Serialization -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the MLIR SPIR-V module to SPIR-V binary serialization. // diff --git a/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp b/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp index e9b4f23cca4..750710fa3d9 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp @@ -1,19 +1,10 @@ //===- TranslateRegistration.cpp - hooks to mlir-translate ----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a translation from SPIR-V binary module to MLIR SPIR-V // ModuleOp. diff --git a/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp index be486f858fe..07621d6fa80 100644 --- a/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp @@ -1,19 +1,10 @@ //===- DecorateSPIRVCompositeTypeLayoutPass.cpp - Decorate composite type -===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to decorate the composite types used by // composite objects in the StorageBuffer, PhysicalStorageBuffer, Uniform, and diff --git a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp index 93ce2c0a0d5..76e1b9b716e 100644 --- a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp @@ -1,19 +1,10 @@ //===- LowerABIAttributesPass.cpp - Decorate composite type ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to lower attributes that specify the shader ABI // for the functions in the generated SPIR-V module. diff --git a/mlir/lib/Dialect/StandardOps/DialectRegistration.cpp b/mlir/lib/Dialect/StandardOps/DialectRegistration.cpp index 6b5578f93cf..684806009e5 100644 --- a/mlir/lib/Dialect/StandardOps/DialectRegistration.cpp +++ b/mlir/lib/Dialect/StandardOps/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - Register standard Op dialect -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/StandardOps/Ops.h" using namespace mlir; diff --git a/mlir/lib/Dialect/StandardOps/Ops.cpp b/mlir/lib/Dialect/StandardOps/Ops.cpp index 94166b5a7dd..55da59a0c74 100644 --- a/mlir/lib/Dialect/StandardOps/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/Ops.cpp @@ -1,19 +1,10 @@ //===- Ops.cpp - Standard MLIR Operations ---------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/lib/Dialect/Traits.cpp b/mlir/lib/Dialect/Traits.cpp index 0ac07c2c4f5..3aea206c07e 100644 --- a/mlir/lib/Dialect/Traits.cpp +++ b/mlir/lib/Dialect/Traits.cpp @@ -1,19 +1,10 @@ //===- Traits.cpp - Common op traits shared by dialects -------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/Traits.h" #include "mlir/IR/StandardTypes.h" diff --git a/mlir/lib/Dialect/VectorOps/DialectRegistration.cpp b/mlir/lib/Dialect/VectorOps/DialectRegistration.cpp index 0caa1cf629e..edd6abb4e2e 100644 --- a/mlir/lib/Dialect/VectorOps/DialectRegistration.cpp +++ b/mlir/lib/Dialect/VectorOps/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - Register super vectorization dialect -----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/VectorOps/VectorOps.h" using namespace mlir; diff --git a/mlir/lib/Dialect/VectorOps/VectorOps.cpp b/mlir/lib/Dialect/VectorOps/VectorOps.cpp index 18c1714f403..8ceff014029 100644 --- a/mlir/lib/Dialect/VectorOps/VectorOps.cpp +++ b/mlir/lib/Dialect/VectorOps/VectorOps.cpp @@ -1,19 +1,10 @@ //===- VectorOps.cpp - MLIR Super Vectorizer Operations -------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements convenience types for working with super-vectorization // operations, in particular super-vector loads and stores. diff --git a/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp b/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp index e5c281cbf64..927aeda4ecd 100644 --- a/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp +++ b/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp @@ -1,19 +1,10 @@ //===- VectorToLoops.cpp - Conversion within the Vector dialect -----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements target-independent rewrites as 1->N patterns. // diff --git a/mlir/lib/EDSC/Builders.cpp b/mlir/lib/EDSC/Builders.cpp index 35108ed5666..b25eb987a9e 100644 --- a/mlir/lib/EDSC/Builders.cpp +++ b/mlir/lib/EDSC/Builders.cpp @@ -1,19 +1,10 @@ //===- Builders.cpp - MLIR Declarative Builder Classes --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/EDSC/Builders.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/lib/EDSC/CoreAPIs.cpp b/mlir/lib/EDSC/CoreAPIs.cpp index 46199c29c14..6f7c1728bb0 100644 --- a/mlir/lib/EDSC/CoreAPIs.cpp +++ b/mlir/lib/EDSC/CoreAPIs.cpp @@ -1,19 +1,10 @@ //===- Types.cpp - Implementations of MLIR Core C APIs --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir-c/Core.h" diff --git a/mlir/lib/EDSC/Helpers.cpp b/mlir/lib/EDSC/Helpers.cpp index 1771eb0a427..79888334cd9 100644 --- a/mlir/lib/EDSC/Helpers.cpp +++ b/mlir/lib/EDSC/Helpers.cpp @@ -1,19 +1,10 @@ //===- Helpers.cpp - MLIR Declarative Helper Functionality ----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/EDSC/Helpers.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/lib/EDSC/Intrinsics.cpp b/mlir/lib/EDSC/Intrinsics.cpp index c6738c42993..1bb32b97867 100644 --- a/mlir/lib/EDSC/Intrinsics.cpp +++ b/mlir/lib/EDSC/Intrinsics.cpp @@ -1,19 +1,10 @@ //===- Intrinsics.cpp - MLIR Operations for Declarative Builders ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/EDSC/Intrinsics.h" #include "mlir/EDSC/Builders.h" diff --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp index 5098ba81762..1537018076a 100644 --- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp @@ -1,19 +1,10 @@ //===- ExecutionEngine.cpp - MLIR Execution engine and utils --------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the execution engine for MLIR modules based on LLVM Orc // JIT engine. diff --git a/mlir/lib/ExecutionEngine/OptUtils.cpp b/mlir/lib/ExecutionEngine/OptUtils.cpp index dc3bd20794e..ec2ae5f2dcc 100644 --- a/mlir/lib/ExecutionEngine/OptUtils.cpp +++ b/mlir/lib/ExecutionEngine/OptUtils.cpp @@ -1,19 +1,10 @@ //===- OptUtils.cpp - MLIR Execution Engine optimization pass utilities ---===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the utility functions to trigger LLVM optimizations from // MLIR Execution Engine. diff --git a/mlir/lib/IR/AffineExpr.cpp b/mlir/lib/IR/AffineExpr.cpp index 009c1a1485c..dd8ce00c82a 100644 --- a/mlir/lib/IR/AffineExpr.cpp +++ b/mlir/lib/IR/AffineExpr.cpp @@ -1,19 +1,10 @@ //===- AffineExpr.cpp - MLIR Affine Expr Classes --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/AffineExpr.h" #include "AffineExprDetail.h" diff --git a/mlir/lib/IR/AffineExprDetail.h b/mlir/lib/IR/AffineExprDetail.h index 214fee65056..8824ddd8682 100644 --- a/mlir/lib/IR/AffineExprDetail.h +++ b/mlir/lib/IR/AffineExprDetail.h @@ -1,19 +1,10 @@ //===- AffineExprDetail.h - MLIR Affine Expr storage details ----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This holds implementation details of AffineExpr. Ideally it would not be // exposed and would be kept local to AffineExpr.cpp however, MLIRContext.cpp diff --git a/mlir/lib/IR/AffineMap.cpp b/mlir/lib/IR/AffineMap.cpp index 6cfef363985..50624afa3eb 100644 --- a/mlir/lib/IR/AffineMap.cpp +++ b/mlir/lib/IR/AffineMap.cpp @@ -1,19 +1,10 @@ //===- AffineMap.cpp - MLIR Affine Map Classes ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/AffineMap.h" #include "AffineMapDetail.h" diff --git a/mlir/lib/IR/AffineMapDetail.h b/mlir/lib/IR/AffineMapDetail.h index a247783540c..f00c4ba216e 100644 --- a/mlir/lib/IR/AffineMapDetail.h +++ b/mlir/lib/IR/AffineMapDetail.h @@ -1,19 +1,10 @@ //===- AffineMapDetail.h - MLIR Affine Map details Class --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This holds implementation details of AffineMap. // diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 177d8a5ef05..a574f87c530 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -1,19 +1,10 @@ //===- AsmPrinter.cpp - MLIR Assembly Printer Implementation --------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the MLIR AsmPrinter class, which is used to implement // the various print() methods on the core IR objects. diff --git a/mlir/lib/IR/AttributeDetail.h b/mlir/lib/IR/AttributeDetail.h index da4aa69dda4..c78d49c0f87 100644 --- a/mlir/lib/IR/AttributeDetail.h +++ b/mlir/lib/IR/AttributeDetail.h @@ -1,19 +1,10 @@ //===- AttributeDetail.h - MLIR Affine Map details Class --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This holds implementation details of Attribute. // diff --git a/mlir/lib/IR/Attributes.cpp b/mlir/lib/IR/Attributes.cpp index bb35a63bf5d..3a9c91f6f77 100644 --- a/mlir/lib/IR/Attributes.cpp +++ b/mlir/lib/IR/Attributes.cpp @@ -1,19 +1,10 @@ //===- Attributes.cpp - MLIR Affine Expr Classes --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Attributes.h" #include "AttributeDetail.h" diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp index 894f9ba38d0..b168a8facd2 100644 --- a/mlir/lib/IR/Block.cpp +++ b/mlir/lib/IR/Block.cpp @@ -1,19 +1,10 @@ //===- Block.cpp - MLIR Block Class ---------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Block.h" #include "mlir/IR/Builders.h" diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp index 733fcd13994..2ef10b6e669 100644 --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -1,19 +1,10 @@ //===- Builders.cpp - Helpers for constructing MLIR Classes ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Builders.h" #include "mlir/IR/AffineExpr.h" diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp index 59e16a48865..6ec92f05370 100644 --- a/mlir/lib/IR/Diagnostics.cpp +++ b/mlir/lib/IR/Diagnostics.cpp @@ -1,19 +1,10 @@ //===- Diagnostics.cpp - MLIR Diagnostics ---------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Diagnostics.h" #include "mlir/IR/Attributes.h" diff --git a/mlir/lib/IR/Dialect.cpp b/mlir/lib/IR/Dialect.cpp index c6266b09668..b2485a368fd 100644 --- a/mlir/lib/IR/Dialect.cpp +++ b/mlir/lib/IR/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Dialect implementation -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Dialect.h" #include "mlir/IR/Diagnostics.h" diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp index b51c77f34c2..72b5ac46a8f 100644 --- a/mlir/lib/IR/Function.cpp +++ b/mlir/lib/IR/Function.cpp @@ -1,19 +1,10 @@ //===- Function.cpp - MLIR Function Classes -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Function.h" #include "mlir/IR/BlockAndValueMapping.h" diff --git a/mlir/lib/IR/FunctionImplementation.cpp b/mlir/lib/IR/FunctionImplementation.cpp index 9cec216468d..79863bc74f4 100644 --- a/mlir/lib/IR/FunctionImplementation.cpp +++ b/mlir/lib/IR/FunctionImplementation.cpp @@ -1,19 +1,10 @@ //===- FunctionImplementation.cpp - Utilities for function-like ops -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/Builders.h" diff --git a/mlir/lib/IR/IntegerSet.cpp b/mlir/lib/IR/IntegerSet.cpp index ce50fa7cc5b..835b4c3a7e2 100644 --- a/mlir/lib/IR/IntegerSet.cpp +++ b/mlir/lib/IR/IntegerSet.cpp @@ -1,19 +1,10 @@ //===- IntegerSet.cpp - MLIR Integer Set class ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/IntegerSet.h" #include "IntegerSetDetail.h" diff --git a/mlir/lib/IR/IntegerSetDetail.h b/mlir/lib/IR/IntegerSetDetail.h index b3eda5205fb..54ffd47bd47 100644 --- a/mlir/lib/IR/IntegerSetDetail.h +++ b/mlir/lib/IR/IntegerSetDetail.h @@ -1,19 +1,10 @@ //===- IntegerSetDetail.h - MLIR IntegerSet storage details -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This holds implementation details of IntegerSet. // diff --git a/mlir/lib/IR/Location.cpp b/mlir/lib/IR/Location.cpp index 1ea75d5e30e..e23a73647a4 100644 --- a/mlir/lib/IR/Location.cpp +++ b/mlir/lib/IR/Location.cpp @@ -1,19 +1,10 @@ //===- Location.cpp - MLIR Location Classes -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Location.h" #include "LocationDetail.h" diff --git a/mlir/lib/IR/LocationDetail.h b/mlir/lib/IR/LocationDetail.h index 6ccaa17018c..a47a2111c4f 100644 --- a/mlir/lib/IR/LocationDetail.h +++ b/mlir/lib/IR/LocationDetail.h @@ -1,19 +1,10 @@ //===- LocationDetail.h - MLIR Location storage details ---------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This holds implementation details of the location attributes. // diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp index d3feca14477..42d77ae2a3d 100644 --- a/mlir/lib/IR/MLIRContext.cpp +++ b/mlir/lib/IR/MLIRContext.cpp @@ -1,19 +1,10 @@ //===- MLIRContext.cpp - MLIR Type Classes --------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/MLIRContext.h" #include "AffineExprDetail.h" diff --git a/mlir/lib/IR/Module.cpp b/mlir/lib/IR/Module.cpp index c52a55b20fe..c5af227459c 100644 --- a/mlir/lib/IR/Module.cpp +++ b/mlir/lib/IR/Module.cpp @@ -1,19 +1,10 @@ //===- Module.cpp - MLIR Module Operation ---------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Module.h" #include "mlir/IR/Builders.h" diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp index 53399ce00a3..1dc7cb4bafd 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -1,19 +1,10 @@ //===- Operation.cpp - Operation support code -----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Operation.h" #include "mlir/IR/BlockAndValueMapping.h" diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp index 333685a16fd..1c68686a0cb 100644 --- a/mlir/lib/IR/OperationSupport.cpp +++ b/mlir/lib/IR/OperationSupport.cpp @@ -1,19 +1,10 @@ //===- OperationSupport.cpp -----------------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains out-of-line implementations of the support types that // Operation and related classes build on top of. diff --git a/mlir/lib/IR/PatternMatch.cpp b/mlir/lib/IR/PatternMatch.cpp index 3887a0308b0..d5749fabc07 100644 --- a/mlir/lib/IR/PatternMatch.cpp +++ b/mlir/lib/IR/PatternMatch.cpp @@ -1,19 +1,10 @@ //===- PatternMatch.cpp - Base classes for pattern match ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/PatternMatch.h" #include "mlir/IR/BlockAndValueMapping.h" diff --git a/mlir/lib/IR/Region.cpp b/mlir/lib/IR/Region.cpp index 26f14c43424..935854a5365 100644 --- a/mlir/lib/IR/Region.cpp +++ b/mlir/lib/IR/Region.cpp @@ -1,19 +1,10 @@ //===- Region.cpp - MLIR Region Class -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Region.h" #include "mlir/IR/BlockAndValueMapping.h" diff --git a/mlir/lib/IR/StandardTypes.cpp b/mlir/lib/IR/StandardTypes.cpp index 7c494e219e8..441b59ed9cd 100644 --- a/mlir/lib/IR/StandardTypes.cpp +++ b/mlir/lib/IR/StandardTypes.cpp @@ -1,19 +1,10 @@ //===- StandardTypes.cpp - MLIR Standard Type Classes ---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/StandardTypes.h" #include "TypeDetail.h" diff --git a/mlir/lib/IR/SymbolTable.cpp b/mlir/lib/IR/SymbolTable.cpp index bd8cb59cea7..83e5802093c 100644 --- a/mlir/lib/IR/SymbolTable.cpp +++ b/mlir/lib/IR/SymbolTable.cpp @@ -1,19 +1,10 @@ //===- SymbolTable.cpp - MLIR Symbol Table Class --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/SymbolTable.h" #include "llvm/ADT/SmallString.h" diff --git a/mlir/lib/IR/TypeDetail.h b/mlir/lib/IR/TypeDetail.h index 5bcb0b61aa5..b3e0edd3a57 100644 --- a/mlir/lib/IR/TypeDetail.h +++ b/mlir/lib/IR/TypeDetail.h @@ -1,19 +1,10 @@ //===- TypeDetail.h - MLIR Type storage details -----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This holds implementation details of Type. // diff --git a/mlir/lib/IR/TypeUtilities.cpp b/mlir/lib/IR/TypeUtilities.cpp index 8200e3a3bc6..8bc67e46fdc 100644 --- a/mlir/lib/IR/TypeUtilities.cpp +++ b/mlir/lib/IR/TypeUtilities.cpp @@ -1,19 +1,10 @@ //===- TypeUtilities.cpp - Helper function for type queries ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines generic type utilities. // diff --git a/mlir/lib/IR/Types.cpp b/mlir/lib/IR/Types.cpp index 23c80c96aad..923d6e16f57 100644 --- a/mlir/lib/IR/Types.cpp +++ b/mlir/lib/IR/Types.cpp @@ -1,19 +1,10 @@ //===- Types.cpp - MLIR Type Classes --------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Types.h" #include "TypeDetail.h" diff --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp index 660d8ae3248..d723eec8b29 100644 --- a/mlir/lib/IR/Value.cpp +++ b/mlir/lib/IR/Value.cpp @@ -1,19 +1,10 @@ //===- Value.cpp - MLIR Value Classes -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Value.h" #include "mlir/IR/Block.h" diff --git a/mlir/lib/IR/Visitors.cpp b/mlir/lib/IR/Visitors.cpp index ea2a6d69418..404e74a82c9 100644 --- a/mlir/lib/IR/Visitors.cpp +++ b/mlir/lib/IR/Visitors.cpp @@ -1,19 +1,10 @@ //===- Visitors.cpp - MLIR Visitor Utilties -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Visitors.h" #include "mlir/IR/Operation.h" diff --git a/mlir/lib/Parser/Lexer.cpp b/mlir/lib/Parser/Lexer.cpp index 29104c82e23..7d8337a9cb3 100644 --- a/mlir/lib/Parser/Lexer.cpp +++ b/mlir/lib/Parser/Lexer.cpp @@ -1,19 +1,10 @@ //===- Lexer.cpp - MLIR Lexer Implementation ------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the lexer for the MLIR textual form. // diff --git a/mlir/lib/Parser/Lexer.h b/mlir/lib/Parser/Lexer.h index a7a2ac4214c..a760dca9396 100644 --- a/mlir/lib/Parser/Lexer.h +++ b/mlir/lib/Parser/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - MLIR Lexer Interface ---------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the MLIR Lexer class. // diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index f78704842fe..e25f4d19654 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -1,19 +1,10 @@ //===- Parser.cpp - MLIR Parser Implementation ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the MLIR textual form. // diff --git a/mlir/lib/Parser/Token.cpp b/mlir/lib/Parser/Token.cpp index c01d6032cbd..84de4c396f4 100644 --- a/mlir/lib/Parser/Token.cpp +++ b/mlir/lib/Parser/Token.cpp @@ -1,19 +1,10 @@ //===- Token.cpp - MLIR Token Implementation ------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the Token class for the MLIR textual form. // diff --git a/mlir/lib/Parser/Token.h b/mlir/lib/Parser/Token.h index 333c4d29aad..7487736fac7 100644 --- a/mlir/lib/Parser/Token.h +++ b/mlir/lib/Parser/Token.h @@ -1,19 +1,10 @@ //===- Token.h - MLIR Token Interface ---------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_LIB_PARSER_TOKEN_H #define MLIR_LIB_PARSER_TOKEN_H diff --git a/mlir/lib/Parser/TokenKinds.def b/mlir/lib/Parser/TokenKinds.def index 19cd343274d..fc9f7821f1a 100644 --- a/mlir/lib/Parser/TokenKinds.def +++ b/mlir/lib/Parser/TokenKinds.def @@ -1,19 +1,10 @@ //===- TokenKinds.def - MLIR Token Description ------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file is intended to be #include'd multiple times to extract information // about tokens for various clients in the lexer. diff --git a/mlir/lib/Pass/IRPrinting.cpp b/mlir/lib/Pass/IRPrinting.cpp index 9d1c1f0d391..132a0bec4b7 100644 --- a/mlir/lib/Pass/IRPrinting.cpp +++ b/mlir/lib/Pass/IRPrinting.cpp @@ -1,19 +1,10 @@ //===- IRPrinting.cpp -----------------------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "PassDetail.h" #include "mlir/IR/Module.h" diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp index f893c7babf9..22e58cc5b63 100644 --- a/mlir/lib/Pass/Pass.cpp +++ b/mlir/lib/Pass/Pass.cpp @@ -1,19 +1,10 @@ //===- Pass.cpp - Pass infrastructure implementation ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements common pass infrastructure. // diff --git a/mlir/lib/Pass/PassDetail.h b/mlir/lib/Pass/PassDetail.h index d0a2ea63e7d..9a52535bedf 100644 --- a/mlir/lib/Pass/PassDetail.h +++ b/mlir/lib/Pass/PassDetail.h @@ -1,19 +1,10 @@ //===- PassDetail.h - MLIR Pass details -------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_PASS_PASSDETAIL_H_ #define MLIR_PASS_PASSDETAIL_H_ diff --git a/mlir/lib/Pass/PassManagerOptions.cpp b/mlir/lib/Pass/PassManagerOptions.cpp index c29e0d08869..87487069d97 100644 --- a/mlir/lib/Pass/PassManagerOptions.cpp +++ b/mlir/lib/Pass/PassManagerOptions.cpp @@ -1,19 +1,10 @@ //===- PassManagerOptions.cpp - PassManager Command Line Options ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" diff --git a/mlir/lib/Pass/PassRegistry.cpp b/mlir/lib/Pass/PassRegistry.cpp index 1a321d666c4..93753d363db 100644 --- a/mlir/lib/Pass/PassRegistry.cpp +++ b/mlir/lib/Pass/PassRegistry.cpp @@ -1,19 +1,10 @@ //===- PassRegistry.cpp - Pass Registration Utilities ---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Pass/PassRegistry.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/lib/Pass/PassStatistics.cpp b/mlir/lib/Pass/PassStatistics.cpp index 530697421ef..0ab656c2054 100644 --- a/mlir/lib/Pass/PassStatistics.cpp +++ b/mlir/lib/Pass/PassStatistics.cpp @@ -1,19 +1,10 @@ //===- PassStatistics.cpp -------------------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "PassDetail.h" #include "mlir/Pass/PassManager.h" diff --git a/mlir/lib/Pass/PassTiming.cpp b/mlir/lib/Pass/PassTiming.cpp index 113b65a09b5..93e640e7890 100644 --- a/mlir/lib/Pass/PassTiming.cpp +++ b/mlir/lib/Pass/PassTiming.cpp @@ -1,19 +1,10 @@ //===- PassTiming.cpp -----------------------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "PassDetail.h" #include "mlir/Pass/PassManager.h" diff --git a/mlir/lib/Quantizer/Configurations/FxpMathConfig.cpp b/mlir/lib/Quantizer/Configurations/FxpMathConfig.cpp index 94e364238c5..ba9c078a765 100644 --- a/mlir/lib/Quantizer/Configurations/FxpMathConfig.cpp +++ b/mlir/lib/Quantizer/Configurations/FxpMathConfig.cpp @@ -1,19 +1,10 @@ //===- FxpMathConfig.cpp - Reference fixed point config -------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a TargetConfiguration for reference fixed-point math // quantization scheme based on the FxpMathOps (plus a small category of diff --git a/mlir/lib/Quantizer/Support/Configuration.cpp b/mlir/lib/Quantizer/Support/Configuration.cpp index 78a74514f8b..f64cc85f0f7 100644 --- a/mlir/lib/Quantizer/Support/Configuration.cpp +++ b/mlir/lib/Quantizer/Support/Configuration.cpp @@ -1,19 +1,10 @@ //===- Configuration.cpp - Configuration object base classes --------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/Configuration.h" diff --git a/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp b/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp index 13fed0f9b1c..38aa5dc811b 100644 --- a/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp +++ b/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp @@ -1,19 +1,10 @@ //===- ConstraintAnalysisGraph.cpp - Graphs type for constraints ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/ConstraintAnalysisGraph.h" diff --git a/mlir/lib/Quantizer/Support/Metadata.cpp b/mlir/lib/Quantizer/Support/Metadata.cpp index 89478c4209d..b7badfd5f87 100644 --- a/mlir/lib/Quantizer/Support/Metadata.cpp +++ b/mlir/lib/Quantizer/Support/Metadata.cpp @@ -1,19 +1,10 @@ //===- Metadata.cpp - Top level types and metadata ------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/Metadata.h" diff --git a/mlir/lib/Quantizer/Support/Statistics.cpp b/mlir/lib/Quantizer/Support/Statistics.cpp index 6753898dbdc..3c8b041e244 100644 --- a/mlir/lib/Quantizer/Support/Statistics.cpp +++ b/mlir/lib/Quantizer/Support/Statistics.cpp @@ -1,19 +1,10 @@ //===- Statistics.cpp - Collects statistics over tensors ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/Statistics.h" diff --git a/mlir/lib/Quantizer/Support/TypeUtils.cpp b/mlir/lib/Quantizer/Support/TypeUtils.cpp index fab4e565308..a1f52c585a1 100644 --- a/mlir/lib/Quantizer/Support/TypeUtils.cpp +++ b/mlir/lib/Quantizer/Support/TypeUtils.cpp @@ -1,19 +1,10 @@ //===- TypeUtils.cpp - Helper function for manipulating types -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/TypeUtils.h" diff --git a/mlir/lib/Quantizer/Support/UniformConstraints.cpp b/mlir/lib/Quantizer/Support/UniformConstraints.cpp index 1a800dad4ac..b20213568a1 100644 --- a/mlir/lib/Quantizer/Support/UniformConstraints.cpp +++ b/mlir/lib/Quantizer/Support/UniformConstraints.cpp @@ -1,19 +1,10 @@ //===- UniformConstraints.cpp - Constraints for uniform quant -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/UniformConstraints.h" diff --git a/mlir/lib/Quantizer/Support/UniformSolvers.cpp b/mlir/lib/Quantizer/Support/UniformSolvers.cpp index 77d69be8382..2f6bb20792f 100644 --- a/mlir/lib/Quantizer/Support/UniformSolvers.cpp +++ b/mlir/lib/Quantizer/Support/UniformSolvers.cpp @@ -1,19 +1,10 @@ //===- UniformSolvers.cpp - Uniform type solver algorithms ----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/UniformSolvers.h" #include "mlir/Support/LLVM.h" diff --git a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp index a3cbe214040..a27f09bf942 100644 --- a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp +++ b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp @@ -1,19 +1,10 @@ //===- AddDefaultStatsTestPass.cpp - Testing pass to add default stats ----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a testing pass to add default statistics nodes to every // quantization eligible op. Useful for unit testing. diff --git a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp index 68c263bc423..c8569c2fe19 100644 --- a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp +++ b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp @@ -1,19 +1,10 @@ //===- InferQuantizedTypesPass.cpp - Infers quantized types ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the primary pass for instantiating a CAG, running it to // convergence on a module to determine eligible quantized type transforms, and diff --git a/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp b/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp index 0266520bec3..da5bd12ea1c 100644 --- a/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp +++ b/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp @@ -1,19 +1,10 @@ //===- RemoveInstrumentationPass.cpp - Removes instrumentation ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a pass to remove any instrumentation ops. It is often one // of the final steps when performing quantization and is run after any diff --git a/mlir/lib/Support/FileUtilities.cpp b/mlir/lib/Support/FileUtilities.cpp index 6f0dc93b235..a56ae57ba25 100644 --- a/mlir/lib/Support/FileUtilities.cpp +++ b/mlir/lib/Support/FileUtilities.cpp @@ -1,19 +1,10 @@ //===- FileUtilities.cpp - utilities for working with files ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Definitions of common utilities for working with files. // diff --git a/mlir/lib/Support/JitRunner.cpp b/mlir/lib/Support/JitRunner.cpp index dcd23437401..b327d3d4756 100644 --- a/mlir/lib/Support/JitRunner.cpp +++ b/mlir/lib/Support/JitRunner.cpp @@ -1,19 +1,10 @@ //===- jit-runner.cpp - MLIR CPU Execution Driver Library -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is a library that provides a shared implementation for command line // utilities that execute an MLIR file on the CPU by translating MLIR to LLVM diff --git a/mlir/lib/Support/MlirOptMain.cpp b/mlir/lib/Support/MlirOptMain.cpp index c256e970c95..4a76801211c 100644 --- a/mlir/lib/Support/MlirOptMain.cpp +++ b/mlir/lib/Support/MlirOptMain.cpp @@ -1,19 +1,10 @@ //===- MlirOptMain.cpp - MLIR Optimizer Driver ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is a utility that runs an optimization pass and prints the result back // out. It is designed to support unit testing. diff --git a/mlir/lib/Support/StorageUniquer.cpp b/mlir/lib/Support/StorageUniquer.cpp index cae4dce143f..d6f6bac4236 100644 --- a/mlir/lib/Support/StorageUniquer.cpp +++ b/mlir/lib/Support/StorageUniquer.cpp @@ -1,19 +1,10 @@ //===- StorageUniquer.cpp - Common Storage Class Uniquer ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Support/StorageUniquer.h" diff --git a/mlir/lib/Support/ToolUtilities.cpp b/mlir/lib/Support/ToolUtilities.cpp index 60d0eee6b8a..cd2df7809b7 100644 --- a/mlir/lib/Support/ToolUtilities.cpp +++ b/mlir/lib/Support/ToolUtilities.cpp @@ -1,19 +1,10 @@ //===- ToolUtilities.cpp - MLIR Tool Utilities ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines common utilities for implementing MLIR tools. // diff --git a/mlir/lib/Support/TranslateClParser.cpp b/mlir/lib/Support/TranslateClParser.cpp index 115c0c03f50..1f538cb531d 100644 --- a/mlir/lib/Support/TranslateClParser.cpp +++ b/mlir/lib/Support/TranslateClParser.cpp @@ -1,19 +1,10 @@ //===- TranslateClParser.h - Translations command line parser -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains custom command line parser for translations. // diff --git a/mlir/lib/TableGen/Argument.cpp b/mlir/lib/TableGen/Argument.cpp index 17dba054e4f..080e717092e 100644 --- a/mlir/lib/TableGen/Argument.cpp +++ b/mlir/lib/TableGen/Argument.cpp @@ -1,19 +1,10 @@ //===- Argument.cpp - Argument definitions --------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/TableGen/Argument.h" #include "llvm/TableGen/Record.h" diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index ec946a855fc..92f5b1f7d9f 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -1,19 +1,10 @@ //===- Attribute.cpp - Attribute wrapper class ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Attribute wrapper to simplify using TableGen Record defining a MLIR // Attribute. diff --git a/mlir/lib/TableGen/Constraint.cpp b/mlir/lib/TableGen/Constraint.cpp index ef3fa5271fa..022c5ad04df 100644 --- a/mlir/lib/TableGen/Constraint.cpp +++ b/mlir/lib/TableGen/Constraint.cpp @@ -1,19 +1,10 @@ //===- Constraint.cpp - Constraint class ----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Constraint wrapper to simplify using TableGen Record for constraints. // diff --git a/mlir/lib/TableGen/Dialect.cpp b/mlir/lib/TableGen/Dialect.cpp index ace4ce3d0f6..d9e8e2f7154 100644 --- a/mlir/lib/TableGen/Dialect.cpp +++ b/mlir/lib/TableGen/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Dialect wrapper class --------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Dialect wrapper to simplify using TableGen Record defining a MLIR dialect. // diff --git a/mlir/lib/TableGen/Format.cpp b/mlir/lib/TableGen/Format.cpp index 967d51a61f7..07742ab6a40 100644 --- a/mlir/lib/TableGen/Format.cpp +++ b/mlir/lib/TableGen/Format.cpp @@ -1,19 +1,10 @@ //===- Format.cpp - Utilities for String Format ---------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines utilities for formatting strings. They are specially // tailored to the needs of TableGen'ing op definitions and rewrite rules, diff --git a/mlir/lib/TableGen/OpInterfaces.cpp b/mlir/lib/TableGen/OpInterfaces.cpp index 1687f3ac795..b1e56efc029 100644 --- a/mlir/lib/TableGen/OpInterfaces.cpp +++ b/mlir/lib/TableGen/OpInterfaces.cpp @@ -1,19 +1,10 @@ //===- OpInterfaces.cpp - OpInterfaces class ------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // OpInterfaces wrapper to simplify using TableGen OpInterfaces. // diff --git a/mlir/lib/TableGen/OpTrait.cpp b/mlir/lib/TableGen/OpTrait.cpp index 0e436a87497..86e34cd46b5 100644 --- a/mlir/lib/TableGen/OpTrait.cpp +++ b/mlir/lib/TableGen/OpTrait.cpp @@ -1,19 +1,10 @@ //===- OpTrait.cpp - OpTrait class ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // OpTrait wrapper to simplify using TableGen Record defining a MLIR OpTrait. // diff --git a/mlir/lib/TableGen/Operator.cpp b/mlir/lib/TableGen/Operator.cpp index 3825363bec0..d61eec4ad44 100644 --- a/mlir/lib/TableGen/Operator.cpp +++ b/mlir/lib/TableGen/Operator.cpp @@ -1,19 +1,10 @@ //===- Operator.cpp - Operator class --------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Operator wrapper to simplify using TableGen Record defining a MLIR Op. // diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp index e8f44087b85..1045b784ae2 100644 --- a/mlir/lib/TableGen/Pattern.cpp +++ b/mlir/lib/TableGen/Pattern.cpp @@ -1,19 +1,10 @@ //===- Pattern.cpp - Pattern wrapper class --------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Pattern wrapper class to simplify using TableGen Record defining a MLIR // Pattern. diff --git a/mlir/lib/TableGen/Predicate.cpp b/mlir/lib/TableGen/Predicate.cpp index f8f23e04c3f..c52e15dbdea 100644 --- a/mlir/lib/TableGen/Predicate.cpp +++ b/mlir/lib/TableGen/Predicate.cpp @@ -1,19 +1,10 @@ //===- Predicate.cpp - Predicate class ------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Wrapper around predicates defined in TableGen. // diff --git a/mlir/lib/TableGen/Type.cpp b/mlir/lib/TableGen/Type.cpp index a558be4c89d..9a309bdde46 100644 --- a/mlir/lib/TableGen/Type.cpp +++ b/mlir/lib/TableGen/Type.cpp @@ -1,19 +1,10 @@ //===- Type.cpp - Type class ----------------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Type wrapper to simplify using TableGen Record defining a MLIR Type. // diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp index 7273d3dfd7b..6f3e2ef21aa 100644 --- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp @@ -1,19 +1,10 @@ //===- ConvertFromLLVMIR.cpp - MLIR to LLVM IR conversion -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a translation between LLVM IR and the MLIR LLVM dialect. // diff --git a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp index e69dce7b59b..4cc59974960 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp @@ -1,19 +1,10 @@ //===- ConvertToLLVMIR.cpp - MLIR to LLVM IR conversion -------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a translation between the MLIR LLVM dialect and LLVM IR. // diff --git a/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp index 8baed9854f1..a5992174df3 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp @@ -1,19 +1,10 @@ //===- ConvertToNVVMIR.cpp - MLIR to LLVM IR conversion -------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a translation between the MLIR LLVM + NVVM dialects and // LLVM IR with NVVM intrinsics and metadata. diff --git a/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp index f119b138e13..881d165e0c8 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp @@ -1,19 +1,10 @@ //===- ConvertToROCDLIR.cpp - MLIR to LLVM IR conversion ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a translation between the MLIR LLVM + ROCDL dialects and // LLVM IR with ROCDL intrinsics and metadata. diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index ec28434b823..e8376364c41 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -1,19 +1,10 @@ //===- ModuleTranslation.cpp - MLIR to LLVM conversion --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the translation between an MLIR LLVM dialect module and // the corresponding LLVMIR module. It only handles core LLVM IR operations. diff --git a/mlir/lib/Transforms/AffineDataCopyGeneration.cpp b/mlir/lib/Transforms/AffineDataCopyGeneration.cpp index 5bc33943e50..1e1b8775d32 100644 --- a/mlir/lib/Transforms/AffineDataCopyGeneration.cpp +++ b/mlir/lib/Transforms/AffineDataCopyGeneration.cpp @@ -1,19 +1,10 @@ //===- AffineDataCopyGeneration.cpp - Explicit memref copying pass ------*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to automatically promote accessed memref regions // to buffers in a faster memory space that is explicitly managed, with the diff --git a/mlir/lib/Transforms/AffineLoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/AffineLoopInvariantCodeMotion.cpp index 23199dd8a39..1f33c0f5dca 100644 --- a/mlir/lib/Transforms/AffineLoopInvariantCodeMotion.cpp +++ b/mlir/lib/Transforms/AffineLoopInvariantCodeMotion.cpp @@ -1,19 +1,10 @@ //===- AffineLoopInvariantCodeMotion.cpp - Code to perform loop fusion-----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements loop invariant code motion. // diff --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp index 18f9fce5e46..714fb1d0109 100644 --- a/mlir/lib/Transforms/CSE.cpp +++ b/mlir/lib/Transforms/CSE.cpp @@ -1,19 +1,10 @@ //===- CSE.cpp - Common Sub-expression Elimination ------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This transformation pass performs a simple common sub-expression elimination // algorithm on operations within a function. diff --git a/mlir/lib/Transforms/Canonicalizer.cpp b/mlir/lib/Transforms/Canonicalizer.cpp index 7dcdeb67cdc..5b3a1eb1cf3 100644 --- a/mlir/lib/Transforms/Canonicalizer.cpp +++ b/mlir/lib/Transforms/Canonicalizer.cpp @@ -1,19 +1,10 @@ //===- Canonicalizer.cpp - Canonicalize MLIR operations -------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This transformation pass converts operations into their canonical forms by // folding constants, applying operation identity transformations etc. diff --git a/mlir/lib/Transforms/DialectConversion.cpp b/mlir/lib/Transforms/DialectConversion.cpp index 05066ef599c..a19274acd1b 100644 --- a/mlir/lib/Transforms/DialectConversion.cpp +++ b/mlir/lib/Transforms/DialectConversion.cpp @@ -1,19 +1,10 @@ //===- DialectConversion.cpp - MLIR dialect conversion generic pass -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Transforms/DialectConversion.h" #include "mlir/IR/Block.h" diff --git a/mlir/lib/Transforms/Inliner.cpp b/mlir/lib/Transforms/Inliner.cpp index b158948069e..b2cee7da083 100644 --- a/mlir/lib/Transforms/Inliner.cpp +++ b/mlir/lib/Transforms/Inliner.cpp @@ -1,19 +1,10 @@ //===- Inliner.cpp - Pass to inline function calls ------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a basic inlining algorithm that operates bottom up over // the Strongly Connect Components(SCCs) of the CallGraph. This enables a more diff --git a/mlir/lib/Transforms/LoopCoalescing.cpp b/mlir/lib/Transforms/LoopCoalescing.cpp index c1eec56526e..2aee688c6c1 100644 --- a/mlir/lib/Transforms/LoopCoalescing.cpp +++ b/mlir/lib/Transforms/LoopCoalescing.cpp @@ -1,19 +1,10 @@ //===- LoopCoalescing.cpp - Pass transforming loop nests into single loops-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index 60f0264eb35..51e30ba7163 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -1,19 +1,10 @@ //===- LoopFusion.cpp - Code to perform loop fusion -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements loop fusion. // diff --git a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp index bd58827d001..93c80822fb3 100644 --- a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp +++ b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp @@ -1,19 +1,10 @@ //===- LoopInvariantCodeMotion.cpp - Code to perform loop fusion-----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements loop invariant code motion. // diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp index 361a4d8ecb9..5389c7e4429 100644 --- a/mlir/lib/Transforms/LoopTiling.cpp +++ b/mlir/lib/Transforms/LoopTiling.cpp @@ -1,19 +1,10 @@ //===- LoopTiling.cpp --- Loop tiling pass ------------------------------*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to tile loop nests. // diff --git a/mlir/lib/Transforms/LoopUnroll.cpp b/mlir/lib/Transforms/LoopUnroll.cpp index 40f48ada4d7..e94c6c8b0bb 100644 --- a/mlir/lib/Transforms/LoopUnroll.cpp +++ b/mlir/lib/Transforms/LoopUnroll.cpp @@ -1,19 +1,10 @@ //===- LoopUnroll.cpp - Code to perform loop unrolling --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements loop unrolling. // diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp index a857b8ec95a..3cefcaacadc 100644 --- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp +++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp @@ -1,19 +1,10 @@ //===- LoopUnrollAndJam.cpp - Code to perform loop unroll and jam ---------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements loop unroll and jam. Unroll and jam is a transformation // that improves locality, in particular, register reuse, while also improving diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp index 0695aafe171..957f41a9d3e 100644 --- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp +++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp @@ -1,19 +1,10 @@ //===- MemRefDataFlowOpt.cpp - MemRef DataFlow Optimization pass ------ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to forward memref stores to loads, thereby // potentially getting rid of intermediate memref's entirely. diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp index 4162936ea2d..12ce6c66abd 100644 --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -1,19 +1,10 @@ //===- PipelineDataTransfer.cpp --- Pass for pipelining data movement ---*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to pipeline data transfers. // diff --git a/mlir/lib/Transforms/SimplifyAffineStructures.cpp b/mlir/lib/Transforms/SimplifyAffineStructures.cpp index 9512ff738aa..217e06bc877 100644 --- a/mlir/lib/Transforms/SimplifyAffineStructures.cpp +++ b/mlir/lib/Transforms/SimplifyAffineStructures.cpp @@ -1,19 +1,10 @@ //===- SimplifyAffineStructures.cpp ---------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to simplify affine structures. // diff --git a/mlir/lib/Transforms/StripDebugInfo.cpp b/mlir/lib/Transforms/StripDebugInfo.cpp index 772df3da3c7..cdfc7fd7e41 100644 --- a/mlir/lib/Transforms/StripDebugInfo.cpp +++ b/mlir/lib/Transforms/StripDebugInfo.cpp @@ -1,19 +1,10 @@ //===- StripDebugInfo.cpp - Pass to strip debug information ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Function.h" #include "mlir/IR/Operation.h" diff --git a/mlir/lib/Transforms/Utils/FoldUtils.cpp b/mlir/lib/Transforms/Utils/FoldUtils.cpp index 85d1f21305e..ce39625831a 100644 --- a/mlir/lib/Transforms/Utils/FoldUtils.cpp +++ b/mlir/lib/Transforms/Utils/FoldUtils.cpp @@ -1,19 +1,10 @@ //===- FoldUtils.cpp ---- Fold Utilities ----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines various operation fold utilities. These utilities are // intended to be used by passes to unify and simply their logic. diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp index fe4a6f9f9e0..3ab4e287bb2 100644 --- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp +++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp @@ -1,19 +1,10 @@ //===- GreedyPatternRewriteDriver.cpp - A greedy rewriter -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements mlir::applyPatternsGreedily. // diff --git a/mlir/lib/Transforms/Utils/InliningUtils.cpp b/mlir/lib/Transforms/Utils/InliningUtils.cpp index 048130c0d3a..e7b34bb3956 100644 --- a/mlir/lib/Transforms/Utils/InliningUtils.cpp +++ b/mlir/lib/Transforms/Utils/InliningUtils.cpp @@ -1,19 +1,10 @@ //===- InliningUtils.cpp ---- Misc utilities for inlining -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements miscellaneous inlining utilities. // diff --git a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp index d5cda3265de..4745a26e168 100644 --- a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp @@ -1,19 +1,10 @@ //===- LoopFusionUtils.cpp ---- Utilities for loop fusion ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements loop fusion transformation utility functions. // diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index bc1ced408a9..3d4db22c866 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -1,19 +1,10 @@ //===- LoopUtils.cpp ---- Misc utilities for loop transformation ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements miscellaneous loop transformation routines. // diff --git a/mlir/lib/Transforms/Utils/RegionUtils.cpp b/mlir/lib/Transforms/Utils/RegionUtils.cpp index 749d5bf1dd0..569c5416edd 100644 --- a/mlir/lib/Transforms/Utils/RegionUtils.cpp +++ b/mlir/lib/Transforms/Utils/RegionUtils.cpp @@ -1,19 +1,10 @@ //===- RegionUtils.cpp - Region-related transformation utilities ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Transforms/RegionUtils.h" #include "mlir/IR/Block.h" diff --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp index 96a6cdc544f..409729a5f20 100644 --- a/mlir/lib/Transforms/Utils/Utils.cpp +++ b/mlir/lib/Transforms/Utils/Utils.cpp @@ -1,19 +1,10 @@ //===- Utils.cpp ---- Misc utilities for code and data transformation -----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements miscellaneous transformation routines for non-loop IR // structures. diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp index d8f5b1dc0e4..2dbac868cc0 100644 --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -1,19 +1,10 @@ //===- Vectorize.cpp - Vectorize Pass Impl --------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements vectorization of loops, operations and data types to // a target-independent, n-D super-vector abstraction. diff --git a/mlir/lib/Transforms/ViewOpGraph.cpp b/mlir/lib/Transforms/ViewOpGraph.cpp index 591562d0245..508c547a52b 100644 --- a/mlir/lib/Transforms/ViewOpGraph.cpp +++ b/mlir/lib/Transforms/ViewOpGraph.cpp @@ -1,19 +1,10 @@ //===- ViewOpGraph.cpp - View/write op graphviz graphs --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Transforms/ViewOpGraph.h" #include "mlir/IR/Block.h" diff --git a/mlir/lib/Transforms/ViewRegionGraph.cpp b/mlir/lib/Transforms/ViewRegionGraph.cpp index db55415d62e..77111087d07 100644 --- a/mlir/lib/Transforms/ViewRegionGraph.cpp +++ b/mlir/lib/Transforms/ViewRegionGraph.cpp @@ -1,19 +1,10 @@ //===- ViewRegionGraph.cpp - View/write graphviz graphs -------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Transforms/ViewRegionGraph.h" #include "mlir/IR/RegionGraphTraits.h" diff --git a/mlir/lib/Translation/Translation.cpp b/mlir/lib/Translation/Translation.cpp index 8b5f98714e4..80c1e483731 100644 --- a/mlir/lib/Translation/Translation.cpp +++ b/mlir/lib/Translation/Translation.cpp @@ -1,19 +1,10 @@ //===- Translation.cpp - Translation registry -----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Definitions of the translation registry. // diff --git a/mlir/test/APITest.h b/mlir/test/APITest.h index 9475bae2b58..08d64a0e48d 100644 --- a/mlir/test/APITest.h +++ b/mlir/test/APITest.h @@ -1,19 +1,10 @@ //===- Test.h - Simple macros for API unit tests ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file define simple macros for declaring test functions and running them. // The actual checking must be performed on the outputs with FileCheck. diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp index 376fc249a18..cfe703281e2 100644 --- a/mlir/test/EDSC/builder-api-test.cpp +++ b/mlir/test/EDSC/builder-api-test.cpp @@ -1,19 +1,10 @@ //===- builder-api-test.cpp - Tests for Declarative Builder APIs ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // RUN: mlir-edsc-builder-api-test | FileCheck %s diff --git a/mlir/test/SDBM/sdbm-api-test.cpp b/mlir/test/SDBM/sdbm-api-test.cpp index 12aff301d88..a672290d01d 100644 --- a/mlir/test/SDBM/sdbm-api-test.cpp +++ b/mlir/test/SDBM/sdbm-api-test.cpp @@ -1,19 +1,10 @@ //===- sdbm-api-test.cpp - Tests for SDBM expression APIs -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // RUN: mlir-sdbm-api-test | FileCheck %s diff --git a/mlir/test/lib/DeclarativeTransforms/TestLinalgTransformPatterns.td b/mlir/test/lib/DeclarativeTransforms/TestLinalgTransformPatterns.td index d2313927398..d07f6060c3b 100644 --- a/mlir/test/lib/DeclarativeTransforms/TestLinalgTransformPatterns.td +++ b/mlir/test/lib/DeclarativeTransforms/TestLinalgTransformPatterns.td @@ -1,19 +1,10 @@ //===- TestLinalgTransformPatterns.td - Test patterns --*- tablegen ----*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the pattern definition file for declarative Linalg transformations // tests. diff --git a/mlir/test/lib/DeclarativeTransforms/TestVectorTransformPatterns.td b/mlir/test/lib/DeclarativeTransforms/TestVectorTransformPatterns.td index 228a8a018d6..29875ccd543 100644 --- a/mlir/test/lib/DeclarativeTransforms/TestVectorTransformPatterns.td +++ b/mlir/test/lib/DeclarativeTransforms/TestVectorTransformPatterns.td @@ -1,19 +1,10 @@ //===- TestVectorTransformPatterns.td - Test patterns ---*- tablegen ----*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the pattern definition file for declarative Vector transformations // tests. diff --git a/mlir/test/lib/IR/TestFunc.cpp b/mlir/test/lib/IR/TestFunc.cpp index 880d0785bb5..3e131590fae 100644 --- a/mlir/test/lib/IR/TestFunc.cpp +++ b/mlir/test/lib/IR/TestFunc.cpp @@ -1,19 +1,10 @@ //===- TestFunctionLike.cpp - Pass to test helpers on FunctionLike --------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Function.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/test/lib/IR/TestMatchers.cpp b/mlir/test/lib/IR/TestMatchers.cpp index 5985a88ffa6..b62daa8437c 100644 --- a/mlir/test/lib/IR/TestMatchers.cpp +++ b/mlir/test/lib/IR/TestMatchers.cpp @@ -1,19 +1,10 @@ //===- TestMatchers.cpp - Pass to test matchers ---------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/StandardOps/Ops.h" #include "mlir/IR/Function.h" diff --git a/mlir/test/lib/IR/TestSymbolUses.cpp b/mlir/test/lib/IR/TestSymbolUses.cpp index 8ef4bb48a1c..c8fb1d8eecf 100644 --- a/mlir/test/lib/IR/TestSymbolUses.cpp +++ b/mlir/test/lib/IR/TestSymbolUses.cpp @@ -1,19 +1,10 @@ //===- TestSymbolUses.cpp - Pass to test symbol uselists ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "TestDialect.h" #include "mlir/IR/Function.h" diff --git a/mlir/test/lib/Pass/TestPassManager.cpp b/mlir/test/lib/Pass/TestPassManager.cpp index d1e1a6d13ee..2e811634880 100644 --- a/mlir/test/lib/Pass/TestPassManager.cpp +++ b/mlir/test/lib/Pass/TestPassManager.cpp @@ -1,19 +1,10 @@ //===- TestPassManager.cpp - Test pass manager functionality --------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Function.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/test/lib/TestDialect/TestDialect.cpp b/mlir/test/lib/TestDialect/TestDialect.cpp index 12d024f6593..976a1976f01 100644 --- a/mlir/test/lib/TestDialect/TestDialect.cpp +++ b/mlir/test/lib/TestDialect/TestDialect.cpp @@ -1,19 +1,10 @@ //===- TestDialect.cpp - MLIR Dialect for Testing -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "TestDialect.h" #include "mlir/IR/Function.h" diff --git a/mlir/test/lib/TestDialect/TestDialect.h b/mlir/test/lib/TestDialect/TestDialect.h index 783b8a1bcdd..20db0f39b81 100644 --- a/mlir/test/lib/TestDialect/TestDialect.h +++ b/mlir/test/lib/TestDialect/TestDialect.h @@ -1,19 +1,10 @@ //===- TestDialect.h - MLIR Dialect for testing -----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a fake 'test' dialect that can be used for testing things // that do not have a respective counterpart in the main source directories. diff --git a/mlir/test/lib/TestDialect/TestOps.td b/mlir/test/lib/TestDialect/TestOps.td index ea071f0ddf4..a8709ddca27 100644 --- a/mlir/test/lib/TestDialect/TestOps.td +++ b/mlir/test/lib/TestDialect/TestOps.td @@ -1,19 +1,10 @@ //===-- TestOps.td - Test dialect operation definitions ----*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef TEST_OPS #define TEST_OPS diff --git a/mlir/test/lib/TestDialect/TestPatterns.cpp b/mlir/test/lib/TestDialect/TestPatterns.cpp index 1f6224dba3a..b886097202d 100644 --- a/mlir/test/lib/TestDialect/TestPatterns.cpp +++ b/mlir/test/lib/TestDialect/TestPatterns.cpp @@ -1,19 +1,10 @@ //===- TestPatterns.cpp - Test dialect pattern driver ---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "TestDialect.h" #include "mlir/IR/PatternMatch.h" diff --git a/mlir/test/lib/Transforms/TestCallGraph.cpp b/mlir/test/lib/Transforms/TestCallGraph.cpp index debf5e77645..6378d953648 100644 --- a/mlir/test/lib/Transforms/TestCallGraph.cpp +++ b/mlir/test/lib/Transforms/TestCallGraph.cpp @@ -1,19 +1,10 @@ //===- TestCallGraph.cpp - Test callgraph construction and iteration ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains test passes for constructing and iterating over a // callgraph. diff --git a/mlir/test/lib/Transforms/TestConstantFold.cpp b/mlir/test/lib/Transforms/TestConstantFold.cpp index 5a0e9ed3f3c..f660bccca1d 100644 --- a/mlir/test/lib/Transforms/TestConstantFold.cpp +++ b/mlir/test/lib/Transforms/TestConstantFold.cpp @@ -1,19 +1,10 @@ //===- TestConstantFold.cpp - Pass to test constant folding ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/AffineOps/AffineOps.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/test/lib/Transforms/TestInlining.cpp b/mlir/test/lib/Transforms/TestInlining.cpp index 0571dc62b73..36378283f8e 100644 --- a/mlir/test/lib/Transforms/TestInlining.cpp +++ b/mlir/test/lib/Transforms/TestInlining.cpp @@ -1,19 +1,10 @@ //===- TestInlining.cpp - Pass to inline calls in the test dialect --------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // TODO(riverriddle) This pass is only necessary because the main inlining pass // has no abstracted away the call+callee relationship. When the inlining diff --git a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp index 37030ca2059..6ea995d3dfe 100644 --- a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp +++ b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp @@ -1,19 +1,10 @@ //===- TestLinalgTransforms.cpp - Test Linalg transformation patterns -----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements logic for testing Linalg transformations. // diff --git a/mlir/test/lib/Transforms/TestLiveness.cpp b/mlir/test/lib/Transforms/TestLiveness.cpp index d97060247f4..23725740df4 100644 --- a/mlir/test/lib/Transforms/TestLiveness.cpp +++ b/mlir/test/lib/Transforms/TestLiveness.cpp @@ -1,20 +1,11 @@ //===- TestLiveness.cpp - Test liveness construction and information //-------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains test passes for constructing and resolving liveness // information. diff --git a/mlir/test/lib/Transforms/TestLoopFusion.cpp b/mlir/test/lib/Transforms/TestLoopFusion.cpp index 7dc722f21f6..23e5035153e 100644 --- a/mlir/test/lib/Transforms/TestLoopFusion.cpp +++ b/mlir/test/lib/Transforms/TestLoopFusion.cpp @@ -1,19 +1,10 @@ //===- TestLoopFusion.cpp - Test loop fusion ------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to test various loop fusion utility functions. // diff --git a/mlir/test/lib/Transforms/TestLoopMapping.cpp b/mlir/test/lib/Transforms/TestLoopMapping.cpp index 7f587fc3170..5b1394d5996 100644 --- a/mlir/test/lib/Transforms/TestLoopMapping.cpp +++ b/mlir/test/lib/Transforms/TestLoopMapping.cpp @@ -1,19 +1,10 @@ //===- TestLoopMapping.cpp --- Parametric loop mapping pass ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to parametrically map loop.for loops to virtual // processing element dimensions. diff --git a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp index 9a8e1917e1f..7b0cdcade4d 100644 --- a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp +++ b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp @@ -1,19 +1,10 @@ //===- TestLoopParametricTiling.cpp --- Parametric loop tiling pass -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to parametrically tile nests of standard loops. // diff --git a/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp b/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp index 40788b259c5..d5e0b7df02b 100644 --- a/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp +++ b/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp @@ -1,19 +1,10 @@ //===- TestMemRefStrideCalculation.cpp - Pass to test strides computation--===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/StandardOps/Ops.h" #include "mlir/IR/StandardTypes.h" diff --git a/mlir/test/lib/Transforms/TestOpaqueLoc.cpp b/mlir/test/lib/Transforms/TestOpaqueLoc.cpp index 0db53322fb8..9a261c0bb3b 100644 --- a/mlir/test/lib/Transforms/TestOpaqueLoc.cpp +++ b/mlir/test/lib/Transforms/TestOpaqueLoc.cpp @@ -1,19 +1,10 @@ //===- TestOpaqueLoc.cpp - Pass to test opaque locations ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/StandardOps/Ops.h" #include "mlir/IR/Builders.h" diff --git a/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp b/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp index e5f5f749bd0..a31f8e474b4 100644 --- a/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp +++ b/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp @@ -1,19 +1,10 @@ //===- TestVectorToLoopsConversion.cpp - Test VectorTransfers lowering ----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include diff --git a/mlir/test/lib/Transforms/TestVectorTransforms.cpp b/mlir/test/lib/Transforms/TestVectorTransforms.cpp index 1d513065330..664d49ab4e5 100644 --- a/mlir/test/lib/Transforms/TestVectorTransforms.cpp +++ b/mlir/test/lib/Transforms/TestVectorTransforms.cpp @@ -1,19 +1,10 @@ //===- TestVectorToVectorConversion.cpp - Test VectorTransfers lowering ---===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include diff --git a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp index 35df0631ca7..e131f4803ef 100644 --- a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp +++ b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp @@ -1,19 +1,10 @@ //===- VectorizerTestPass.cpp - VectorizerTestPass Pass Impl --------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple testing pass for vectorization functionality. // diff --git a/mlir/test/mlir-cpu-runner/cblas.cpp b/mlir/test/mlir-cpu-runner/cblas.cpp index d219b7b1256..aebb8f212b4 100644 --- a/mlir/test/mlir-cpu-runner/cblas.cpp +++ b/mlir/test/mlir-cpu-runner/cblas.cpp @@ -1,19 +1,10 @@ //===- cblas.cpp - Simple Blas subset implementation ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Simple Blas subset implementation. // diff --git a/mlir/test/mlir-cpu-runner/cblas_interface.cpp b/mlir/test/mlir-cpu-runner/cblas_interface.cpp index 831702f594e..5e3a00e7fd1 100644 --- a/mlir/test/mlir-cpu-runner/cblas_interface.cpp +++ b/mlir/test/mlir-cpu-runner/cblas_interface.cpp @@ -1,19 +1,10 @@ //===- cblas_interface.cpp - Simple Blas subset interface -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Simple Blas subset interface implementation. // diff --git a/mlir/test/mlir-cpu-runner/include/cblas.h b/mlir/test/mlir-cpu-runner/include/cblas.h index 522ac8380b9..ccd316ff52e 100644 --- a/mlir/test/mlir-cpu-runner/include/cblas.h +++ b/mlir/test/mlir-cpu-runner/include/cblas.h @@ -1,19 +1,10 @@ //===- cblas.h - Simple Blas subset ---------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CPU_RUNNER_CBLAS_H_ #define MLIR_CPU_RUNNER_CBLAS_H_ diff --git a/mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h b/mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h index d4b6e1fedb0..1f4e638c33e 100644 --- a/mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h +++ b/mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h @@ -1,19 +1,10 @@ //===- mlir_runner_utils.h - Utils for debugging MLIR CPU execution -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CPU_RUNNER_MLIRUTILS_H_ #define MLIR_CPU_RUNNER_MLIRUTILS_H_ diff --git a/mlir/test/mlir-cpu-runner/mlir_runner_utils.cpp b/mlir/test/mlir-cpu-runner/mlir_runner_utils.cpp index 56829c629bb..fc3a782c080 100644 --- a/mlir/test/mlir-cpu-runner/mlir_runner_utils.cpp +++ b/mlir/test/mlir-cpu-runner/mlir_runner_utils.cpp @@ -1,19 +1,10 @@ //===- mlir_runner_utils.cpp - Utils for MLIR CPU execution ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Utilities for interfacing MLIR types with C code as well as printing, // debugging etc. diff --git a/mlir/tools/mlir-cpu-runner/mlir-cpu-runner.cpp b/mlir/tools/mlir-cpu-runner/mlir-cpu-runner.cpp index f7023c4cf61..144f73d9c97 100644 --- a/mlir/tools/mlir-cpu-runner/mlir-cpu-runner.cpp +++ b/mlir/tools/mlir-cpu-runner/mlir-cpu-runner.cpp @@ -1,19 +1,10 @@ //===- mlir-cpu-runner.cpp - MLIR CPU Execution Driver---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Main entry point to a command line utility that executes an MLIR file on the // CPU by translating MLIR to LLVM IR before JIT-compiling and executing the diff --git a/mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp b/mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp index 0698095afcf..9f1591b5a8c 100644 --- a/mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp +++ b/mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp @@ -1,19 +1,10 @@ //===- cuda-runtime-wrappers.cpp - MLIR CUDA runner wrapper library -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Implements C wrappers around the CUDA library for easy linking in ORC jit. // Also adds some debugging helpers that are helpful when writing MLIR code to diff --git a/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp b/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp index c1ca4ebd8e1..d6160d6d6e0 100644 --- a/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp +++ b/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp @@ -1,19 +1,10 @@ //===- mlir-cpu-runner.cpp - MLIR CPU Execution Driver---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is a command line utility that executes an MLIR file on the GPU by // translating MLIR to NVVM/LVVM IR before JIT-compiling and executing the diff --git a/mlir/tools/mlir-opt/mlir-opt.cpp b/mlir/tools/mlir-opt/mlir-opt.cpp index d01f66d4e0b..b0dd1b59ce7 100644 --- a/mlir/tools/mlir-opt/mlir-opt.cpp +++ b/mlir/tools/mlir-opt/mlir-opt.cpp @@ -1,19 +1,10 @@ //===- mlir-opt.cpp - MLIR Optimizer Driver -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Main entry function for mlir-opt for when built as standalone binary. // diff --git a/mlir/tools/mlir-tblgen/DocGenUtilities.h b/mlir/tools/mlir-tblgen/DocGenUtilities.h index b7617742727..1b3c8541aee 100644 --- a/mlir/tools/mlir-tblgen/DocGenUtilities.h +++ b/mlir/tools/mlir-tblgen/DocGenUtilities.h @@ -1,19 +1,10 @@ //===- DocGenUtilities.h - MLIR doc gen utilities ---------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines common utilities for generating documents from tablegen // structures. diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp index e278fdd80e8..610a380dab3 100644 --- a/mlir/tools/mlir-tblgen/EnumsGen.cpp +++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp @@ -1,19 +1,10 @@ //===- EnumsGen.cpp - MLIR enum utility generator -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // EnumsGen generates common utility functions for enums. // diff --git a/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp b/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp index f4b1279f11e..30f720e8d73 100644 --- a/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp +++ b/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp @@ -1,19 +1,10 @@ //===- LLVMIRConversionGen.cpp - MLIR LLVM IR builder generator -----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file uses tablegen definitions of the LLVM IR Dialect operations to // generate the code building the LLVM IR from it. diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index df8feb855c5..52cbc08c429 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -1,19 +1,10 @@ //===- OpDefinitionsGen.cpp - MLIR op definitions generator ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // OpDefinitionsGen uses the description of operations to generate C++ // definitions for ops. diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp index 8b048d9ea94..87a27238ce3 100644 --- a/mlir/tools/mlir-tblgen/OpDocGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp @@ -1,19 +1,10 @@ //===- OpDocGen.cpp - MLIR operation documentation generator --------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // OpDocGen uses the description of operations to generate documentation for the // operations. diff --git a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp index a48bd2509bc..a96736cd2c5 100644 --- a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp +++ b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp @@ -1,19 +1,10 @@ //===- OpInterfacesGen.cpp - MLIR op interface utility generator ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // OpInterfacesGen generates definitions for operation interfaces. // diff --git a/mlir/tools/mlir-tblgen/ReferenceImplGen.cpp b/mlir/tools/mlir-tblgen/ReferenceImplGen.cpp index 9181d0e90ed..90b60e5efed 100644 --- a/mlir/tools/mlir-tblgen/ReferenceImplGen.cpp +++ b/mlir/tools/mlir-tblgen/ReferenceImplGen.cpp @@ -1,19 +1,10 @@ //===- ReferenceImplGen.cpp - MLIR reference implementation generator -----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // ReferenceImplGen uses the description of operations to generate reference // implementations for the ops. diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index a74bc23a95a..8cfd454d629 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -1,19 +1,10 @@ //===- RewriterGen.cpp - MLIR pattern rewriter generator ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // RewriterGen uses pattern rewrite definitions to generate rewriter matchers. // diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp index 6d5bcc116ad..1aa7d5968d2 100644 --- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp +++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp @@ -1,19 +1,10 @@ //===- SPIRVSerializationGen.cpp - SPIR-V serialization utility generator -===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // SPIRVSerializationGen generates common utility functions for SPIR-V // serialization. diff --git a/mlir/tools/mlir-tblgen/StructsGen.cpp b/mlir/tools/mlir-tblgen/StructsGen.cpp index d8844957ece..576085e41eb 100644 --- a/mlir/tools/mlir-tblgen/StructsGen.cpp +++ b/mlir/tools/mlir-tblgen/StructsGen.cpp @@ -1,19 +1,10 @@ //===- StructsGen.cpp - MLIR struct utility generator ---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // StructsGen generates common utility functions for grouping attributes into a // set of structured data. diff --git a/mlir/tools/mlir-tblgen/mlir-tblgen.cpp b/mlir/tools/mlir-tblgen/mlir-tblgen.cpp index 993a05d7095..3c9778b3ec7 100644 --- a/mlir/tools/mlir-tblgen/mlir-tblgen.cpp +++ b/mlir/tools/mlir-tblgen/mlir-tblgen.cpp @@ -1,19 +1,10 @@ //===- mlir-tblgen.cpp - Top-Level TableGen implementation for MLIR -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the main function for MLIR's TableGen. // diff --git a/mlir/tools/mlir-translate/mlir-translate.cpp b/mlir/tools/mlir-translate/mlir-translate.cpp index b5622e3ecf8..3b15c5f3875 100644 --- a/mlir/tools/mlir-translate/mlir-translate.cpp +++ b/mlir/tools/mlir-translate/mlir-translate.cpp @@ -1,19 +1,10 @@ //===- mlir-translate.cpp - MLIR Translate Driver -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is a command line utility that translates a file from/to MLIR using one // of the registered translations. diff --git a/mlir/unittests/ADT/TypeSwitchTest.cpp b/mlir/unittests/ADT/TypeSwitchTest.cpp index b6a78de892e..549fb9b221e 100644 --- a/mlir/unittests/ADT/TypeSwitchTest.cpp +++ b/mlir/unittests/ADT/TypeSwitchTest.cpp @@ -1,19 +1,10 @@ //===- TypeSwitchTest.cpp - TypeSwitch unit tests -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/ADT/TypeSwitch.h" #include "gtest/gtest.h" diff --git a/mlir/unittests/Dialect/BroadcastShapeTest.cpp b/mlir/unittests/Dialect/BroadcastShapeTest.cpp index c475fa79476..594e98741e1 100644 --- a/mlir/unittests/Dialect/BroadcastShapeTest.cpp +++ b/mlir/unittests/Dialect/BroadcastShapeTest.cpp @@ -1,19 +1,10 @@ //===- BroadcastShapeTest.cpp - broadcasting shape unit tests -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/Traits.h" #include "llvm/ADT/SmallVector.h" diff --git a/mlir/unittests/Dialect/QuantOps/QuantizationUtilsTest.cpp b/mlir/unittests/Dialect/QuantOps/QuantizationUtilsTest.cpp index d10623e3d1d..4f6ad302c7c 100644 --- a/mlir/unittests/Dialect/QuantOps/QuantizationUtilsTest.cpp +++ b/mlir/unittests/Dialect/QuantOps/QuantizationUtilsTest.cpp @@ -1,19 +1,10 @@ //===- QuantizationUtilsTest.cpp - unit tests for quantization utils ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/QuantizeUtils.h" #include "mlir/Dialect/QuantOps/UniformSupport.h" diff --git a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp index ed5bd9ebecc..72fee15ac90 100644 --- a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp +++ b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp @@ -1,19 +1,10 @@ //===- DeserializationTest.cpp - SPIR-V Deserialization Tests -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // The purpose of this file is to provide negative deserialization tests. // For positive deserialization tests, please use serialization and diff --git a/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp b/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp index 2728ab820b6..61f5fcbfb7b 100644 --- a/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp +++ b/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp @@ -1,19 +1,10 @@ //===- SerializationTest.cpp - SPIR-V Serialization Tests -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains corner case tests for the SPIR-V serializer that are not // covered by normal serialization and deserialization roundtripping. diff --git a/mlir/unittests/IR/AttributeTest.cpp b/mlir/unittests/IR/AttributeTest.cpp index 3db87b29c2d..5a1750e1123 100644 --- a/mlir/unittests/IR/AttributeTest.cpp +++ b/mlir/unittests/IR/AttributeTest.cpp @@ -1,19 +1,10 @@ //===- AttributeTest.cpp - Attribute unit tests ---------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Attributes.h" #include "mlir/IR/StandardTypes.h" diff --git a/mlir/unittests/IR/DialectTest.cpp b/mlir/unittests/IR/DialectTest.cpp index e48d2d7d710..1438d322652 100644 --- a/mlir/unittests/IR/DialectTest.cpp +++ b/mlir/unittests/IR/DialectTest.cpp @@ -1,19 +1,10 @@ //===- DialectTest.cpp - Dialect unit tests -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Dialect.h" #include "gtest/gtest.h" diff --git a/mlir/unittests/IR/OperationSupportTest.cpp b/mlir/unittests/IR/OperationSupportTest.cpp index d7dae4648fe..004a940ca6c 100644 --- a/mlir/unittests/IR/OperationSupportTest.cpp +++ b/mlir/unittests/IR/OperationSupportTest.cpp @@ -1,19 +1,10 @@ //===- OperationSupportTest.cpp - Operation support unit tests ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/OperationSupport.h" #include "mlir/IR/Builders.h" diff --git a/mlir/unittests/IR/StringExtrasTest.cpp b/mlir/unittests/IR/StringExtrasTest.cpp index def65950365..3773006faee 100644 --- a/mlir/unittests/IR/StringExtrasTest.cpp +++ b/mlir/unittests/IR/StringExtrasTest.cpp @@ -1,19 +1,10 @@ //===- StringExtrasTest.cpp - Tests for utility methods in StringExtras.h -===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Support/StringExtras.h" #include "gtest/gtest.h" diff --git a/mlir/unittests/Pass/AnalysisManagerTest.cpp b/mlir/unittests/Pass/AnalysisManagerTest.cpp index 790ad9c2589..0ea2c3f66e5 100644 --- a/mlir/unittests/Pass/AnalysisManagerTest.cpp +++ b/mlir/unittests/Pass/AnalysisManagerTest.cpp @@ -1,19 +1,10 @@ //===- AnalysisManagerTest.cpp - AnalysisManager unit tests ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Pass/AnalysisManager.h" #include "mlir/IR/Builders.h" diff --git a/mlir/unittests/Quantizer/Support/RulesTest.cpp b/mlir/unittests/Quantizer/Support/RulesTest.cpp index 7ddfb715751..e2593848cbf 100644 --- a/mlir/unittests/Quantizer/Support/RulesTest.cpp +++ b/mlir/unittests/Quantizer/Support/RulesTest.cpp @@ -1,19 +1,10 @@ //===- RulesTest.cpp - Rules unit tests -----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/Rules.h" #include "llvm/Support/raw_ostream.h" diff --git a/mlir/unittests/Quantizer/Support/UniformSolversTest.cpp b/mlir/unittests/Quantizer/Support/UniformSolversTest.cpp index 4a53f923d3d..4e27cdc1d66 100644 --- a/mlir/unittests/Quantizer/Support/UniformSolversTest.cpp +++ b/mlir/unittests/Quantizer/Support/UniformSolversTest.cpp @@ -1,19 +1,10 @@ //===- UniformSolversTest.cpp - Tests for uniform solvers -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/UniformSolvers.h" #include "gtest/gtest.h" diff --git a/mlir/unittests/SDBM/SDBMTest.cpp b/mlir/unittests/SDBM/SDBMTest.cpp index 99756dcaa96..aa55ce58477 100644 --- a/mlir/unittests/SDBM/SDBMTest.cpp +++ b/mlir/unittests/SDBM/SDBMTest.cpp @@ -1,19 +1,10 @@ //===- SDBMTest.cpp - SDBM expression unit tests --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/SDBM/SDBM.h" #include "mlir/Dialect/SDBM/SDBMDialect.h" diff --git a/mlir/unittests/TableGen/EnumsGenTest.cpp b/mlir/unittests/TableGen/EnumsGenTest.cpp index 3934e8b0ed2..e4fe68482ef 100644 --- a/mlir/unittests/TableGen/EnumsGenTest.cpp +++ b/mlir/unittests/TableGen/EnumsGenTest.cpp @@ -1,19 +1,10 @@ //===- EnumsGenTest.cpp - TableGen EnumsGen Tests -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" diff --git a/mlir/unittests/TableGen/FormatTest.cpp b/mlir/unittests/TableGen/FormatTest.cpp index 7338a8f7554..0566c8a5a7b 100644 --- a/mlir/unittests/TableGen/FormatTest.cpp +++ b/mlir/unittests/TableGen/FormatTest.cpp @@ -1,19 +1,10 @@ //===- FormatTest.cpp - TableGen Format Utility Tests ---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/TableGen/Format.h" #include "gmock/gmock.h" diff --git a/mlir/unittests/TableGen/StructsGenTest.cpp b/mlir/unittests/TableGen/StructsGenTest.cpp index b446ca9558a..45455d7e2aa 100644 --- a/mlir/unittests/TableGen/StructsGenTest.cpp +++ b/mlir/unittests/TableGen/StructsGenTest.cpp @@ -1,19 +1,10 @@ //===- StructsGenTest.cpp - TableGen StructsGen Tests ---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Attributes.h" #include "mlir/IR/Identifier.h" diff --git a/mlir/unittests/TableGen/enums.td b/mlir/unittests/TableGen/enums.td index 806d4a9d7b9..7d44856f9dc 100644 --- a/mlir/unittests/TableGen/enums.td +++ b/mlir/unittests/TableGen/enums.td @@ -1,19 +1,10 @@ //===-- enums.td - EnumsGen test definition file -----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// include "mlir/IR/OpBase.td" diff --git a/mlir/unittests/TableGen/structs.td b/mlir/unittests/TableGen/structs.td index efa0a6024c5..88551751182 100644 --- a/mlir/unittests/TableGen/structs.td +++ b/mlir/unittests/TableGen/structs.td @@ -1,19 +1,10 @@ //===-- structs.td - StructsGen test definition file -------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// include "mlir/IR/OpBase.td" diff --git a/mlir/utils/generate-test-checks.py b/mlir/utils/generate-test-checks.py index 3bb4ffe4a4f..6dc40c797e2 100755 --- a/mlir/utils/generate-test-checks.py +++ b/mlir/utils/generate-test-checks.py @@ -17,19 +17,9 @@ adding checks to a test case fast, it is *not* designed to be authoritative about what constitutes a good test! """ -# Copyright 2019 The MLIR Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# 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 import argparse import os # Used to advertise this file's name ("autogenerated_note"). diff --git a/mlir/utils/spirv/define_enum.sh b/mlir/utils/spirv/define_enum.sh index 9da898f7d4c..87b88c93133 100755 --- a/mlir/utils/spirv/define_enum.sh +++ b/mlir/utils/spirv/define_enum.sh @@ -1,18 +1,8 @@ #!/bin/bash -# Copyright 2019 The MLIR Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# 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 # Script for defining a new enum attr using SPIR-V spec from the Internet. # diff --git a/mlir/utils/spirv/define_inst.sh b/mlir/utils/spirv/define_inst.sh index f11078a8e76..322c67e8da8 100755 --- a/mlir/utils/spirv/define_inst.sh +++ b/mlir/utils/spirv/define_inst.sh @@ -1,17 +1,7 @@ #!/bin/bash -# Copyright 2019 The MLIR Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# 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 # Script for defining a new op using SPIR-V spec from the Internet. # diff --git a/mlir/utils/spirv/define_opcodes.sh b/mlir/utils/spirv/define_opcodes.sh index 05c36571115..7b9aeab9c08 100755 --- a/mlir/utils/spirv/define_opcodes.sh +++ b/mlir/utils/spirv/define_opcodes.sh @@ -1,18 +1,8 @@ #!/bin/bash -# Copyright 2019 The MLIR Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# 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 # Script for defining map for opname to opcode using SPIR-V spec from the # Internet diff --git a/mlir/utils/spirv/gen_spirv_dialect.py b/mlir/utils/spirv/gen_spirv_dialect.py index be7116c211f..2433cf4e6da 100755 --- a/mlir/utils/spirv/gen_spirv_dialect.py +++ b/mlir/utils/spirv/gen_spirv_dialect.py @@ -1,19 +1,9 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright 2019 The MLIR Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# 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 # Script for updating SPIR-V dialect by scraping information from SPIR-V # HTML and JSON specs from the Internet. -- cgit v1.2.3