xref: /llvm-project/mlir/lib/Target/LLVMIR/Dialect/ArmSVE/ArmSVEToLLVMIRTranslation.cpp (revision 7bbfd2aec048b23000d2ada6ed9220862b187f17)
1 //======- ArmSVEToLLVMIRTranslation.cpp - Translate ArmSVE to LLVM IR -=======//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements a translation between the ArmSVE dialect and LLVM IR.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "mlir/Target/LLVMIR/Dialect/ArmSVE/ArmSVEToLLVMIRTranslation.h"
14 #include "mlir/Dialect/ArmSVE/IR/ArmSVEDialect.h"
15 #include "mlir/IR/Operation.h"
16 #include "mlir/Target/LLVMIR/ModuleTranslation.h"
17 
18 #include "llvm/IR/IRBuilder.h"
19 #include "llvm/IR/IntrinsicsAArch64.h"
20 
21 using namespace mlir;
22 using namespace mlir::LLVM;
23 
24 namespace {
25 /// Implementation of the dialect interface that converts operations belonging
26 /// to the ArmSVE dialect to LLVM IR.
27 class ArmSVEDialectLLVMIRTranslationInterface
28     : public LLVMTranslationDialectInterface {
29 public:
30   using LLVMTranslationDialectInterface::LLVMTranslationDialectInterface;
31 
32   /// Translates the given operation to LLVM IR using the provided IR builder
33   /// and saving the state in `moduleTranslation`.
34   LogicalResult
convertOperation(Operation * op,llvm::IRBuilderBase & builder,LLVM::ModuleTranslation & moduleTranslation) const35   convertOperation(Operation *op, llvm::IRBuilderBase &builder,
36                    LLVM::ModuleTranslation &moduleTranslation) const final {
37     Operation &opInst = *op;
38 #include "mlir/Dialect/ArmSVE/IR/ArmSVEConversions.inc"
39 
40     return failure();
41   }
42 };
43 } // namespace
44 
registerArmSVEDialectTranslation(DialectRegistry & registry)45 void mlir::registerArmSVEDialectTranslation(DialectRegistry &registry) {
46   registry.insert<arm_sve::ArmSVEDialect>();
47   registry.addExtension(+[](MLIRContext *ctx, arm_sve::ArmSVEDialect *dialect) {
48     dialect->addInterfaces<ArmSVEDialectLLVMIRTranslationInterface>();
49   });
50 }
51 
registerArmSVEDialectTranslation(MLIRContext & context)52 void mlir::registerArmSVEDialectTranslation(MLIRContext &context) {
53   DialectRegistry registry;
54   registerArmSVEDialectTranslation(registry);
55   context.appendDialectRegistry(registry);
56 }
57