CIRCT 20.0.0git
Loading...
Searching...
No Matches
ArcTypes.cpp
Go to the documentation of this file.
1//===- ArcTypes.cpp -------------------------------------------------------===//
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
13#include "mlir/IR/Builders.h"
14#include "mlir/IR/DialectImplementation.h"
15#include "llvm/ADT/TypeSwitch.h"
16
17using namespace circt;
18using namespace arc;
19using namespace mlir;
20
21#define GET_TYPEDEF_CLASSES
22#include "circt/Dialect/Arc/ArcTypes.cpp.inc"
23
24unsigned StateType::getBitWidth() {
25 if (llvm::isa<seq::ClockType>(getType()))
26 return 1;
27 return hw::getBitWidth(getType());
28}
29
30LogicalResult
31StateType::verify(llvm::function_ref<InFlightDiagnostic()> emitError,
32 Type innerType) {
33 if (llvm::isa<seq::ClockType>(innerType))
34 return success();
35 if (hw::getBitWidth(innerType) < 0)
36 return emitError() << "state type must have a known bit width; got "
37 << innerType;
38 return success();
39}
40
41unsigned MemoryType::getStride() {
42 unsigned stride = (getWordType().getWidth() + 7) / 8;
43 return llvm::alignToPowerOf2(stride, llvm::bit_ceil(std::min(stride, 16U)));
44}
45
46void ArcDialect::registerTypes() {
47 addTypes<
48#define GET_TYPEDEF_LIST
49#include "circt/Dialect/Arc/ArcTypes.cpp.inc"
50 >();
51}
mlir::Type innerType(mlir::Type type)
Definition ESITypes.cpp:227
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.