diff --git a/include/Standalone/LinneaDialect.td b/include/Standalone/LinneaDialect.td index f502cec..36f52f2 100644 --- a/include/Standalone/LinneaDialect.td +++ b/include/Standalone/LinneaDialect.td @@ -28,8 +28,8 @@ def Linnea_Dialect : Dialect { let extraClassDeclaration = [{ //Type parseType(DialectAsmParser& parser) const override; //void printType(Type type, DialectAsmPrinter& printer) const override; - Attribute parseAttribute(DialectAsmParser &parser, Type type) const override; - void printAttribute(Attribute attr, DialectAsmPrinter &printer) const override; + //Attribute parseAttribute(DialectAsmParser &parser, Type type) const override; + //void printAttribute(Attribute attr, DialectAsmPrinter &printer) const override; }]; } diff --git a/include/Standalone/LinneaPasses.h b/include/Standalone/LinneaPasses.h index a8a921e..949cbd5 100644 --- a/include/Standalone/LinneaPasses.h +++ b/include/Standalone/LinneaPasses.h @@ -9,14 +9,66 @@ #ifndef LINNEA_PASSES_H #define LINNEA_PASSES_H -#include "mlir/Dialect/Bufferization/IR/Bufferization.h" -#include "mlir/Dialect/Func/IR/FuncOps.h" -#include "mlir/Dialect/LLVMIR/LLVMDialect.h" -#include "mlir/Dialect/Linalg/IR/Linalg.h" -#include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/Vector/IR/VectorOps.h" #include "mlir/Pass/Pass.h" +namespace mlir { +class ModuleOp; +} // namespace mlir + +namespace mlir { +namespace func { +class FuncOp; +} // namespace func +} // namespace mlir + +namespace mlir { +namespace vector { +class VectorDialect; +} // namespace vector +} // namespace mlir + +namespace mlir { +namespace linalg { +class LinalgDialect; +} // namespace linalg +} // namespace mlir + +namespace mlir { +namespace scf { +class SCFDialect; +} // namespace scf +} // namespace mlir + +namespace mlir { +namespace memref { +class MemRefDialect; +} // namespace memref +} // namespace mlir + +namespace mlir { +namespace arith { +class ArithmeticDialect; +} // namespace arith +} // namespace mlir + +namespace mlir { +namespace bufferization { +class BufferizationDialect; +} // namespace bufferization +} // namespace mlir + +namespace mlir { +namespace tensor { +class TensorDialect; +} // namespace tensor +} // namespace mlir + +namespace mlir { +namespace LLVM { +class LLVMDialect; +} // namespace LLVM +} // namespace mlir + namespace mlir { namespace linnea { std::unique_ptr> createConvertLinneaToLinalgPass(); diff --git a/lib/Standalone/LinneaCompilerPipeline.cpp b/lib/Standalone/LinneaCompilerPipeline.cpp index a452b1e..72d444d 100644 --- a/lib/Standalone/LinneaCompilerPipeline.cpp +++ b/lib/Standalone/LinneaCompilerPipeline.cpp @@ -13,9 +13,13 @@ #include "mlir/Conversion/ReconcileUnrealizedCasts/ReconcileUnrealizedCasts.h" #include "mlir/Conversion/SCFToControlFlow/SCFToControlFlow.h" #include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h" +#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/Arithmetic/Transforms/Passes.h" +#include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/Bufferization/Transforms/Passes.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Func/Transforms/Passes.h" +#include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/Linalg/Passes.h" #include "mlir/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.h" #include "mlir/Dialect/Tensor/Transforms/Passes.h" diff --git a/lib/Standalone/LinneaConvertToLinalg.cpp b/lib/Standalone/LinneaConvertToLinalg.cpp index 5a208e0..74d870c 100644 --- a/lib/Standalone/LinneaConvertToLinalg.cpp +++ b/lib/Standalone/LinneaConvertToLinalg.cpp @@ -10,8 +10,14 @@ #include "Standalone/LinneaOps.h" #include "Standalone/LinneaPasses.h" #include "Standalone/LinneaUtils.h" +#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Func/Transforms/FuncConversions.h" +#include "mlir/Dialect/LLVMIR/LLVMDialect.h" +#include "mlir/Dialect/Linalg/IR/Linalg.h" +#include "mlir/Dialect/Tensor/IR/Tensor.h" +#include "mlir/Dialect/Vector/IR/VectorOps.h" #include "mlir/Transforms/DialectConversion.h" #include "mlir/Pass/Pass.h" diff --git a/lib/Standalone/LinneaConvertToLoops.cpp b/lib/Standalone/LinneaConvertToLoops.cpp index ec2e7d0..f6654dc 100644 --- a/lib/Standalone/LinneaConvertToLoops.cpp +++ b/lib/Standalone/LinneaConvertToLoops.cpp @@ -11,6 +11,7 @@ #include "Standalone/LinneaPasses.h" #include "Standalone/LinneaUtils.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/Linalg/Passes.h" #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" diff --git a/test/Integration/linnea-lower-add-op.mlir b/test/Integration/linnea-lower-add-op.mlir index bdd14e8..8d66a42 100644 --- a/test/Integration/linnea-lower-add-op.mlir +++ b/test/Integration/linnea-lower-add-op.mlir @@ -5,7 +5,7 @@ // RUN: FileCheck %s // module { - func @entry() { + func.func @entry() { %c5 = arith.constant 5 : index %fc = arith.constant 5.0 : f32 diff --git a/test/Integration/linnea-lower-add-op2.mlir b/test/Integration/linnea-lower-add-op2.mlir index c9a15f3..4fed18f 100644 --- a/test/Integration/linnea-lower-add-op2.mlir +++ b/test/Integration/linnea-lower-add-op2.mlir @@ -5,7 +5,7 @@ // RUN: FileCheck %s // module { - func @entry() { + func.func @entry() { %c5 = arith.constant 5 : index %fc = arith.constant 5.0 : f32 diff --git a/test/Integration/linnea-lower-chain.mlir b/test/Integration/linnea-lower-chain.mlir index 70d4f49..f730c74 100644 --- a/test/Integration/linnea-lower-chain.mlir +++ b/test/Integration/linnea-lower-chain.mlir @@ -21,7 +21,7 @@ // RUN: rm -rf %testdir/chain module { - func @entry() { + func.func @entry() { // A1. %fA1 = arith.constant 1 : i32 diff --git a/test/Integration/linnea-lower-mul-op.mlir b/test/Integration/linnea-lower-mul-op.mlir index 8fe787e..859c2a3 100644 --- a/test/Integration/linnea-lower-mul-op.mlir +++ b/test/Integration/linnea-lower-mul-op.mlir @@ -6,7 +6,7 @@ // module { - func @entry() { + func.func @entry() { %c5 = arith.constant 5 : index diff --git a/test/Integration/linnea-lower-mul-op2.mlir b/test/Integration/linnea-lower-mul-op2.mlir index 20a0892..36cb85b 100644 --- a/test/Integration/linnea-lower-mul-op2.mlir +++ b/test/Integration/linnea-lower-mul-op2.mlir @@ -6,7 +6,7 @@ // module { - func @entry() { + func.func @entry() { %c5 = arith.constant 5 : index %fc = arith.constant 5.0 : f32 diff --git a/test/Integration/linnea-lower-mul-op3.mlir b/test/Integration/linnea-lower-mul-op3.mlir index c062b01..061c638 100644 --- a/test/Integration/linnea-lower-mul-op3.mlir +++ b/test/Integration/linnea-lower-mul-op3.mlir @@ -6,7 +6,7 @@ // module { - func @entry() { + func.func @entry() { %c5 = arith.constant 5 : index %fc = arith.constant 5.0 : f32 diff --git a/test/Standalone/canonicalize.mlir b/test/Standalone/canonicalize.mlir index f2286b1..56eed44 100644 --- a/test/Standalone/canonicalize.mlir +++ b/test/Standalone/canonicalize.mlir @@ -2,7 +2,7 @@ // CHECK-LABEL: @bar // CHECK-SAME: %[[arg0:[a-zA-Z0-9]+]]: !linnea.matrix<#linnea.property<["square"]>, [32, 32], f32> -func @bar(%arg0 : !linnea.matrix<#linnea.property<["square"]>, [32,32], f32>) -> !linnea.term { +func.func @bar(%arg0 : !linnea.matrix<#linnea.property<["square"]>, [32,32], f32>) -> !linnea.term { %0 = linnea.equation { %1 = linnea.inverse.high %arg0 : !linnea.matrix<#linnea.property<["square"]>, [32,32], f32> @@ -19,7 +19,7 @@ func @bar(%arg0 : !linnea.matrix<#linnea.property<["square"]>, [32,32], f32>) -> // CHECK-LABEL: @bar // CHECK-SAME: %[[arg0:[a-zA-Z0-9]+]]: !linnea.matrix<#linnea.property<["general"]>, [32, 32], f32> -func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>, [32, 32], f32>, +func.func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>, [32, 32], f32>, %arg1: !linnea.identity<[32, 32], f32>) -> !linnea.term { %0 = linnea.equation { diff --git a/test/Standalone/conversion.mlir b/test/Standalone/conversion.mlir index cc39383..3a61e84 100644 --- a/test/Standalone/conversion.mlir +++ b/test/Standalone/conversion.mlir @@ -1,7 +1,7 @@ // RUN: standalone-opt %s --properties-propagation --linnea-func-type-conversion --convert-linnea-to-linalg | FileCheck %s // CHECK-LABEL: func @bar( -func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>, +func.func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) { %0 = linnea.equation { // CHECK: %{{.*}} = linalg.generic diff --git a/test/Standalone/invalid.mlir b/test/Standalone/invalid.mlir index a146e26..c0a3259 100644 --- a/test/Standalone/invalid.mlir +++ b/test/Standalone/invalid.mlir @@ -1,6 +1,6 @@ // RUN: standalone-opt --verify-diagnostics %s -func @some_func() { +func.func @some_func() { // expected-error @below {{Unexpected empty region}} linnea.equation { diff --git a/test/Standalone/ops.mlir b/test/Standalone/ops.mlir index 9176310..583a8d9 100644 --- a/test/Standalone/ops.mlir +++ b/test/Standalone/ops.mlir @@ -1,7 +1,7 @@ // RUN: standalone-opt --split-input-file %s | standalone-opt | FileCheck %s // CHECK-LABEL: func @bar( -func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) { +func.func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) { // CHECK: %{{.*}} = linnea.mul.low %{{.*}} %0 = linnea.mul.low %arg0, %arg1 { semirings = "min-plus" }: !linnea.term, !linnea.matrix<#linnea.property<["general"]>,[32,32], f32> -> !linnea.term return @@ -10,7 +10,7 @@ func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general" // ----- // CHECK-LABEL: func @bar( -func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) { +func.func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) { %0 = linnea.equation { // CHECK: %{{.*}} = linnea.mul.high %{{.*}} %1 = linnea.mul.high %arg0, %arg1 : !linnea.term, !linnea.matrix<#linnea.property<["general"]>,[32,32], f32> -> !linnea.term @@ -22,7 +22,7 @@ func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general" // ----- // CHECK-LABEL: func @bar( -func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) { +func.func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) { // CHECK: %{{.*}} = linnea.equation %0 = linnea.equation { // CHECK: %[[T:.*]] = linnea.transpose %{{.*}} @@ -36,7 +36,7 @@ func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) { // ----- // CHECK-LABEL: func @bar( -func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>, %arg1: f32) { +func.func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>, %arg1: f32) { // CHECK: %{{.*}} = linnea.fill linnea.fill(%arg1, %arg0) : f32, !linnea.matrix<#linnea.property<["general"]>,[32,32], f32> return @@ -45,7 +45,7 @@ func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>, %ar // ----- // CHECK-LABEL: func @bar( -func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) { +func.func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) { %0 = linnea.equation { // CHECK: %{{.*}} = linnea.mul.high %1 = linnea.mul.high %arg0, %arg1 { semirings = "min-plus" } : !linnea.term, !linnea.matrix<#linnea.property<["general"]>,[32,32], f32> -> !linnea.term @@ -57,7 +57,7 @@ func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general" // ----- // CHECK-LABEL: func @bar( -func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) { +func.func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) { // CHECK: %{{.*}} = linnea.mul.low %{{.*}} %0 = linnea.mul.low %arg0, %arg1 { semirings = "min-plus" } : !linnea.term, !linnea.matrix<#linnea.property<["general"]>,[32,32], f32> -> !linnea.term return @@ -66,7 +66,7 @@ func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general" // ----- // CHECK-LABEL: func @bar( -func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) { +func.func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) { %0 = linnea.equation { // CHECK: %{{.*}} = linnea.mul.high %{{.*}} %1 = linnea.mul.high %arg0, %arg1 { semirings = "min-plus" } : !linnea.term, !linnea.matrix<#linnea.property<["general"]>,[32,32], f32> -> !linnea.term diff --git a/test/Standalone/properties-propagation.mlir b/test/Standalone/properties-propagation.mlir index e1a4d52..f4f0755 100644 --- a/test/Standalone/properties-propagation.mlir +++ b/test/Standalone/properties-propagation.mlir @@ -1,7 +1,7 @@ // RUN: standalone-opt %s --split-input-file --properties-propagation | FileCheck %s module { // CHECK: entry - func @entry() { + func.func @entry() { %c5 = arith.constant 5 : index %fc = arith.constant 5.0 : f32 @@ -46,7 +46,7 @@ module { module { // CHECK: entry - func @entry() { + func.func @entry() { %c5 = arith.constant 5 : index %fc = arith.constant 5.0 : f32