16#include "mlir/IR/Builders.h"
17#include "mlir/IR/DialectImplementation.h"
18#include "llvm/ADT/TypeSwitch.h"
23#define GET_TYPEDEF_CLASSES
24#include "circt/Dialect/LLHD/LLHDTypes.cpp.inc"
26#define GET_ATTRDEF_CLASSES
27#include "circt/Dialect/LLHD/LLHDAttributes.cpp.inc"
34 return TypeSwitch<WrapperType, Type>(*this).Case<RefType, NetType>(
35 [](
auto type) { return type.getNestedType(); });
44Attribute TimeAttr::parse(AsmParser &p, Type type) {
45 llvm::StringRef timeUnit;
50 if (p.parseLess() || p.parseInteger(time) || p.parseKeyword(&timeUnit))
54 if (p.parseComma() || p.parseInteger(delta) || p.parseKeyword(
"d") ||
59 auto loc = p.getEncodedSourceLoc(p.getCurrentLocation());
60 return getChecked(mlir::detail::getDefaultDiagnosticEmitFn(loc),
61 p.getContext(), time, timeUnit, delta);
64void TimeAttr::print(AsmPrinter &p)
const {
65 p <<
"<" << getTime() << getTimeUnit() <<
", " << getDelta() <<
"d>";
68LogicalResult TimeAttr::verify(function_ref<InFlightDiagnostic()> emitError,
69 TimeType type, uint64_t time,
70 llvm::StringRef timeUnit,
unsigned delta) {
72 std::vector<std::string> legalUnits{
"ys",
"zs",
"as",
"fs",
"ps",
73 "ns",
"us",
"ms",
"s"};
74 if (llvm::find(legalUnits, timeUnit) == legalUnits.end())
75 return emitError() <<
"Illegal time unit.";
84void LLHDDialect::registerTypes() {
86#define GET_TYPEDEF_LIST
87#include "circt/Dialect/LLHD/LLHDTypes.cpp.inc"
91void LLHDDialect::registerAttributes() {
93#define GET_ATTRDEF_LIST
94#include "circt/Dialect/LLHD/LLHDAttributes.cpp.inc"
mlir::Type getNestedType() const
Get the wrapped type.