1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
//===- Types.cpp - MLIR Type Classes --------------------------------------===//
//
// Part of the MLIR 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/IR/Types.h"
#include "TypeDetail.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/Dialect.h"
#include "llvm/ADT/Twine.h"
using namespace mlir;
using namespace mlir::detail;
//===----------------------------------------------------------------------===//
// Type
//===----------------------------------------------------------------------===//
unsigned Type::getKind() const { return impl->getKind(); }
/// Get the dialect this type is registered to.
Dialect &Type::getDialect() const { return impl->getDialect(); }
MLIRContext *Type::getContext() const { return getDialect().getContext(); }
unsigned Type::getSubclassData() const { return impl->getSubclassData(); }
void Type::setSubclassData(unsigned val) { impl->setSubclassData(val); }
//===----------------------------------------------------------------------===//
// FunctionType
//===----------------------------------------------------------------------===//
FunctionType FunctionType::get(ArrayRef<Type> inputs, ArrayRef<Type> results,
MLIRContext *context) {
return Base::get(context, Type::Kind::Function, inputs, results);
}
ArrayRef<Type> FunctionType::getInputs() const {
return getImpl()->getInputs();
}
unsigned FunctionType::getNumResults() const { return getImpl()->numResults; }
ArrayRef<Type> FunctionType::getResults() const {
return getImpl()->getResults();
}
//===----------------------------------------------------------------------===//
// OpaqueType
//===----------------------------------------------------------------------===//
OpaqueType OpaqueType::get(Identifier dialect, StringRef typeData,
MLIRContext *context) {
return Base::get(context, Type::Kind::Opaque, dialect, typeData);
}
OpaqueType OpaqueType::getChecked(Identifier dialect, StringRef typeData,
MLIRContext *context, Location location) {
return Base::getChecked(location, context, Kind::Opaque, dialect, typeData);
}
/// Returns the dialect namespace of the opaque type.
Identifier OpaqueType::getDialectNamespace() const {
return getImpl()->dialectNamespace;
}
/// Returns the raw type data of the opaque type.
StringRef OpaqueType::getTypeData() const { return getImpl()->typeData; }
/// Verify the construction of an opaque type.
LogicalResult OpaqueType::verifyConstructionInvariants(Optional<Location> loc,
MLIRContext *context,
Identifier dialect,
StringRef typeData) {
if (!Dialect::isValidNamespace(dialect.strref()))
return emitOptionalError(loc, "invalid dialect namespace '", dialect, "'");
return success();
}
|