CIRCT  20.0.0git
OMTypes.cpp
Go to the documentation of this file.
1 //===- OMTypes.cpp - Object Model type definitions ------------------------===//
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 contains the Object Model type definitions.
10 //
11 //===----------------------------------------------------------------------===//
12 
15 
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 mlir;
22 using namespace circt::om;
23 
24 #define GET_TYPEDEF_CLASSES
25 #include "circt/Dialect/OM/OMTypes.cpp.inc"
26 
27 void circt::om::OMDialect::registerTypes() {
28  addTypes<
29 #define GET_TYPEDEF_LIST
30 #include "circt/Dialect/OM/OMTypes.cpp.inc"
31  >();
32 }
33 
34 mlir::LogicalResult
35 circt::om::MapType::verify(llvm::function_ref<mlir::InFlightDiagnostic()> diag,
36  mlir::Type keyType, mlir::Type elementType) {
37  if (!llvm::isa<om::StringType, mlir::IntegerType>(keyType))
38  return diag() << "map key type must be either string or integer but got "
39  << keyType;
40  return mlir::success();
41 }
42 
43 bool circt::om::isMapKeyValuePairType(mlir::Type type) {
44  auto tuple = llvm::dyn_cast<mlir::TupleType>(type);
45  return tuple && tuple.getTypes().size() == 2 &&
46  llvm::isa<om::StringType, mlir::IntegerType>(tuple.getTypes().front());
47 }
MlirType elementType
Definition: CHIRRTL.cpp:29
static LogicalResult verify(Value clock, bool eventExists, mlir::Location loc)
Definition: SVOps.cpp:2467
bool isMapKeyValuePairType(mlir::Type)
Definition: OMTypes.cpp:43
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21