1 //===- ArmNeonToLLVMIRTranslation.cpp - Translate ArmNeon to LLVM IR ------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements a translation between the MLIR ArmNeon dialect and
12 //===----------------------------------------------------------------------===//
14 #include "mlir/Target/LLVMIR/Dialect/ArmNeon/ArmNeonToLLVMIRTranslation.h"
15 #include "mlir/Dialect/ArmNeon/ArmNeonDialect.h"
16 #include "mlir/IR/Operation.h"
17 #include "mlir/Target/LLVMIR/ModuleTranslation.h"
19 #include "llvm/IR/IRBuilder.h"
20 #include "llvm/IR/IntrinsicsAArch64.h"
23 using namespace mlir::LLVM
;
26 /// Implementation of the dialect interface that converts operations belonging
27 /// to the ArmNeon dialect to LLVM IR.
28 class ArmNeonDialectLLVMIRTranslationInterface
29 : public LLVMTranslationDialectInterface
{
31 using LLVMTranslationDialectInterface::LLVMTranslationDialectInterface
;
33 /// Translates the given operation to LLVM IR using the provided IR builder
34 /// and saving the state in `moduleTranslation`.
36 convertOperation(Operation
*op
, llvm::IRBuilderBase
&builder
,
37 LLVM::ModuleTranslation
&moduleTranslation
) const final
{
38 Operation
&opInst
= *op
;
39 #include "mlir/Dialect/ArmNeon/ArmNeonConversions.inc"
46 void mlir::registerArmNeonDialectTranslation(DialectRegistry
®istry
) {
47 registry
.insert
<arm_neon::ArmNeonDialect
>();
48 registry
.addExtension(
49 +[](MLIRContext
*ctx
, arm_neon::ArmNeonDialect
*dialect
) {
50 dialect
->addInterfaces
<ArmNeonDialectLLVMIRTranslationInterface
>();
54 void mlir::registerArmNeonDialectTranslation(MLIRContext
&context
) {
55 DialectRegistry registry
;
56 registerArmNeonDialectTranslation(registry
);
57 context
.appendDialectRegistry(registry
);