MLIR  19.0.0git
AMXToLLVMIRTranslation.cpp
Go to the documentation of this file.
1 //===- AMXToLLVMIRTranslation.cpp - Translate AMX 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 AMX dialect and LLVM IR.
10 //
11 //===----------------------------------------------------------------------===//
12 
15 #include "mlir/IR/Operation.h"
17 
18 #include "llvm/IR/IRBuilder.h"
19 #include "llvm/IR/IntrinsicsX86.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 AMX dialect to LLVM IR.
27 class AMXDialectLLVMIRTranslationInterface
29 public:
31 
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/AMX/AMXConversions.inc"
39 
40  return failure();
41  }
42 };
43 } // namespace
44 
46  registry.insert<amx::AMXDialect>();
47  registry.addExtension(+[](MLIRContext *ctx, amx::AMXDialect *dialect) {
48  dialect->addInterfaces<AMXDialectLLVMIRTranslationInterface>();
49  });
50 }
51 
53  DialectRegistry registry;
55  context.appendDialectRegistry(registry);
56 }
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
void addExtension(std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
Base class for dialect interfaces providing translation to LLVM IR.
Implementation class for module translation.
MLIRContext is the top-level object for a collection of MLIR operations.
Definition: MLIRContext.h:60
void appendDialectRegistry(const DialectRegistry &registry)
Append the contents of the given dialect registry to the registry associated with this context.
Operation is the basic unit of execution within MLIR.
Definition: Operation.h:88
Include the generated interface declarations.
void registerAMXDialectTranslation(DialectRegistry &registry)
Register the AMX dialect and the translation from it to the LLVM IR in the given registry;.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
Definition: LogicalResult.h:62
This class represents an efficient way to signal success or failure.
Definition: LogicalResult.h:26