1 //======- ArmSMEToLLVMIRTranslation.cpp - Translate ArmSME 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 ArmSME dialect and LLVM IR.
11 //===----------------------------------------------------------------------===//
13 #include "mlir/Target/LLVMIR/Dialect/ArmSME/ArmSMEToLLVMIRTranslation.h"
14 #include "mlir/Dialect/ArmSME/IR/ArmSME.h"
15 #include "mlir/IR/Operation.h"
16 #include "mlir/Target/LLVMIR/ModuleTranslation.h"
18 #include "llvm/IR/IRBuilder.h"
19 #include "llvm/IR/IntrinsicsAArch64.h"
22 using namespace mlir::LLVM
;
25 /// Implementation of the dialect interface that converts operations belonging
26 /// to the ArmSME dialect to LLVM IR.
27 class ArmSMEDialectLLVMIRTranslationInterface
28 : public LLVMTranslationDialectInterface
{
30 using LLVMTranslationDialectInterface::LLVMTranslationDialectInterface
;
32 /// Translates the given operation to LLVM IR using the provided IR builder
33 /// and saving the state in `moduleTranslation`.
35 convertOperation(Operation
*op
, llvm::IRBuilderBase
&builder
,
36 LLVM::ModuleTranslation
&moduleTranslation
) const final
{
37 Operation
&opInst
= *op
;
38 #include "mlir/Dialect/ArmSME/IR/ArmSMEIntrinsicConversions.inc"
39 #include "mlir/Dialect/ArmSME/IR/ArmSMEOpsConversions.inc"
46 void mlir::registerArmSMEDialectTranslation(DialectRegistry
®istry
) {
47 registry
.insert
<arm_sme::ArmSMEDialect
>();
48 registry
.addExtension(+[](MLIRContext
*ctx
, arm_sme::ArmSMEDialect
*dialect
) {
49 dialect
->addInterfaces
<ArmSMEDialectLLVMIRTranslationInterface
>();
53 void mlir::registerArmSMEDialectTranslation(MLIRContext
&context
) {
54 DialectRegistry registry
;
55 registerArmSMEDialectTranslation(registry
);
56 context
.appendDialectRegistry(registry
);