[Mlir-commits] [mlir] 2b92f21 - [mlir] Drop deprecated syntax for LLVM dialect types

Alex Zinenko llvmlistbot at llvm.org
Mon Feb 8 10:26:31 PST 2021


Author: Alex Zinenko
Date: 2021-02-08T19:26:21+01:00
New Revision: 2b92f21c6e97bd40edec71bb085b06f67e078f59

URL: https://github.com/llvm/llvm-project/commit/2b92f21c6e97bd40edec71bb085b06f67e078f59
DIFF: https://github.com/llvm/llvm-project/commit/2b92f21c6e97bd40edec71bb085b06f67e078f59.diff

LOG: [mlir] Drop deprecated syntax for LLVM dialect types

After the LLVM dialect types were ported to use built-in types, the parser kept
supporting the old syntax for LLVM dialect types to produce built-in types for
compatibility. Drop this support.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D96275

Added: 
    

Modified: 
    mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
    mlir/test/Dialect/LLVMIR/types-invalid.mlir
    mlir/test/Target/llvmir-intrinsics.mlir
    mlir/test/Target/openmp-llvm.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
index f3f5d12fb6b6..61499ee59a30 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
@@ -236,11 +236,12 @@ static LLVMPointerType parsePointerType(DialectAsmParser &parser) {
 /// Supports both fixed and scalable vectors.
 static Type parseVectorType(DialectAsmParser &parser) {
   SmallVector<int64_t, 2> dims;
-  llvm::SMLoc dimPos;
+  llvm::SMLoc dimPos, typePos;
   Type elementType;
   Location loc = parser.getEncodedSourceLoc(parser.getCurrentLocation());
   if (parser.parseLess() || parser.getCurrentLocation(&dimPos) ||
       parser.parseDimensionList(dims, /*allowDynamic=*/true) ||
+      parser.getCurrentLocation(&typePos) ||
       dispatchParse(parser, elementType) || parser.parseGreater())
     return Type();
 
@@ -259,8 +260,11 @@ static Type parseVectorType(DialectAsmParser &parser) {
   bool isScalable = dims.size() == 2;
   if (isScalable)
     return LLVMScalableVectorType::getChecked(loc, elementType, dims[1]);
-  if (elementType.isSignlessIntOrFloat())
-    return VectorType::getChecked(loc, dims, elementType);
+  if (elementType.isSignlessIntOrFloat()) {
+    parser.emitError(typePos)
+        << "cannot use !llvm.vec for built-in primitives, use 'vector' instead";
+    return Type();
+  }
   return LLVMFixedVectorType::getChecked(loc, elementType, dims[0]);
 }
 
@@ -409,7 +413,6 @@ static LLVMStructType parseStructType(DialectAsmParser &parser) {
 /// LLVM dialect types without the `!llvm` prefix.
 static Type dispatchParse(DialectAsmParser &parser, bool allowAny = true) {
   llvm::SMLoc keyLoc = parser.getCurrentLocation();
-  Location loc = parser.getEncodedSourceLoc(keyLoc);
 
   // Try parsing any MLIR type.
   Type type;
@@ -417,15 +420,9 @@ static Type dispatchParse(DialectAsmParser &parser, bool allowAny = true) {
   if (result.hasValue()) {
     if (failed(result.getValue()))
       return nullptr;
-    // TODO: integer types are temporarily allowed for compatibility with the
-    // deprecated !llvm.i[0-9]+ syntax.
     if (!allowAny) {
-      auto intType = type.dyn_cast<IntegerType>();
-      if (!intType || !intType.isSignless()) {
-        parser.emitError(keyLoc) << "unexpected type, expected keyword";
-        return nullptr;
-      }
-      emitWarning(loc) << "deprecated syntax, drop '!llvm.' for integers";
+      parser.emitError(keyLoc) << "unexpected type, expected keyword";
+      return nullptr;
     }
     return type;
   }
@@ -438,36 +435,6 @@ static Type dispatchParse(DialectAsmParser &parser, bool allowAny = true) {
   MLIRContext *ctx = parser.getBuilder().getContext();
   return StringSwitch<function_ref<Type()>>(key)
       .Case("void", [&] { return LLVMVoidType::get(ctx); })
-      .Case("bfloat",
-            [&] {
-              emitWarning(loc) << "deprecated syntax, use bf16 instead";
-              return BFloat16Type::get(ctx);
-            })
-      .Case("half",
-            [&] {
-              emitWarning(loc) << "deprecated syntax, use f16 instead";
-              return Float16Type::get(ctx);
-            })
-      .Case("float",
-            [&] {
-              emitWarning(loc) << "deprecated syntax, use f32 instead";
-              return Float32Type::get(ctx);
-            })
-      .Case("double",
-            [&] {
-              emitWarning(loc) << "deprecated syntax, use f64 instead";
-              return Float64Type::get(ctx);
-            })
-      .Case("fp128",
-            [&] {
-              emitWarning(loc) << "deprecated syntax, use f128 instead";
-              return Float128Type::get(ctx);
-            })
-      .Case("x86_fp80",
-            [&] {
-              emitWarning(loc) << "deprecated syntax, use f80 instead";
-              return Float80Type::get(ctx);
-            })
       .Case("ppc_fp128", [&] { return LLVMPPCFP128Type::get(ctx); })
       .Case("x86_mmx", [&] { return LLVMX86MMXType::get(ctx); })
       .Case("token", [&] { return LLVMTokenType::get(ctx); })

diff  --git a/mlir/test/Dialect/LLVMIR/types-invalid.mlir b/mlir/test/Dialect/LLVMIR/types-invalid.mlir
index d1c661dab516..cfeab15267e0 100644
--- a/mlir/test/Dialect/LLVMIR/types-invalid.mlir
+++ b/mlir/test/Dialect/LLVMIR/types-invalid.mlir
@@ -153,35 +153,15 @@ func @scalable_void_vector() {
 
 // -----
 
-// expected-warning @+1 {{deprecated syntax, drop '!llvm.' for integers}}
-func private @deprecated_int() -> !llvm.i32
-
-// -----
-
 // expected-error @+1 {{unexpected type, expected keyword}}
 func private @unexpected_type() -> !llvm.tensor<*xf32>
 
 // -----
 
-// expected-warning @+1 {{deprecated syntax, use bf16 instead}}
-func private @deprecated_bfloat() -> !llvm.bfloat
-
-// -----
-
-// expected-warning @+1 {{deprecated syntax, use f16 instead}}
-func private @deprecated_half() -> !llvm.half
-
-// -----
-
-// expected-warning @+1 {{deprecated syntax, use f32 instead}}
-func private @deprecated_float() -> !llvm.float
-
-// -----
-
-// expected-warning @+1 {{deprecated syntax, use f64 instead}}
-func private @deprecated_double() -> !llvm.double
+// expected-error @+1 {{unexpected type, expected keyword}}
+func private @unexpected_type() -> !llvm.f32
 
 // -----
 
-// expected-error @+1 {{unexpected type, expected keyword}}
-func private @unexpected_type() -> !llvm.f32
+// expected-error @below {{cannot use !llvm.vec for built-in primitives, use 'vector' instead}}
+func private @llvm_vector_primitive() -> !llvm.vec<4 x f32>

diff  --git a/mlir/test/Target/llvmir-intrinsics.mlir b/mlir/test/Target/llvmir-intrinsics.mlir
index bbffb8965a3a..12b470a8176b 100644
--- a/mlir/test/Target/llvmir-intrinsics.mlir
+++ b/mlir/test/Target/llvmir-intrinsics.mlir
@@ -380,14 +380,14 @@ llvm.func @coro_save(%arg0: !llvm.ptr<i8>) {
 // CHECK-LABEL: @coro_suspend
 llvm.func @coro_suspend(%arg0: !llvm.token, %arg1 : i1) {
   // CHECK: call i8 @llvm.coro.suspend
-  %0 = llvm.intr.coro.suspend %arg0, %arg1 : !llvm.i8
+  %0 = llvm.intr.coro.suspend %arg0, %arg1 : i8
   llvm.return
 }
 
 // CHECK-LABEL: @coro_end
 llvm.func @coro_end(%arg0: !llvm.ptr<i8>, %arg1 : i1) {
   // CHECK: call i1 @llvm.coro.end
-  %0 = llvm.intr.coro.end %arg0, %arg1 : !llvm.i1
+  %0 = llvm.intr.coro.end %arg0, %arg1 : i1
   llvm.return
 }
 

diff  --git a/mlir/test/Target/openmp-llvm.mlir b/mlir/test/Target/openmp-llvm.mlir
index d8bda22fc93c..71f0277744f3 100644
--- a/mlir/test/Target/openmp-llvm.mlir
+++ b/mlir/test/Target/openmp-llvm.mlir
@@ -325,33 +325,33 @@ llvm.func @wsloop_simple(%arg0: !llvm.ptr<f32>) {
 }
 
 // CHECK-LABEL: @wsloop_inclusive_1
-llvm.func @wsloop_inclusive_1(%arg0: !llvm.ptr<float>) {
-  %0 = llvm.mlir.constant(42 : index) : !llvm.i64
-  %1 = llvm.mlir.constant(10 : index) : !llvm.i64
-  %2 = llvm.mlir.constant(1 : index) : !llvm.i64
+llvm.func @wsloop_inclusive_1(%arg0: !llvm.ptr<f32>) {
+  %0 = llvm.mlir.constant(42 : index) : i64
+  %1 = llvm.mlir.constant(10 : index) : i64
+  %2 = llvm.mlir.constant(1 : index) : i64
   // CHECK: store i64 31, i64* %{{.*}}upperbound
   "omp.wsloop"(%1, %0, %2) ( {
-  ^bb0(%arg1: !llvm.i64):
-    %3 = llvm.mlir.constant(2.000000e+00 : f32) : !llvm.float
-    %4 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr<float>, !llvm.i64) -> !llvm.ptr<float>
-    llvm.store %3, %4 : !llvm.ptr<float>
+  ^bb0(%arg1: i64):
+    %3 = llvm.mlir.constant(2.000000e+00 : f32) : f32
+    %4 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr<f32>, i64) -> !llvm.ptr<f32>
+    llvm.store %3, %4 : !llvm.ptr<f32>
     omp.yield
-  }) {operand_segment_sizes = dense<[1, 1, 1, 0, 0, 0, 0, 0, 0]> : vector<9xi32>} : (!llvm.i64, !llvm.i64, !llvm.i64) -> ()
+  }) {operand_segment_sizes = dense<[1, 1, 1, 0, 0, 0, 0, 0, 0]> : vector<9xi32>} : (i64, i64, i64) -> ()
   llvm.return
 }
 
 // CHECK-LABEL: @wsloop_inclusive_2
-llvm.func @wsloop_inclusive_2(%arg0: !llvm.ptr<float>) {
-  %0 = llvm.mlir.constant(42 : index) : !llvm.i64
-  %1 = llvm.mlir.constant(10 : index) : !llvm.i64
-  %2 = llvm.mlir.constant(1 : index) : !llvm.i64
+llvm.func @wsloop_inclusive_2(%arg0: !llvm.ptr<f32>) {
+  %0 = llvm.mlir.constant(42 : index) : i64
+  %1 = llvm.mlir.constant(10 : index) : i64
+  %2 = llvm.mlir.constant(1 : index) : i64
   // CHECK: store i64 32, i64* %{{.*}}upperbound
   "omp.wsloop"(%1, %0, %2) ( {
-  ^bb0(%arg1: !llvm.i64):
-    %3 = llvm.mlir.constant(2.000000e+00 : f32) : !llvm.float
-    %4 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr<float>, !llvm.i64) -> !llvm.ptr<float>
-    llvm.store %3, %4 : !llvm.ptr<float>
+  ^bb0(%arg1: i64):
+    %3 = llvm.mlir.constant(2.000000e+00 : f32) : f32
+    %4 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr<f32>, i64) -> !llvm.ptr<f32>
+    llvm.store %3, %4 : !llvm.ptr<f32>
     omp.yield
-  }) {inclusive, operand_segment_sizes = dense<[1, 1, 1, 0, 0, 0, 0, 0, 0]> : vector<9xi32>} : (!llvm.i64, !llvm.i64, !llvm.i64) -> ()
+  }) {inclusive, operand_segment_sizes = dense<[1, 1, 1, 0, 0, 0, 0, 0, 0]> : vector<9xi32>} : (i64, i64, i64) -> ()
   llvm.return
 }


        


More information about the Mlir-commits mailing list