llvm/mlir/unittests/Interfaces/DataLayoutInterfacesTest.cpp

//===- DataLayoutInterfacesTest.cpp - Unit Tests for Data Layouts ---------===//
//
// 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/Interfaces/DataLayoutInterfaces.h"
#include "mlir/Dialect/DLTI/DLTI.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/Parser/Parser.h"

#include <gtest/gtest.h>

usingnamespacemlir;

namespace {
constexpr static llvm::StringLiteral kAttrName =;
constexpr static llvm::StringLiteral kEndiannesKeyName =;
constexpr static llvm::StringLiteral kAllocaKeyName =;
constexpr static llvm::StringLiteral kProgramKeyName =;
constexpr static llvm::StringLiteral kGlobalKeyName =;
constexpr static llvm::StringLiteral kStackAlignmentKeyName =;

constexpr static llvm::StringLiteral kTargetSystemDescAttrName =;

/// Trivial array storage for the custom data layout spec attribute, just a list
/// of entries.
class DataLayoutSpecStorage : public AttributeStorage {};

/// Simple data layout spec containing a list of entries that always verifies
/// as valid.
struct CustomDataLayoutSpec
    : public Attribute::AttrBase<
          CustomDataLayoutSpec, Attribute, DataLayoutSpecStorage,
          DLTIQueryInterface::Trait, DataLayoutSpecInterface::Trait> {};

class TargetSystemSpecStorage : public AttributeStorage {};

struct CustomTargetSystemSpec
    : public Attribute::AttrBase<
          CustomTargetSystemSpec, Attribute, TargetSystemSpecStorage,
          DLTIQueryInterface::Trait, TargetSystemSpecInterface::Trait> {};

/// A type subject to data layout that exits the program if it is queried more
/// than once. Handy to check if the cache works.
struct SingleQueryType
    : public Type::TypeBase<SingleQueryType, Type, TypeStorage,
                            DataLayoutTypeInterface::Trait> {};

/// A types that is not subject to data layout.
struct TypeNoLayout : public Type::TypeBase<TypeNoLayout, Type, TypeStorage> {};

/// An op that serves as scope for data layout queries with the relevant
/// attribute attached. This can handle data layout requests for the built-in
/// types itself.
struct OpWithLayout : public Op<OpWithLayout, DataLayoutOpInterface::Trait> {};

struct OpWith7BitByte
    : public Op<OpWith7BitByte, DataLayoutOpInterface::Trait> {};

/// A dialect putting all the above together.
struct DLTestDialect : Dialect {};

/// A dialect to test DLTI's target system spec and related attributes
struct DLTargetSystemDescTestDialect : public Dialect {};

} // namespace

TEST(DataLayout, FallbackDefault) {}

TEST(DataLayout, NullSpec) {}

TEST(DataLayout, EmptySpec) {}

TEST(DataLayout, SpecWithEntries) {}

TEST(DataLayout, SpecWithTargetSystemDescEntries) {}

TEST(DataLayout, Caching) {}

TEST(DataLayout, CacheInvalidation) {}

TEST(DataLayout, UnimplementedTypeInterface) {}

TEST(DataLayout, SevenBitByte) {}