CIRCT  19.0.0git
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 
17 using namespace circt;
18 using namespace arc;
19 using namespace mlir;
20 
21 #define GET_TYPEDEF_CLASSES
22 #include "circt/Dialect/Arc/ArcTypes.cpp.inc"
23 
24 unsigned StateType::getBitWidth() { return hw::getBitWidth(getType()); }
25 
26 LogicalResult
27 StateType::verify(llvm::function_ref<InFlightDiagnostic()> emitError,
28  Type innerType) {
29  if (hw::getBitWidth(innerType) < 0)
30  return emitError() << "state type must have a known bit width; got "
31  << innerType;
32  return success();
33 }
34 
35 unsigned MemoryType::getStride() {
36  unsigned stride = (getWordType().getWidth() + 7) / 8;
37  return llvm::alignToPowerOf2(stride, llvm::bit_ceil(std::min(stride, 16U)));
38 }
39 
40 void ArcDialect::registerTypes() {
41  addTypes<
42 #define GET_TYPEDEF_LIST
43 #include "circt/Dialect/Arc/ArcTypes.cpp.inc"
44  >();
45 }
mlir::Type innerType(mlir::Type type)
Definition: ESITypes.cpp:184
std::optional< int64_t > getBitWidth(FIRRTLBaseType type, bool ignoreFlip=false)
int64_t getBitWidth(mlir::Type type)
Return the hardware bit width of a type.
Definition: HWTypes.cpp:102
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21