CIRCT  20.0.0git
SVTypes.cpp
Go to the documentation of this file.
1 //===- SVTypes.cpp - Implement the SV types -------------------------------===//
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 implement the SV dialect type system.
10 //
11 //===----------------------------------------------------------------------===//
12 
16 #include "mlir/IR/Builders.h"
17 #include "mlir/IR/DialectImplementation.h"
18 #include "llvm/ADT/TypeSwitch.h"
19 
20 using namespace circt;
21 using namespace circt::sv;
22 
23 /// Return the element type of an ArrayType or UnpackedArrayType, or null if the
24 /// operand isn't an array.
26  if (!type)
27  return {};
28  if (auto array = hw::type_dyn_cast<hw::ArrayType>(type))
29  return array.getElementType();
30  if (auto array = hw::type_dyn_cast<hw::UnpackedArrayType>(type))
31  return array.getElementType();
32 
33  return {};
34 }
35 
36 //===----------------------------------------------------------------------===//
37 // InOut type logic.
38 //===----------------------------------------------------------------------===//
39 
40 /// Return the element type of an InOutType or null if the operand isn't an
41 /// InOut type.
42 mlir::Type circt::sv::getInOutElementType(mlir::Type type) {
43  if (auto inout = dyn_cast_or_null<InOutType>(type))
44  return inout.getElementType();
45  return {};
46 }
47 
48 //===----------------------------------------------------------------------===//
49 // TableGen generated logic.
50 //===----------------------------------------------------------------------===//
51 
52 // Provide the autogenerated implementation guts for the Op classes.
53 #define GET_TYPEDEF_CLASSES
54 #include "circt/Dialect/SV/SVTypes.cpp.inc"
55 
56 void SVDialect::registerTypes() {
57  addTypes<
58 #define GET_TYPEDEF_LIST
59 #include "circt/Dialect/SV/SVTypes.cpp.inc"
60  >();
61 }
mlir::Type getAnyHWArrayElementType(mlir::Type type)
Return the element type of an ArrayType or UnpackedArrayType, or null if the operand isn't an array.
mlir::Type getInOutElementType(mlir::Type type)
Return the element type of an InOutType or null if the operand isn't an InOut type.
Definition: SVTypes.cpp:42
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21