[SampleProfileLoader] Fix integer overflow in generateMDProfMetadata (#90217)
[llvm-project.git] / mlir / lib / Target / LLVMIR / Dialect / X86Vector / X86VectorToLLVMIRTranslation.cpp
blobfa5f61420ee8a9632e5c32021377ff1358b513c0
1 //===- X86VectorToLLVMIRTranslation.cpp - Translate X86Vector 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 MLIR X86Vector dialect and
10 // LLVM IR.
12 //===----------------------------------------------------------------------===//
14 #include "mlir/Target/LLVMIR/Dialect/X86Vector/X86VectorToLLVMIRTranslation.h"
15 #include "mlir/Dialect/X86Vector/X86VectorDialect.h"
16 #include "mlir/IR/Operation.h"
17 #include "mlir/Target/LLVMIR/ModuleTranslation.h"
19 #include "llvm/IR/IRBuilder.h"
20 #include "llvm/IR/IntrinsicsX86.h"
22 using namespace mlir;
23 using namespace mlir::LLVM;
25 namespace {
26 /// Implementation of the dialect interface that converts operations belonging
27 /// to the X86Vector dialect to LLVM IR.
28 class X86VectorDialectLLVMIRTranslationInterface
29 : public LLVMTranslationDialectInterface {
30 public:
31 using LLVMTranslationDialectInterface::LLVMTranslationDialectInterface;
33 /// Translates the given operation to LLVM IR using the provided IR builder
34 /// and saving the state in `moduleTranslation`.
35 LogicalResult
36 convertOperation(Operation *op, llvm::IRBuilderBase &builder,
37 LLVM::ModuleTranslation &moduleTranslation) const final {
38 Operation &opInst = *op;
39 #include "mlir/Dialect/X86Vector/X86VectorConversions.inc"
41 return failure();
44 } // namespace
46 void mlir::registerX86VectorDialectTranslation(DialectRegistry &registry) {
47 registry.insert<x86vector::X86VectorDialect>();
48 registry.addExtension(
49 +[](MLIRContext *ctx, x86vector::X86VectorDialect *dialect) {
50 dialect->addInterfaces<X86VectorDialectLLVMIRTranslationInterface>();
51 });
54 void mlir::registerX86VectorDialectTranslation(MLIRContext &context) {
55 DialectRegistry registry;
56 registerX86VectorDialectTranslation(registry);
57 context.appendDialectRegistry(registry);