Coverage Report

Created: 2020-06-26 05:44

/home/arjun/llvm-project/mlir/include/mlir/IR/TypeSupport.h
Line
Count
Source (jump to first uncovered line)
1
//===- TypeSupport.h --------------------------------------------*- C++ -*-===//
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 defines support types for registering dialect extended types.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef MLIR_IR_TYPE_SUPPORT_H
14
#define MLIR_IR_TYPE_SUPPORT_H
15
16
#include "mlir/IR/MLIRContext.h"
17
#include "mlir/IR/StorageUniquerSupport.h"
18
19
namespace mlir {
20
class Dialect;
21
class MLIRContext;
22
23
//===----------------------------------------------------------------------===//
24
// TypeStorage
25
//===----------------------------------------------------------------------===//
26
27
namespace detail {
28
class TypeUniquer;
29
} // end namespace detail
30
31
/// Base storage class appearing in a Type.
32
class TypeStorage : public StorageUniquer::BaseStorage {
33
  friend detail::TypeUniquer;
34
  friend StorageUniquer;
35
36
protected:
37
  /// This constructor is used by derived classes as part of the TypeUniquer.
38
  /// When using this constructor, the initializeDialect function must be
39
  /// invoked afterwards for the storage to be valid.
40
  TypeStorage(unsigned subclassData = 0)
41
0
      : dialect(nullptr), subclassData(subclassData) {}
42
43
public:
44
  /// Get the dialect that this type is registered to.
45
0
  Dialect &getDialect() {
46
0
    assert(dialect && "Malformed type storage object.");
47
0
    return *dialect;
48
0
  }
49
  /// Get the subclass data.
50
0
  unsigned getSubclassData() const { return subclassData; }
51
52
  /// Set the subclass data.
53
0
  void setSubclassData(unsigned val) { subclassData = val; }
54
55
private:
56
  // Set the dialect for this storage instance. This is used by the TypeUniquer
57
  // when initializing a newly constructed type storage object.
58
0
  void initializeDialect(Dialect &newDialect) { dialect = &newDialect; }
59
60
  /// The dialect for this type.
61
  Dialect *dialect;
62
63
  /// Space for subclasses to store data.
64
  unsigned subclassData;
65
};
66
67
/// Default storage type for types that require no additional initialization or
68
/// storage.
69
using DefaultTypeStorage = TypeStorage;
70
71
//===----------------------------------------------------------------------===//
72
// TypeStorageAllocator
73
//===----------------------------------------------------------------------===//
74
75
// This is a utility allocator used to allocate memory for instances of derived
76
// Types.
77
using TypeStorageAllocator = StorageUniquer::StorageAllocator;
78
79
//===----------------------------------------------------------------------===//
80
// TypeUniquer
81
//===----------------------------------------------------------------------===//
82
namespace detail {
83
// A utility class to get, or create, unique instances of types within an
84
// MLIRContext. This class manages all creation and uniquing of types.
85
class TypeUniquer {
86
public:
87
  /// Get an uniqued instance of a type T.
88
  template <typename T, typename... Args>
89
0
  static T get(MLIRContext *ctx, unsigned kind, Args &&... args) {
90
0
    return ctx->getTypeUniquer().get<typename T::ImplType>(
91
0
        [&](TypeStorage *storage) {
92
0
          storage->initializeDialect(lookupDialectForType<T>(ctx));
93
0
        },
Unexecuted instantiation: _ZZN4mlir6detail11TypeUniquer3getINS_9FloatTypeEJEEET_PNS_11MLIRContextEjDpOT0_ENKUlPNS_11TypeStorageEE_clESB_
Unexecuted instantiation: _ZZN4mlir6detail11TypeUniquer3getINS_9IndexTypeEJEEET_PNS_11MLIRContextEjDpOT0_ENKUlPNS_11TypeStorageEE_clESB_
Unexecuted instantiation: _ZZN4mlir6detail11TypeUniquer3getINS_11IntegerTypeEJiNS3_19SignednessSemanticsEEEET_PNS_11MLIRContextEjDpOT0_ENKUlPNS_11TypeStorageEE_clESC_
Unexecuted instantiation: _ZZN4mlir6detail11TypeUniquer3getINS_8NoneTypeEJEEET_PNS_11MLIRContextEjDpOT0_ENKUlPNS_11TypeStorageEE_clESB_
Unexecuted instantiation: _ZZN4mlir6detail11TypeUniquer3getINS_11IntegerTypeEJRjRNS3_19SignednessSemanticsEEEET_PNS_11MLIRContextEjDpOT0_ENKUlPNS_11TypeStorageEE_clESE_
Unexecuted instantiation: _ZZN4mlir6detail11TypeUniquer3getINS_11ComplexTypeEJRNS_4TypeEEEET_PNS_11MLIRContextEjDpOT0_ENKUlPNS_11TypeStorageEE_clESD_
Unexecuted instantiation: _ZZN4mlir6detail11TypeUniquer3getINS_10VectorTypeEJRN4llvm8ArrayRefIlEERNS_4TypeEEEET_PNS_11MLIRContextEjDpOT0_ENKUlPNS_11TypeStorageEE_clESH_
Unexecuted instantiation: _ZZN4mlir6detail11TypeUniquer3getINS_16RankedTensorTypeEJRN4llvm8ArrayRefIlEERNS_4TypeEEEET_PNS_11MLIRContextEjDpOT0_ENKUlPNS_11TypeStorageEE_clESH_
Unexecuted instantiation: _ZZN4mlir6detail11TypeUniquer3getINS_18UnrankedTensorTypeEJRNS_4TypeEEEET_PNS_11MLIRContextEjDpOT0_ENKUlPNS_11TypeStorageEE_clESD_
Unexecuted instantiation: _ZZN4mlir6detail11TypeUniquer3getINS_10MemRefTypeEJRN4llvm8ArrayRefIlEERNS_4TypeERNS4_11SmallVectorINS_9AffineMapELj2EEERjEEET_PNS_11MLIRContextEjDpOT0_ENKUlPNS_11TypeStorageEE_clESM_
Unexecuted instantiation: _ZZN4mlir6detail11TypeUniquer3getINS_18UnrankedMemRefTypeEJRNS_4TypeERjEEET_PNS_11MLIRContextEjDpOT0_ENKUlPNS_11TypeStorageEE_clESE_
Unexecuted instantiation: _ZZN4mlir6detail11TypeUniquer3getINS_9TupleTypeEJRN4llvm8ArrayRefINS_4TypeEEEEEET_PNS_11MLIRContextEjDpOT0_ENKUlPNS_11TypeStorageEE_clESG_
Unexecuted instantiation: _ZZN4mlir6detail11TypeUniquer3getINS_12FunctionTypeEJRN4llvm8ArrayRefINS_4TypeEEES8_EEET_PNS_11MLIRContextEjDpOT0_ENKUlPNS_11TypeStorageEE_clESG_
Unexecuted instantiation: _ZZN4mlir6detail11TypeUniquer3getINS_10OpaqueTypeEJRNS_10IdentifierERN4llvm9StringRefEEEET_PNS_11MLIRContextEjDpOT0_ENKUlPNS_11TypeStorageEE_clESG_
94
0
        kind, std::forward<Args>(args)...);
95
0
  }
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer3getINS_9FloatTypeEJEEET_PNS_11MLIRContextEjDpOT0_
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer3getINS_9IndexTypeEJEEET_PNS_11MLIRContextEjDpOT0_
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer3getINS_11IntegerTypeEJiNS3_19SignednessSemanticsEEEET_PNS_11MLIRContextEjDpOT0_
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer3getINS_8NoneTypeEJEEET_PNS_11MLIRContextEjDpOT0_
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer3getINS_11IntegerTypeEJRjRNS3_19SignednessSemanticsEEEET_PNS_11MLIRContextEjDpOT0_
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer3getINS_11ComplexTypeEJRNS_4TypeEEEET_PNS_11MLIRContextEjDpOT0_
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer3getINS_10VectorTypeEJRN4llvm8ArrayRefIlEERNS_4TypeEEEET_PNS_11MLIRContextEjDpOT0_
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer3getINS_16RankedTensorTypeEJRN4llvm8ArrayRefIlEERNS_4TypeEEEET_PNS_11MLIRContextEjDpOT0_
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer3getINS_18UnrankedTensorTypeEJRNS_4TypeEEEET_PNS_11MLIRContextEjDpOT0_
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer3getINS_10MemRefTypeEJRN4llvm8ArrayRefIlEERNS_4TypeERNS4_11SmallVectorINS_9AffineMapELj2EEERjEEET_PNS_11MLIRContextEjDpOT0_
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer3getINS_18UnrankedMemRefTypeEJRNS_4TypeERjEEET_PNS_11MLIRContextEjDpOT0_
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer3getINS_9TupleTypeEJRN4llvm8ArrayRefINS_4TypeEEEEEET_PNS_11MLIRContextEjDpOT0_
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer3getINS_12FunctionTypeEJRN4llvm8ArrayRefINS_4TypeEEES8_EEET_PNS_11MLIRContextEjDpOT0_
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer3getINS_10OpaqueTypeEJRNS_10IdentifierERN4llvm9StringRefEEEET_PNS_11MLIRContextEjDpOT0_
96
97
private:
98
  /// Get the dialect that the type 'T' was registered with.
99
0
  template <typename T> static Dialect &lookupDialectForType(MLIRContext *ctx) {
100
0
    return lookupDialectForType(ctx, T::getTypeID());
101
0
  }
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer20lookupDialectForTypeINS_9FloatTypeEEERNS_7DialectEPNS_11MLIRContextE
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer20lookupDialectForTypeINS_9IndexTypeEEERNS_7DialectEPNS_11MLIRContextE
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer20lookupDialectForTypeINS_11IntegerTypeEEERNS_7DialectEPNS_11MLIRContextE
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer20lookupDialectForTypeINS_8NoneTypeEEERNS_7DialectEPNS_11MLIRContextE
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer20lookupDialectForTypeINS_11ComplexTypeEEERNS_7DialectEPNS_11MLIRContextE
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer20lookupDialectForTypeINS_10VectorTypeEEERNS_7DialectEPNS_11MLIRContextE
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer20lookupDialectForTypeINS_16RankedTensorTypeEEERNS_7DialectEPNS_11MLIRContextE
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer20lookupDialectForTypeINS_18UnrankedTensorTypeEEERNS_7DialectEPNS_11MLIRContextE
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer20lookupDialectForTypeINS_10MemRefTypeEEERNS_7DialectEPNS_11MLIRContextE
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer20lookupDialectForTypeINS_18UnrankedMemRefTypeEEERNS_7DialectEPNS_11MLIRContextE
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer20lookupDialectForTypeINS_9TupleTypeEEERNS_7DialectEPNS_11MLIRContextE
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer20lookupDialectForTypeINS_12FunctionTypeEEERNS_7DialectEPNS_11MLIRContextE
Unexecuted instantiation: _ZN4mlir6detail11TypeUniquer20lookupDialectForTypeINS_10OpaqueTypeEEERNS_7DialectEPNS_11MLIRContextE
102
103
  /// Get the dialect that registered the type with the provided typeid.
104
  static Dialect &lookupDialectForType(MLIRContext *ctx, TypeID typeID);
105
};
106
} // namespace detail
107
108
} // end namespace mlir
109
110
#endif