//===- X86TransformOps.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "mlir/Dialect/X86/TransformOps/X86TransformOps.h"
#include "mlir/Conversion/LLVMCommon/TypeConverter.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/Transform/IR/TransformDialect.h"
#include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/Dialect/X86/Transforms.h"
#include "mlir/Dialect/X86/X86Dialect.h"

#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/RegionKindInterface.h"

using namespace mlir;
using namespace mlir::x86;
using namespace mlir::transform;

void mlir::transform::ApplyVectorContractToFMAPatternsOp::populatePatterns(
    RewritePatternSet &patterns) {
  x86::populateVectorContractToFMAPatterns(patterns);
}

void mlir::transform::ApplyVectorContractToPackedTypeDotProductPatternsOp::
    populatePatterns(RewritePatternSet &patterns) {
  x86::populateVectorContractToPackedTypeDotProductPatterns(patterns);
}

void mlir::transform::ApplyVectorContractBF16ToFMAPatternsOp::populatePatterns(
    RewritePatternSet &patterns) {
  x86::populateVectorContractBF16ToFMAPatterns(patterns);
}

void mlir::transform::ApplySinkVectorProducerOpsPatternsOp::populatePatterns(
    RewritePatternSet &patterns) {
  x86::populateSinkVectorProducerOpsPatterns(patterns);
}

void mlir::transform::ApplyShuffleVectorFMAOpsPatternsOp::populatePatterns(
    RewritePatternSet &patterns) {
  x86::populateShuffleVectorFMAOpsPatterns(patterns);
}

void mlir::transform::ApplyVectorContractToAMXDotProductPatternsOp::
    populatePatterns(RewritePatternSet &patterns) {
  x86::populateVectorContractToAMXDotProductPatterns(patterns);
}

//===----------------------------------------------------------------------===//
// Transform op registration
//===----------------------------------------------------------------------===//

namespace {
class X86TransformDialectExtension
    : public transform::TransformDialectExtension<
          X86TransformDialectExtension> {
public:
  MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(X86TransformDialectExtension)

  X86TransformDialectExtension() {
    declareGeneratedDialect<x86::X86Dialect>();
    declareGeneratedDialect<LLVM::LLVMDialect>();
    registerTransformOps<
#define GET_OP_LIST
#include "mlir/Dialect/X86/TransformOps/X86TransformOps.cpp.inc"
        >();
  }
};
} // namespace

#define GET_OP_CLASSES
#include "mlir/Dialect/X86/TransformOps/X86TransformOps.cpp.inc"

void mlir::x86::registerTransformDialectExtension(DialectRegistry &registry) {
  registry.addExtensions<X86TransformDialectExtension>();
}
