[Mlir-commits] [mlir] 6410ee0 - [mlir] Squash LLVM_ArmNeon dialect into ArmNeon

Alex Zinenko llvmlistbot at llvm.org
Fri Mar 5 14:33:39 PST 2021


Author: Alex Zinenko
Date: 2021-03-05T23:33:32+01:00
New Revision: 6410ee0d09bbd87bb0a19b1fdeca2e9420e487e8

URL: https://github.com/llvm/llvm-project/commit/6410ee0d09bbd87bb0a19b1fdeca2e9420e487e8
DIFF: https://github.com/llvm/llvm-project/commit/6410ee0d09bbd87bb0a19b1fdeca2e9420e487e8.diff

LOG: [mlir] Squash LLVM_ArmNeon dialect into ArmNeon

The two dialects are largely redundant. The former was introduced as a mirror
of the latter operating on LLVM dialect types. This is no longer necessary
since the LLVM dialect operates on built-in types. Combine the two dialects.

Reviewed By: mehdi_amini

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

Added: 
    mlir/include/mlir/Target/LLVMIR/Dialect/ArmNeon/ArmNeonToLLVMIRTranslation.h
    mlir/lib/Target/LLVMIR/Dialect/ArmNeon/ArmNeonToLLVMIRTranslation.cpp
    mlir/lib/Target/LLVMIR/Dialect/ArmNeon/CMakeLists.txt

Modified: 
    mlir/include/mlir/Dialect/ArmNeon/ArmNeon.td
    mlir/include/mlir/Dialect/ArmNeon/CMakeLists.txt
    mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt
    mlir/include/mlir/InitAllDialects.h
    mlir/include/mlir/Target/LLVMIR/Dialect/All.h
    mlir/lib/Conversion/CMakeLists.txt
    mlir/lib/Conversion/PassDetail.h
    mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt
    mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
    mlir/lib/Dialect/LLVMIR/CMakeLists.txt
    mlir/lib/Target/LLVMIR/CMakeLists.txt
    mlir/lib/Target/LLVMIR/Dialect/CMakeLists.txt
    mlir/test/Target/arm-neon.mlir
    mlir/test/mlir-opt/commandline.mlir

Removed: 
    mlir/include/mlir/Conversion/ArmNeonToLLVM/ArmNeonToLLVM.h
    mlir/include/mlir/Dialect/LLVMIR/LLVMArmNeon.td
    mlir/include/mlir/Dialect/LLVMIR/LLVMArmNeonDialect.h
    mlir/include/mlir/Target/LLVMIR/Dialect/LLVMArmNeon/LLVMArmNeonToLLVMIRTranslation.h
    mlir/lib/Conversion/ArmNeonToLLVM/ArmNeonToLLVM.cpp
    mlir/lib/Conversion/ArmNeonToLLVM/CMakeLists.txt
    mlir/lib/Dialect/LLVMIR/IR/LLVMArmNeonDialect.cpp
    mlir/lib/Target/LLVMIR/Dialect/LLVMArmNeon/CMakeLists.txt
    mlir/lib/Target/LLVMIR/Dialect/LLVMArmNeon/LLVMArmNeonToLLVMIRTranslation.cpp
    mlir/test/Conversion/ArmNeonToLLVM/convert-to-llvm.mlir


################################################################################
diff  --git a/mlir/include/mlir/Conversion/ArmNeonToLLVM/ArmNeonToLLVM.h b/mlir/include/mlir/Conversion/ArmNeonToLLVM/ArmNeonToLLVM.h
deleted file mode 100644
index 41342c50d5ea..000000000000
--- a/mlir/include/mlir/Conversion/ArmNeonToLLVM/ArmNeonToLLVM.h
+++ /dev/null
@@ -1,23 +0,0 @@
-//===- ArmNeonToLLVM.h - Conversion Patterns from ArmNeon to LLVM ---------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef MLIR_CONVERSION_ARMNEONTOLLVM_ARMNEONTOLLVM_H_
-#define MLIR_CONVERSION_ARMNEONTOLLVM_ARMNEONTOLLVM_H_
-
-namespace mlir {
-
-class LLVMTypeConverter;
-class OwningRewritePatternList;
-
-/// Collect a set of patterns to convert from theArmNeon dialect to LLVM.
-void populateArmNeonToLLVMConversionPatterns(
-    LLVMTypeConverter &converter, OwningRewritePatternList &patterns);
-
-} // namespace mlir
-
-#endif // MLIR_CONVERSION_ARMNEONTOLLVM_ARMNEONTOLLVM_H_

diff  --git a/mlir/include/mlir/Dialect/ArmNeon/ArmNeon.td b/mlir/include/mlir/Dialect/ArmNeon/ArmNeon.td
index f38049be949f..b87c4b1cc12f 100644
--- a/mlir/include/mlir/Dialect/ArmNeon/ArmNeon.td
+++ b/mlir/include/mlir/Dialect/ArmNeon/ArmNeon.td
@@ -13,6 +13,7 @@
 #ifndef ARMNEON_OPS
 #define ARMNEON_OPS
 
