llvm/mlir/unittests/Target/LLVM/SerializeToLLVMBitcode.cpp

//===- SerializeToLLVMBitcode.cpp -------------------------------*- C++ -*-===//
//
// This file is licensed 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/GPU/IR/GPUDialect.h"
#include "mlir/IR/BuiltinDialect.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/Parser/Parser.h"
#include "mlir/Target/LLVM/ModuleToObject.h"
#include "mlir/Target/LLVMIR/Dialect/Builtin/BuiltinToLLVMIRTranslation.h"
#include "mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.h"

#include "llvm/IRReader/IRReader.h"
#include "llvm/Support/MemoryBufferRef.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"

#include "gmock/gmock.h"

usingnamespacemlir;

// Skip the test if the native target was not built.
#if LLVM_NATIVE_TARGET_TEST_ENABLED == 0
#define SKIP_WITHOUT_NATIVE
#else
#define SKIP_WITHOUT_NATIVE(x)
#endif

namespace {
// Dummy interface for testing.
class TargetAttrImpl
    : public gpu::TargetAttrInterface::FallbackModel<TargetAttrImpl> {};
} // namespace

class MLIRTargetLLVM : public ::testing::Test {};

TEST_F(MLIRTargetLLVM, SKIP_WITHOUT_NATIVE(SerializeToLLVMBitcode)) {}

std::optional<SmallVector<char, 0>>
TargetAttrImpl::serializeToObject(Attribute attribute, Operation *module,
                                  const gpu::TargetOptions &options) const {}

Attribute
TargetAttrImpl::createObject(Attribute attribute, Operation *module,
                             const SmallVector<char, 0> &object,
                             const gpu::TargetOptions &options) const {}

// This test checks the correct functioning of `TargetAttrInterface` as an API.
// In particular, it shows how `TargetAttrInterface::createObject` can leverage
// the `module` operation argument to retrieve information from the module.
TEST_F(MLIRTargetLLVM, SKIP_WITHOUT_NATIVE(TargetAttrAPI)) {}