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