+include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
 include "mlir/Interfaces/SideEffectInterfaces.td"
 
 //===----------------------------------------------------------------------===//
@@ -22,20 +23,43 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
 def ArmNeon_Dialect : Dialect {
   let name = "arm_neon";
   let cppNamespace = "::mlir::arm_neon";
+
+  // Note: this does not need to depend on LLVMDialect as long as functions in
+  // this dialect (such as canonicalization) do not produce entities belonging
+  // to the LLVMDialect (ops or types).
 }
 
 //===----------------------------------------------------------------------===//
 // ArmNeon op definitions
 //===----------------------------------------------------------------------===//
 
-class ArmNeon_Op<string mnemonic, list<OpTrait> traits = []> :
-  Op<ArmNeon_Dialect, mnemonic, traits> {}
+// ArmNeon dialect op that corresponds (and is convertible to) an LLVM IR
+// intrinsic.
+class ArmNeon_IntrOp<string mnemonic, list<int> overloadedResults,
+                     list<int> overloadedOperands, int numResults,
+                     list<OpTrait> traits = [], bit requiresAccessGroup = 0>
+    : LLVM_IntrOpBase</*dialect=*/ArmNeon_Dialect,
+                      /*opName=*/mnemonic,
+                      /*enumName=*/"aarch64_neon_" # !subst(".", "_", mnemonic),
+                      /*overloadedResults=*/overloadedResults,
+                      /*overloadedOperands=*/overloadedOperands,
+                      /*traits=*/traits,
+                      /*numResults=*/numResults,
+                      /*requiresAccessGroup=*/requiresAccessGroup>;
+
+// ArmNeon dialect op that corresponds to an LLVM IR intrinsic with one
+// overloaded result.
+class ArmNeon_OverloadedOneResultIntrOp<string mnemonic,
+                                        list<OpTrait> traits = []>
+  : ArmNeon_IntrOp<mnemonic, [0], [], 1, traits>;
 
