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/IR/LLHDTypes.cpp.inc" 
   26#define GET_ATTRDEF_CLASSES 
   27#include "circt/Dialect/LLHD/IR/LLHDAttributes.cpp.inc" 
   35Attribute TimeAttr::parse(AsmParser &p, Type type) {
 
   36  llvm::StringRef timeUnit;
 
   42  if (p.parseLess() || p.parseInteger(time) || p.parseKeyword(&timeUnit))
 
   46  if (p.parseComma() || p.parseInteger(delta) || p.parseKeyword(
"d"))
 
   50  if (p.parseComma() || p.parseInteger(eps) || p.parseKeyword(
"e") ||
 
   55  auto loc = p.getEncodedSourceLoc(p.getCurrentLocation());
 
   56  return getChecked(mlir::detail::getDefaultDiagnosticEmitFn(loc),
 
   57                    p.getContext(), time, timeUnit, delta, eps);
 
   60void TimeAttr::print(AsmPrinter &p)
 const {
 
   61  p << 
"<" << getTime() << getTimeUnit() << 
", " << getDelta() << 
"d, " 
   62    << getEpsilon() << 
"e>";
 
   65LogicalResult TimeAttr::verify(function_ref<InFlightDiagnostic()> emitError,
 
   66                               TimeType type, uint64_t time,
 
   67                               llvm::StringRef timeUnit, 
unsigned delta,
 
   70  std::vector<std::string> legalUnits{
"ys", 
"zs", 
"as", 
"fs", 
"ps",
 
   71                                      "ns", 
"us", 
"ms", 
"s"};
 
   72  if (std::find(legalUnits.begin(), legalUnits.end(), timeUnit) ==
 
   74    return emitError() << 
"Illegal time unit.";
 
   83void LLHDDialect::registerTypes() {
 
   85#define GET_TYPEDEF_LIST 
   86#include "circt/Dialect/LLHD/IR/LLHDTypes.cpp.inc" 
   90void LLHDDialect::registerAttributes() {
 
   92#define GET_ATTRDEF_LIST 
   93#include "circt/Dialect/LLHD/IR/LLHDAttributes.cpp.inc"