-def SMullOp : ArmNeon_Op<"smull", [NoSideEffect,
-  AllTypesMatch<["a", "b"]>,
-  TypesMatchWith<
-    "res has same vector shape and element bitwidth scaled by 2 as a",
-    "a", "res", "$_self.cast<VectorType>().scaleElementBitwidth(2)">]> {
+def SMullOp : ArmNeon_OverloadedOneResultIntrOp<"smull", [
+       NoSideEffect,
+       AllTypesMatch<["a", "b"]>,
+       TypesMatchWith<
+         "res has same vector shape and element bitwidth scaled by 2 as a",
+         "a", "res", "$_self.cast<VectorType>().scaleElementBitwidth(2)">
+    ]> {
   let summary = "smull roundscale op";
   let description = [{
     Signed Multiply Long (vector). This instruction multiplies corresponding
@@ -46,6 +70,7 @@ def SMullOp : ArmNeon_Op<"smull", [NoSideEffect,
     Source:
     https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics
   }];
+
   // Supports either:
   //   (vector<8xi8>, vector<8xi8>) -> (vector<8xi16>)
   //   (vector<4xi16>, vector<4xi16>) -> (vector<4xi32>)
@@ -57,4 +82,5 @@ def SMullOp : ArmNeon_Op<"smull", [NoSideEffect,
     "$a `,` $b attr-dict `:` type($a) `to` type($res)";
 }
 
+
 #endif // ARMNEON_OPS

diff  --git a/mlir/include/mlir/Dialect/ArmNeon/CMakeLists.txt b/mlir/include/mlir/Dialect/ArmNeon/CMakeLists.txt
index 46c79d373743..40f2802644c9 100644
--- a/mlir/include/mlir/Dialect/ArmNeon/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/ArmNeon/CMakeLists.txt
@@ -1,2 +1,6 @@
 add_mlir_dialect(ArmNeon arm_neon)
 add_mlir_doc(ArmNeon -gen-dialect-doc ArmNeon Dialects/)
+
+set(LLVM_TARGET_DEFINITIONS ArmNeon.td)
+mlir_tablegen(ArmNeonConversions.inc -gen-llvmir-conversions)
+add_public_tablegen_target(MLIRArmNeonConversionsIncGen)

diff  --git a/mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt b/mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt
index 29cef3f0032d..ae0fc152ddc4 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt
@@ -36,12 +36,6 @@ set(LLVM_TARGET_DEFINITIONS LLVMAVX512.td)
 mlir_tablegen(LLVMAVX512Conversions.inc -gen-llvmir-conversions)
 add_public_tablegen_target(MLIRLLVMAVX512ConversionsIncGen)
 
-add_mlir_dialect(LLVMArmNeon llvm_arm_neon LLVMArmNeon)
-add_mlir_doc(LLVMArmNeon -gen-dialect-doc LLVMArmNeon Dialects/)
-set(LLVM_TARGET_DEFINITIONS LLVMArmNeon.td)
-mlir_tablegen(LLVMArmNeonConversions.inc -gen-llvmir-conversions)
-add_public_tablegen_target(MLIRLLVMArmNeonConversionsIncGen)
-
 add_mlir_dialect(LLVMArmSVE llvm_arm_sve LLVMArmSVE)
 add_mlir_doc(LLVMArmSVE -gen-dialect-doc LLVMArmSve Dialects/)
 set(LLVM_TARGET_DEFINITIONS LLVMArmSVE.td)

diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMArmNeon.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMArmNeon.td
deleted file mode 100644
index f15c77451cbe..000000000000
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMArmNeon.td
+++ /dev/null
@@ -1,43 +0,0 @@
-//===-- LLVMArmNeon.td - LLVMArmNeon dialect op definitions *- tablegen -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the basic operations for the LLVMArmNeon dialect.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVMIR_ARMNEON_OPS
-#define LLVMIR_ARMNEON_OPS
-
-include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
-
-//===----------------------------------------------------------------------===//
-// LLVMArmNeon dialect definition
-//===----------------------------------------------------------------------===//
-
-def LLVMArmNeon_Dialect : Dialect {
-  let name = "llvm_arm_neon";
-  let cppNamespace = "::mlir::LLVM";
-}
-
-//----------------------------------------------------------------------------//
-// MLIR LLVMArmNeon intrinsics using the MLIR LLVM Dialect type system
-//----------------------------------------------------------------------------//
-
-class LLVMArmNeon_IntrBinaryOverloadedOp<string mnemonic, list<OpTrait> traits = []> :
-  LLVM_IntrOpBase</*Dialect dialect=*/LLVMArmNeon_Dialect,
-                  /*string opName=*/mnemonic,
-                  /*string enumName=*/"aarch64_neon_" # !subst(".", "_", mnemonic),
-                  /*list<int> overloadedResults=*/[0],
-                  /*list<int> overloadedOperands=*/[], // defined by result overload
-                  /*list<OpTrait> traits=*/traits,
-                  /*int numResults=*/1>;
-
-def LLVM_aarch64_arm_neon_smull :
-  LLVMArmNeon_IntrBinaryOverloadedOp<"smull">, Arguments<(ins LLVM_Type, LLVM_Type)>;
-
-#endif // ARMNEON_OPS

diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMArmNeonDialect.h b/mlir/include/mlir/Dialect/LLVMIR/LLVMArmNeonDialect.h
deleted file mode 100644
index 4fa8c9796f89..000000000000
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMArmNeonDialect.h
+++ /dev/null
@@ -1,24 +0,0 @@
-//===- LLVMArmNeonDialect.h - MLIR Dialect for LLVMArmNeon ------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file declares the Target dialect for LLVMArmNeon in MLIR.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef MLIR_DIALECT_LLVMIR_LLVMARMNEONDIALECT_H_
-#define MLIR_DIALECT_LLVMIR_LLVMARMNEONDIALECT_H_
-
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/OpDefinition.h"
-
-#define GET_OP_CLASSES
-#include "mlir/Dialect/LLVMIR/LLVMArmNeon.h.inc"
-
-#include "mlir/Dialect/LLVMIR/LLVMArmNeonDialect.h.inc"
-
-#endif // MLIR_DIALECT_LLVMIR_LLVMARMNEONDIALECT_H_

diff  --git a/mlir/include/mlir/InitAllDialects.h b/mlir/include/mlir/InitAllDialects.h
index e9e11dac4152..c1e2a7c31bb0 100644
--- a/mlir/include/mlir/InitAllDialects.h
+++ b/mlir/include/mlir/InitAllDialects.h
@@ -22,7 +22,6 @@
 #include "mlir/Dialect/Complex/IR/Complex.h"
 #include "mlir/Dialect/GPU/GPUDialect.h"
 #include "mlir/Dialect/LLVMIR/LLVMAVX512Dialect.h"
-#include "mlir/Dialect/LLVMIR/LLVMArmNeonDialect.h"
 #include "mlir/Dialect/LLVMIR/LLVMArmSVEDialect.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/Dialect/LLVMIR/NVVMDialect.h"
@@ -58,7 +57,6 @@ inline void registerAllDialects(DialectRegistry &registry) {
                   gpu::GPUDialect,
                   LLVM::LLVMAVX512Dialect,
                   LLVM::LLVMDialect,
-                  LLVM::LLVMArmNeonDialect,
                   LLVM::LLVMArmSVEDialect,
                   linalg::LinalgDialect,
                   math::MathDialect,

diff  --git a/mlir/include/mlir/Target/LLVMIR/Dialect/All.h b/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
index 21df7c85fcab..d07e1fa8df47 100644
--- a/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
+++ b/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
@@ -14,8 +14,8 @@
 #ifndef MLIR_TARGET_LLVMIR_DIALECT_ALL_H
 #define MLIR_TARGET_LLVMIR_DIALECT_ALL_H
 
+#include "mlir/Target/LLVMIR/Dialect/ArmNeon/ArmNeonToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/LLVMAVX512/LLVMAVX512ToLLVMIRTranslation.h"
-#include "mlir/Target/LLVMIR/Dialect/LLVMArmNeon/LLVMArmNeonToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/LLVMArmSVE/LLVMArmSVEToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.h"
@@ -28,8 +28,8 @@ class DialectRegistry;
 /// Registers all dialects that can be translated to LLVM IR and the
 /// corresponding translation interfaces.
 static inline void registerAllToLLVMIRTranslations(DialectRegistry &registry) {
+  registerArmNeonDialectTranslation(registry);
   registerLLVMAVX512DialectTranslation(registry);
-  registerLLVMArmNeonDialectTranslation(registry);
   registerLLVMArmSVEDialectTranslation(registry);
   registerLLVMDialectTranslation(registry);
   registerNVVMDialectTranslation(registry);

diff  --git a/mlir/include/mlir/Target/LLVMIR/Dialect/LLVMArmNeon/LLVMArmNeonToLLVMIRTranslation.h b/mlir/include/mlir/Target/LLVMIR/Dialect/ArmNeon/ArmNeonToLLVMIRTranslation.h
similarity index 57%
rename from mlir/include/mlir/Target/LLVMIR/Dialect/LLVMArmNeon/LLVMArmNeonToLLVMIRTranslation.h
rename to mlir/include/mlir/Target/LLVMIR/Dialect/ArmNeon/ArmNeonToLLVMIRTranslation.h
index daa7441e9711..eb2b5ca2fe90 100644
--- a/mlir/include/mlir/Target/LLVMIR/Dialect/LLVMArmNeon/LLVMArmNeonToLLVMIRTranslation.h
+++ b/mlir/include/mlir/Target/LLVMIR/Dialect/ArmNeon/ArmNeonToLLVMIRTranslation.h
@@ -1,4 +1,4 @@
-//===- LLVMArmNeonToLLVMIRTranslation.h - LLVMArmNeon to LLVMIR -*- C++ -*-===//
+//===- ArmNeonToLLVMIRTranslation.h - ArmNeon to LLVMIR ---------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,13 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This provides registration calls for LLVMArmNeon dialect to LLVM IR
-// translation.
+// This provides registration calls for ArmNeon dialect to LLVM IR translation.
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef MLIR_TARGET_LLVMIR_DIALECT_LLVMARMNEON_LLVMARMNEONTOLLVMIRTRANSLATION_H
-#define MLIR_TARGET_LLVMIR_DIALECT_LLVMARMNEON_LLVMARMNEONTOLLVMIRTRANSLATION_H
+#ifndef MLIR_TARGET_LLVMIR_DIALECT_ARMNEON_ARMNEONTOLLVMIRTRANSLATION_H
+#define MLIR_TARGET_LLVMIR_DIALECT_ARMNEON_ARMNEONTOLLVMIRTRANSLATION_H
 
 namespace mlir {
 
@@ -21,12 +20,12 @@ class MLIRContext;
 
 /// Register the LLVMArmNeon dialect and the translation from it to the LLVM IR
 /// in the given registry;
-void registerLLVMArmNeonDialectTranslation(DialectRegistry &registry);
+void registerArmNeonDialectTranslation(DialectRegistry &registry);
 
 /// Register the LLVMArmNeon dialect and the translation from it in the registry
 /// associated with the given context.
-void registerLLVMArmNeonDialectTranslation(MLIRContext &context);
+void registerArmNeonDialectTranslation(MLIRContext &context);
 
 } // namespace mlir
 
-#endif // MLIR_TARGET_LLVMIR_DIALECT_LLVMARMNEON_LLVMARMNEONTOLLVMIRTRANSLATION_H
+#endif // MLIR_TARGET_LLVMIR_DIALECT_ARMNEON_ARMNEONTOLLVMIRTRANSLATION_H

diff  --git a/mlir/lib/Conversion/ArmNeonToLLVM/ArmNeonToLLVM.cpp b/mlir/lib/Conversion/ArmNeonToLLVM/ArmNeonToLLVM.cpp
deleted file mode 100644
index c3c815591df7..000000000000
--- a/mlir/lib/Conversion/ArmNeonToLLVM/ArmNeonToLLVM.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-//===- ArmNeonToLLVM.cpp - ArmNeon to the LLVM dialect --------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "mlir/Conversion/ArmNeonToLLVM/ArmNeonToLLVM.h"
-
-#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
-#include "mlir/Dialect/ArmNeon/ArmNeonDialect.h"
-#include "mlir/Dialect/LLVMIR/LLVMArmNeonDialect.h"
-#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
-#include "mlir/Dialect/StandardOps/IR/Ops.h"
-#include "mlir/Dialect/Vector/VectorOps.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/IR/PatternMatch.h"
-
-using namespace mlir;
-using namespace mlir::vector;
-using namespace mlir::arm_neon;
-
-using SMullOpLowering =
-    OneToOneConvertToLLVMPattern<SMullOp, LLVM::aarch64_arm_neon_smull>;
-
-/// Populate the given list with patterns that convert from ArmNeon to LLVM.
-void mlir::populateArmNeonToLLVMConversionPatterns(
-    LLVMTypeConverter &converter, OwningRewritePatternList &patterns) {
-  patterns.insert<SMullOpLowering>(converter);
-}

diff  --git a/mlir/lib/Conversion/ArmNeonToLLVM/CMakeLists.txt b/mlir/lib/Conversion/ArmNeonToLLVM/CMakeLists.txt
deleted file mode 100644
index de028f6322a6..000000000000
--- a/mlir/lib/Conversion/ArmNeonToLLVM/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-add_mlir_conversion_library(MLIRArmNeonToLLVM
-  ArmNeonToLLVM.cpp
-
-  ADDITIONAL_HEADER_DIRS
-  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/ArmNeonToLLVM
-
-  DEPENDS
-  MLIRConversionPassIncGen
-
-  LINK_COMPONENTS
-  Core
-
-  LINK_LIBS PUBLIC
-  MLIRArmNeon
-  MLIRLLVMArmNeon
-  MLIRLLVMIR
-  MLIRStandardToLLVM
-  MLIRTransforms
-  )

diff  --git a/mlir/lib/Conversion/CMakeLists.txt b/mlir/lib/Conversion/CMakeLists.txt
index 2f8008489df5..d17ef3cf3e2e 100644
--- a/mlir/lib/Conversion/CMakeLists.txt
+++ b/mlir/lib/Conversion/CMakeLists.txt
@@ -1,5 +1,4 @@
 add_subdirectory(AffineToStandard)
-add_subdirectory(ArmNeonToLLVM)
 add_subdirectory(AsyncToLLVM)
 add_subdirectory(AVX512ToLLVM)
 add_subdirectory(ComplexToLLVM)

diff  --git a/mlir/lib/Conversion/PassDetail.h b/mlir/lib/Conversion/PassDetail.h
index 7c1db73d486a..aa05bcd9bc43 100644
--- a/mlir/lib/Conversion/PassDetail.h
+++ b/mlir/lib/Conversion/PassDetail.h
@@ -29,7 +29,6 @@ class GPUModuleOp;
 } // end namespace gpu
 
 namespace LLVM {
-class LLVMArmNeonDialect;
 class LLVMArmSVEDialect;
 class LLVMAVX512Dialect;
 class LLVMDialect;

diff  --git a/mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt b/mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt
index e2123c3287b2..e15c3793eb3d 100644
--- a/mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt
+++ b/mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt
@@ -14,10 +14,8 @@ add_mlir_conversion_library(MLIRVectorToLLVM
 
   LINK_LIBS PUBLIC
   MLIRArmNeon
-  MLIRArmNeonToLLVM
   MLIRAVX512
   MLIRAVX512ToLLVM
-  MLIRLLVMArmNeon
   MLIRLLVMAVX512
   MLIRArmSVE
   MLIRArmSVEToLLVM

diff  --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
index 0657361c7c73..686ee82e450a 100644
--- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
+++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
@@ -11,7 +11,6 @@
 #include "../PassDetail.h"
 
 #include "mlir/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.h"
-#include "mlir/Conversion/ArmNeonToLLVM/ArmNeonToLLVM.h"
 #include "mlir/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.h"
 #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
 #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h"
@@ -19,7 +18,6 @@
 #include "mlir/Dialect/ArmNeon/ArmNeonDialect.h"
 #include "mlir/Dialect/ArmSVE/ArmSVEDialect.h"
 #include "mlir/Dialect/LLVMIR/LLVMAVX512Dialect.h"
-#include "mlir/Dialect/LLVMIR/LLVMArmNeonDialect.h"
 #include "mlir/Dialect/LLVMIR/LLVMArmSVEDialect.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/Dialect/StandardOps/IR/Ops.h"
@@ -43,7 +41,7 @@ struct LowerVectorToLLVMPass
   void getDependentDialects(DialectRegistry &registry) const override {
     registry.insert<LLVM::LLVMDialect>();
     if (enableArmNeon)
-      registry.insert<LLVM::LLVMArmNeonDialect>();
+      registry.insert<arm_neon::ArmNeonDialect>();
     if (enableArmSVE)
       registry.insert<LLVM::LLVMArmSVEDialect>();
     if (enableAVX512)
@@ -78,9 +76,10 @@ void LowerVectorToLLVMPass::runOnOperation() {
   target.addLegalDialect<StandardOpsDialect>();
   target.addLegalOp<UnrealizedConversionCastOp>();
   if (enableArmNeon) {
-    target.addLegalDialect<LLVM::LLVMArmNeonDialect>();
-    target.addIllegalDialect<arm_neon::ArmNeonDialect>();
-    populateArmNeonToLLVMConversionPatterns(converter, patterns);
+    // TODO: we may or may not want to include in-dialect lowering to
+    // LLVM-compatible operations here. So far, all operations in the dialect
+    // can be translated to LLVM IR so there is no conversion necessary.
+    target.addLegalDialect<arm_neon::ArmNeonDialect>();
   }
   if (enableArmSVE) {
     target.addLegalDialect<LLVM::LLVMArmSVEDialect>();

diff  --git a/mlir/lib/Dialect/LLVMIR/CMakeLists.txt b/mlir/lib/Dialect/LLVMIR/CMakeLists.txt
index 337e3c48d1fc..1b6e4212861f 100644
--- a/mlir/lib/Dialect/LLVMIR/CMakeLists.txt
+++ b/mlir/lib/Dialect/LLVMIR/CMakeLists.txt
@@ -50,27 +50,6 @@ add_mlir_dialect_library(MLIRLLVMAVX512
   MLIRSideEffectInterfaces
   )
 
-add_mlir_dialect_library(MLIRLLVMArmNeon
-  IR/LLVMArmNeonDialect.cpp
-
-  ADDITIONAL_HEADER_DIRS
-  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LLVMIR
-
-  DEPENDS
-  MLIRLLVMArmNeonIncGen
-  MLIRLLVMArmNeonConversionsIncGen
-  intrinsics_gen
-
-  LINK_COMPONENTS
-  AsmParser
-  Core
-
-  LINK_LIBS PUBLIC
-  MLIRIR
-  MLIRLLVMIR
-  MLIRSideEffectInterfaces
-  )
-
 add_mlir_dialect_library(MLIRLLVMArmSVE
   IR/LLVMArmSVEDialect.cpp
 

diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMArmNeonDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMArmNeonDialect.cpp
deleted file mode 100644
index d05b6584c39f..000000000000
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMArmNeonDialect.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-//===- LLVMArmNeonDialect.cpp - MLIR LLVMArmNeon ops implementation -------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the LLVMArmNeon dialect and its operations.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/IR/IntrinsicsAArch64.h"
-
-#include "mlir/Dialect/LLVMIR/LLVMArmNeonDialect.h"
-#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
-#include "mlir/IR/Builders.h"
-#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/TypeUtilities.h"
-
-using namespace mlir;
-
-void LLVM::LLVMArmNeonDialect::initialize() {
-  addOperations<
-#define GET_OP_LIST
-#include "mlir/Dialect/LLVMIR/LLVMArmNeon.cpp.inc"
-      >();
-}
-
-#define GET_OP_CLASSES
-#include "mlir/Dialect/LLVMIR/LLVMArmNeon.cpp.inc"

diff  --git a/mlir/lib/Target/LLVMIR/CMakeLists.txt b/mlir/lib/Target/LLVMIR/CMakeLists.txt
index 4c6863259639..162d2c42a19b 100644
--- a/mlir/lib/Target/LLVMIR/CMakeLists.txt
+++ b/mlir/lib/Target/LLVMIR/CMakeLists.txt
@@ -36,7 +36,7 @@ add_mlir_translation_library(MLIRToLLVMIRTranslationRegistration
   ConvertToLLVMIR.cpp
 
   LINK_LIBS PUBLIC
-  MLIRLLVMArmNeonToLLVMIRTranslation
+  MLIRArmNeonToLLVMIRTranslation
   MLIRLLVMArmSVEToLLVMIRTranslation
   MLIRLLVMAVX512ToLLVMIRTranslation
   MLIRLLVMToLLVMIRTranslation

diff  --git a/mlir/lib/Target/LLVMIR/Dialect/LLVMArmNeon/LLVMArmNeonToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/ArmNeon/ArmNeonToLLVMIRTranslation.cpp
similarity index 62%
rename from mlir/lib/Target/LLVMIR/Dialect/LLVMArmNeon/LLVMArmNeonToLLVMIRTranslation.cpp
rename to mlir/lib/Target/LLVMIR/Dialect/ArmNeon/ArmNeonToLLVMIRTranslation.cpp
index f8a175baa78a..679fda67a440 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/LLVMArmNeon/LLVMArmNeonToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/ArmNeon/ArmNeonToLLVMIRTranslation.cpp
@@ -1,4 +1,4 @@
-//===- LLVMArmNeonToLLVMIRTranslation.cpp - LLVMArmNeon to LLVM IR --------===//
+//===- ArmNeonToLLVMIRTranslation.cpp - Translate ArmNeon to LLVM IR ------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,13 +6,13 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This file implements a translation between the MLIR LLVMArmNeon dialect and
+// This file implements a translation between the MLIR ArmNeon dialect and
 // LLVM IR.
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Target/LLVMIR/Dialect/LLVMArmNeon/LLVMArmNeonToLLVMIRTranslation.h"
-#include "mlir/Dialect/LLVMIR/LLVMArmNeonDialect.h"
+#include "mlir/Target/LLVMIR/Dialect/ArmNeon/ArmNeonToLLVMIRTranslation.h"
+#include "mlir/Dialect/ArmNeon/ArmNeonDialect.h"
 #include "mlir/IR/Operation.h"
 #include "mlir/Target/LLVMIR/ModuleTranslation.h"
 
@@ -25,7 +25,7 @@ using namespace mlir::LLVM;
 namespace {
 /// Implementation of the dialect interface that converts operations belonging
 /// to the LLVMArmNeon dialect to LLVM IR.
-class LLVMArmNeonDialectLLVMIRTranslationInterface
+class ArmNeonDialectLLVMIRTranslationInterface
     : public LLVMTranslationDialectInterface {
 public:
   using LLVMTranslationDialectInterface::LLVMTranslationDialectInterface;
@@ -36,21 +36,21 @@ class LLVMArmNeonDialectLLVMIRTranslationInterface
   convertOperation(Operation *op, llvm::IRBuilderBase &builder,
                    LLVM::ModuleTranslation &moduleTranslation) const final {
     Operation &opInst = *op;
-#include "mlir/Dialect/LLVMIR/LLVMArmNeonConversions.inc"
+#include "mlir/Dialect/ArmNeon/ArmNeonConversions.inc"
 
     return failure();
   }
 };
 } // end namespace
 
-void mlir::registerLLVMArmNeonDialectTranslation(DialectRegistry &registry) {
-  registry.insert<LLVM::LLVMArmNeonDialect>();
-  registry.addDialectInterface<LLVM::LLVMArmNeonDialect,
-                               LLVMArmNeonDialectLLVMIRTranslationInterface>();
+void mlir::registerArmNeonDialectTranslation(DialectRegistry &registry) {
+  registry.insert<arm_neon::ArmNeonDialect>();
+  registry.addDialectInterface<arm_neon::ArmNeonDialect,
+                               ArmNeonDialectLLVMIRTranslationInterface>();
 }
 
-void mlir::registerLLVMArmNeonDialectTranslation(MLIRContext &context) {
+void mlir::registerArmNeonDialectTranslation(MLIRContext &context) {
   DialectRegistry registry;
-  registerLLVMArmNeonDialectTranslation(registry);
+  registerArmNeonDialectTranslation(registry);
   context.appendDialectRegistry(registry);
 }

diff  --git a/mlir/lib/Target/LLVMIR/Dialect/ArmNeon/CMakeLists.txt b/mlir/lib/Target/LLVMIR/Dialect/ArmNeon/CMakeLists.txt
new file mode 100644
index 000000000000..887ba8d9e22b
--- /dev/null
+++ b/mlir/lib/Target/LLVMIR/Dialect/ArmNeon/CMakeLists.txt
@@ -0,0 +1,16 @@
+add_mlir_translation_library(MLIRArmNeonToLLVMIRTranslation
+  ArmNeonToLLVMIRTranslation.cpp
+
+  DEPENDS
+  MLIRArmNeonConversionsIncGen
+
+  LINK_COMPONENTS
+  Core
+
+  LINK_LIBS PUBLIC
+  MLIRArmNeon
+  MLIRIR
+  MLIRLLVMIR
+  MLIRSupport
+  MLIRTargetLLVMIRExport
+  )

diff  --git a/mlir/lib/Target/LLVMIR/Dialect/CMakeLists.txt b/mlir/lib/Target/LLVMIR/Dialect/CMakeLists.txt
index 36a28b87403b..d115b13d7123 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/CMakeLists.txt
+++ b/mlir/lib/Target/LLVMIR/Dialect/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_subdirectory(LLVMArmNeon)
+add_subdirectory(ArmNeon)
 add_subdirectory(LLVMArmSVE)
 add_subdirectory(LLVMAVX512)
 add_subdirectory(LLVMIR)

diff  --git a/mlir/lib/Target/LLVMIR/Dialect/LLVMArmNeon/CMakeLists.txt b/mlir/lib/Target/LLVMIR/Dialect/LLVMArmNeon/CMakeLists.txt
deleted file mode 100644
index 634e775c4390..000000000000
--- a/mlir/lib/Target/LLVMIR/Dialect/LLVMArmNeon/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-add_mlir_translation_library(MLIRLLVMArmNeonToLLVMIRTranslation
-  LLVMArmNeonToLLVMIRTranslation.cpp
-
-  DEPENDS
-  MLIRLLVMArmNeonConversionsIncGen
-
-  LINK_COMPONENTS
-  Core
-
-  LINK_LIBS PUBLIC
-  MLIRIR
-  MLIRLLVMArmNeon
-  MLIRLLVMIR
-  MLIRSupport
-  MLIRTargetLLVMIRExport
-  )

diff  --git a/mlir/test/Conversion/ArmNeonToLLVM/convert-to-llvm.mlir b/mlir/test/Conversion/ArmNeonToLLVM/convert-to-llvm.mlir
deleted file mode 100644
index d95abf4dd50e..000000000000
--- a/mlir/test/Conversion/ArmNeonToLLVM/convert-to-llvm.mlir
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: mlir-opt %s -convert-vector-to-llvm="enable-arm-neon" | mlir-opt | FileCheck %s
-
-// CHECK-LABEL: arm_neon_smull
-func @arm_neon_smull(%a: vector<8xi8>, %b: vector<8xi8>)
-    -> (vector<8xi16>, vector<4xi32>, vector<2xi64>) {
-  // CHECK: arm_neon.smull{{.*}}: (vector<8xi8>, vector<8xi8>) -> vector<8xi16>
-  %0 = arm_neon.smull %a, %b : vector<8xi8> to vector<8xi16>
-  %00 = vector.extract_strided_slice %0 {offsets = [3], sizes = [4], strides = [1]}:
-    vector<8xi16> to vector<4xi16>
-
-  // CHECK: arm_neon.smull{{.*}}: (vector<4xi16>, vector<4xi16>) -> vector<4xi32>
-  %1 = arm_neon.smull %00, %00 : vector<4xi16> to vector<4xi32>
-  %11 = vector.extract_strided_slice %1 {offsets = [1], sizes = [2], strides = [1]}:
-    vector<4xi32> to vector<2xi32>
-
-  // CHECK: arm_neon.smull{{.*}}: (vector<2xi32>, vector<2xi32>) -> vector<2xi64>
-  %2 = arm_neon.smull %11, %11 : vector<2xi32> to vector<2xi64>
-
-  return %0, %1, %2 : vector<8xi16>, vector<4xi32>, vector<2xi64>
-}

diff  --git a/mlir/test/Target/arm-neon.mlir b/mlir/test/Target/arm-neon.mlir
index 04627a087d35..3cd7641c5798 100644
--- a/mlir/test/Target/arm-neon.mlir
+++ b/mlir/test/Target/arm-neon.mlir
@@ -4,16 +4,16 @@
 llvm.func @arm_neon_smull(%arg0: vector<8xi8>, %arg1: vector<8xi8>) -> !llvm.struct<(vector<8xi16>, vector<4xi32>, vector<2xi64>)> {
   //      CHECK: %[[V0:.*]] = call <8 x i16> @llvm.aarch64.neon.smull.v8i16(<8 x i8> %{{.*}}, <8 x i8> %{{.*}})
   // CHECK-NEXT: %[[V00:.*]] = shufflevector <8 x i16> %3, <8 x i16> %[[V0]], <4 x i32> <i32 3, i32 4, i32 5, i32 6>
-  %0 = "llvm_arm_neon.smull"(%arg0, %arg1) : (vector<8xi8>, vector<8xi8>) -> vector<8xi16>
+  %0 = arm_neon.smull %arg0, %arg1 : vector<8xi8> to vector<8xi16>
   %1 = llvm.shufflevector %0, %0 [3, 4, 5, 6] : vector<8xi16>, vector<8xi16>
 
   // CHECK-NEXT: %[[V1:.*]] = call <4 x i32> @llvm.aarch64.neon.smull.v4i32(<4 x i16> %[[V00]], <4 x i16> %[[V00]])
   // CHECK-NEXT: %[[V11:.*]] = shufflevector <4 x i32> %[[V1]], <4 x i32> %[[V1]], <2 x i32> <i32 1, i32 2>
-  %2 = "llvm_arm_neon.smull"(%1, %1) : (vector<4xi16>, vector<4xi16>) -> vector<4xi32>
+  %2 = arm_neon.smull %1, %1 : vector<4xi16> to vector<4xi32>
   %3 = llvm.shufflevector %2, %2 [1, 2] : vector<4xi32>, vector<4xi32>
 
   // CHECK-NEXT: %[[V1:.*]] = call <2 x i64> @llvm.aarch64.neon.smull.v2i64(<2 x i32> %[[V11]], <2 x i32> %[[V11]])
-  %4 = "llvm_arm_neon.smull"(%3, %3) : (vector<2xi32>, vector<2xi32>) -> vector<2xi64>
+  %4 = arm_neon.smull %3, %3 : vector<2xi32> to vector<2xi64>
 
   %5 = llvm.mlir.undef : !llvm.struct<(vector<8xi16>, vector<4xi32>, vector<2xi64>)>
   %6 = llvm.insertvalue %0, %5[0] : !llvm.struct<(vector<8xi16>, vector<4xi32>, vector<2xi64>)>

diff  --git a/mlir/test/mlir-opt/commandline.mlir b/mlir/test/mlir-opt/commandline.mlir
index 9e73ba2c775a..467f10af0804 100644
--- a/mlir/test/mlir-opt/commandline.mlir
+++ b/mlir/test/mlir-opt/commandline.mlir
@@ -10,7 +10,6 @@
 // CHECK-NEXT: gpu
 // CHECK-NEXT: linalg
 // CHECK-NEXT: llvm
-// CHECK-NEXT: llvm_arm_neon
 // CHECK-NEXT: llvm_arm_sve
 // CHECK-NEXT: llvm_avx512
 // CHECK-NEXT: math


        


More information about the Mlir-commits mailing list