/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
|*                                                                            *|
|* AttrDef Definitions                                                        *|
|*                                                                            *|
|* Automatically generated file, do not edit!                                 *|
|*                                                                            *|
\*===----------------------------------------------------------------------===*/

#ifdef GET_ATTRDEF_LIST
#undef GET_ATTRDEF_LIST

::cuf::DataAttributeAttr,
::cuf::ProcAttributeAttr,
::cuf::LaunchBoundsAttr,
::cuf::ClusterDimsAttr,
::cuf::DataTransferKindAttr

#endif  // GET_ATTRDEF_LIST

#ifdef GET_ATTRDEF_CLASSES
#undef GET_ATTRDEF_CLASSES

static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) {
  return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser)
    .Case(::cuf::DataAttributeAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
      value = ::cuf::DataAttributeAttr::parse(parser, type);
      return ::mlir::success(!!value);
    })
    .Case(::cuf::ProcAttributeAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
      value = ::cuf::ProcAttributeAttr::parse(parser, type);
      return ::mlir::success(!!value);
    })
    .Case(::cuf::LaunchBoundsAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
      value = ::cuf::LaunchBoundsAttr::parse(parser, type);
      return ::mlir::success(!!value);
    })
    .Case(::cuf::ClusterDimsAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
      value = ::cuf::ClusterDimsAttr::parse(parser, type);
      return ::mlir::success(!!value);
    })
    .Case(::cuf::DataTransferKindAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
      value = ::cuf::DataTransferKindAttr::parse(parser, type);
      return ::mlir::success(!!value);
    })
    .Default([&](llvm::StringRef keyword, llvm::SMLoc) {
      *mnemonic = keyword;
      return std::nullopt;
    });
}

static ::llvm::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) {
  return ::llvm::TypeSwitch<::mlir::Attribute, ::llvm::LogicalResult>(def)    .Case<::cuf::DataAttributeAttr>([&](auto t) {
      printer << ::cuf::DataAttributeAttr::getMnemonic();
t.print(printer);
      return ::mlir::success();
    })
    .Case<::cuf::ProcAttributeAttr>([&](auto t) {
      printer << ::cuf::ProcAttributeAttr::getMnemonic();
t.print(printer);
      return ::mlir::success();
    })
    .Case<::cuf::LaunchBoundsAttr>([&](auto t) {
      printer << ::cuf::LaunchBoundsAttr::getMnemonic();
t.print(printer);
      return ::mlir::success();
    })
    .Case<::cuf::ClusterDimsAttr>([&](auto t) {
      printer << ::cuf::ClusterDimsAttr::getMnemonic();
t.print(printer);
      return ::mlir::success();
    })
    .Case<::cuf::DataTransferKindAttr>([&](auto t) {
      printer << ::cuf::DataTransferKindAttr::getMnemonic();
t.print(printer);
      return ::mlir::success();
    })
    .Default([](auto) { return ::mlir::failure(); });
}

namespace cuf {
namespace detail {
struct DataAttributeAttrStorage : public ::mlir::AttributeStorage {
  using KeyTy = std::tuple<::cuf::DataAttribute>;
  DataAttributeAttrStorage(::cuf::DataAttribute value) : value(std::move(value)) {}

  KeyTy getAsKey() const {
    return KeyTy(value);
  }

  bool operator==(const KeyTy &tblgenKey) const {
    return (value == std::get<0>(tblgenKey));
  }

  static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
    return ::llvm::hash_combine(std::get<0>(tblgenKey));
  }

  static DataAttributeAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
    auto value = std::move(std::get<0>(tblgenKey));
    return new (allocator.allocate<DataAttributeAttrStorage>()) DataAttributeAttrStorage(std::move(value));
  }

  ::cuf::DataAttribute value;
};
} // namespace detail
DataAttributeAttr DataAttributeAttr::get(::mlir::MLIRContext *context, ::cuf::DataAttribute value) {
  return Base::get(context, std::move(value));
}

::mlir::Attribute DataAttributeAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
  ::mlir::Builder odsBuilder(odsParser.getContext());
  ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
  (void) odsLoc;
  ::mlir::FailureOr<::cuf::DataAttribute> _result_value;
  // Parse literal '<'
  if (odsParser.parseLess()) return {};

  // Parse variable 'value'
  _result_value = [&]() -> ::mlir::FailureOr<::cuf::DataAttribute> {
      auto loc = odsParser.getCurrentLocation();
      ::llvm::StringRef enumKeyword;
      if (::mlir::failed(odsParser.parseKeyword(&enumKeyword)))
        return ::mlir::failure();
      auto maybeEnum = ::cuf::symbolizeDataAttribute(enumKeyword);
      if (maybeEnum)
        return *maybeEnum;
      return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::cuf::DataAttribute" << " to be one of: " << "constant" << ", " << "device" << ", " << "managed" << ", " << "pinned" << ", " << "shared" << ", " << "unified")};
    }();
  if (::mlir::failed(_result_value)) {
    odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse cuf_DataAttributeAttr parameter 'value' which is to be a `::cuf::DataAttribute`");
    return {};
  }
  // Parse literal '>'
  if (odsParser.parseGreater()) return {};
  assert(::mlir::succeeded(_result_value));
  return DataAttributeAttr::get(odsParser.getContext(),
      ::cuf::DataAttribute((*_result_value)));
}

void DataAttributeAttr::print(::mlir::AsmPrinter &odsPrinter) const {
  ::mlir::Builder odsBuilder(getContext());
  odsPrinter << "<";
  odsPrinter << stringifyDataAttribute(getValue());
  odsPrinter << ">";
}

::cuf::DataAttribute DataAttributeAttr::getValue() const {
  return getImpl()->value;
}

} // namespace cuf
MLIR_DEFINE_EXPLICIT_TYPE_ID(::cuf::DataAttributeAttr)
namespace cuf {
namespace detail {
struct ProcAttributeAttrStorage : public ::mlir::AttributeStorage {
  using KeyTy = std::tuple<::cuf::ProcAttribute>;
  ProcAttributeAttrStorage(::cuf::ProcAttribute value) : value(std::move(value)) {}

  KeyTy getAsKey() const {
    return KeyTy(value);
  }

  bool operator==(const KeyTy &tblgenKey) const {
    return (value == std::get<0>(tblgenKey));
  }

  static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
    return ::llvm::hash_combine(std::get<0>(tblgenKey));
  }

  static ProcAttributeAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
    auto value = std::move(std::get<0>(tblgenKey));
    return new (allocator.allocate<ProcAttributeAttrStorage>()) ProcAttributeAttrStorage(std::move(value));
  }

  ::cuf::ProcAttribute value;
};
} // namespace detail
ProcAttributeAttr ProcAttributeAttr::get(::mlir::MLIRContext *context, ::cuf::ProcAttribute value) {
  return Base::get(context, std::move(value));
}

::mlir::Attribute ProcAttributeAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
  ::mlir::Builder odsBuilder(odsParser.getContext());
  ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
  (void) odsLoc;
  ::mlir::FailureOr<::cuf::ProcAttribute> _result_value;
  // Parse literal '<'
  if (odsParser.parseLess()) return {};

  // Parse variable 'value'
  _result_value = [&]() -> ::mlir::FailureOr<::cuf::ProcAttribute> {
      auto loc = odsParser.getCurrentLocation();
      ::llvm::StringRef enumKeyword;
      if (::mlir::failed(odsParser.parseKeyword(&enumKeyword)))
        return ::mlir::failure();
      auto maybeEnum = ::cuf::symbolizeProcAttribute(enumKeyword);
      if (maybeEnum)
        return *maybeEnum;
      return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::cuf::ProcAttribute" << " to be one of: " << "host" << ", " << "device" << ", " << "host_device" << ", " << "global" << ", " << "grid_global")};
    }();
  if (::mlir::failed(_result_value)) {
    odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse cuf_ProcAttributeAttr parameter 'value' which is to be a `::cuf::ProcAttribute`");
    return {};
  }
  // Parse literal '>'
  if (odsParser.parseGreater()) return {};
  assert(::mlir::succeeded(_result_value));
  return ProcAttributeAttr::get(odsParser.getContext(),
      ::cuf::ProcAttribute((*_result_value)));
}

void ProcAttributeAttr::print(::mlir::AsmPrinter &odsPrinter) const {
  ::mlir::Builder odsBuilder(getContext());
  odsPrinter << "<";
  odsPrinter << stringifyProcAttribute(getValue());
  odsPrinter << ">";
}

::cuf::ProcAttribute ProcAttributeAttr::getValue() const {
  return getImpl()->value;
}

} // namespace cuf
MLIR_DEFINE_EXPLICIT_TYPE_ID(::cuf::ProcAttributeAttr)
namespace cuf {
namespace detail {
struct LaunchBoundsAttrStorage : public ::mlir::AttributeStorage {
  using KeyTy = std::tuple<mlir::IntegerAttr, mlir::IntegerAttr, mlir::IntegerAttr>;
  LaunchBoundsAttrStorage(mlir::IntegerAttr maxTPB, mlir::IntegerAttr minBPM, mlir::IntegerAttr upperBoundClusterSize) : maxTPB(std::move(maxTPB)), minBPM(std::move(minBPM)), upperBoundClusterSize(std::move(upperBoundClusterSize)) {}

  KeyTy getAsKey() const {
    return KeyTy(maxTPB, minBPM, upperBoundClusterSize);
  }

  bool operator==(const KeyTy &tblgenKey) const {
    return (maxTPB == std::get<0>(tblgenKey)) && (minBPM == std::get<1>(tblgenKey)) && (upperBoundClusterSize == std::get<2>(tblgenKey));
  }

  static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
    return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey));
  }

  static LaunchBoundsAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
    auto maxTPB = std::move(std::get<0>(tblgenKey));
    auto minBPM = std::move(std::get<1>(tblgenKey));
    auto upperBoundClusterSize = std::move(std::get<2>(tblgenKey));
    return new (allocator.allocate<LaunchBoundsAttrStorage>()) LaunchBoundsAttrStorage(std::move(maxTPB), std::move(minBPM), std::move(upperBoundClusterSize));
  }

  mlir::IntegerAttr maxTPB;
  mlir::IntegerAttr minBPM;
  mlir::IntegerAttr upperBoundClusterSize;
};
} // namespace detail
LaunchBoundsAttr LaunchBoundsAttr::get(::mlir::MLIRContext *context, mlir::IntegerAttr maxTPB, mlir::IntegerAttr minBPM, mlir::IntegerAttr upperBoundClusterSize) {
  return Base::get(context, std::move(maxTPB), std::move(minBPM), std::move(upperBoundClusterSize));
}

::mlir::Attribute LaunchBoundsAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
  ::mlir::Builder odsBuilder(odsParser.getContext());
  ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
  (void) odsLoc;
  ::mlir::FailureOr<mlir::IntegerAttr> _result_maxTPB;
  ::mlir::FailureOr<mlir::IntegerAttr> _result_minBPM;
  ::mlir::FailureOr<mlir::IntegerAttr> _result_upperBoundClusterSize;
  // Parse literal '<'
  if (odsParser.parseLess()) return {};
  // Parse parameter struct
  bool _seen_maxTPB = false;
  bool _seen_minBPM = false;
  bool _seen_upperBoundClusterSize = false;
  {
    const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool {
      // Parse literal '='
      if (odsParser.parseEqual()) return {};
      if (!_seen_maxTPB && _paramKey == "maxTPB") {
        _seen_maxTPB = true;

        // Parse variable 'maxTPB'
        _result_maxTPB = ::mlir::FieldParser<mlir::IntegerAttr>::parse(odsParser);
        if (::mlir::failed(_result_maxTPB)) {
          odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse cuf_LaunchBoundsAttr parameter 'maxTPB' which is to be a `mlir::IntegerAttr`");
          return {};
        }
      } else if (!_seen_minBPM && _paramKey == "minBPM") {
        _seen_minBPM = true;

        // Parse variable 'minBPM'
        _result_minBPM = ::mlir::FieldParser<mlir::IntegerAttr>::parse(odsParser);
        if (::mlir::failed(_result_minBPM)) {
          odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse cuf_LaunchBoundsAttr parameter 'minBPM' which is to be a `mlir::IntegerAttr`");
          return {};
        }
      } else if (!_seen_upperBoundClusterSize && _paramKey == "upperBoundClusterSize") {
        _seen_upperBoundClusterSize = true;

        // Parse variable 'upperBoundClusterSize'
        _result_upperBoundClusterSize = ::mlir::FieldParser<mlir::IntegerAttr>::parse(odsParser);
        if (::mlir::failed(_result_upperBoundClusterSize)) {
          odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse cuf_LaunchBoundsAttr parameter 'upperBoundClusterSize' which is to be a `mlir::IntegerAttr`");
          return {};
        }
      } else {
        odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey;
        return {};
      }
      return true;
    };
    do {
      ::llvm::StringRef _paramKey;
      if (odsParser.parseKeyword(&_paramKey)) {
        odsParser.emitError(odsParser.getCurrentLocation(),
                           "expected a parameter name in struct");
        return {};
      }
      if (!_loop_body(_paramKey)) return {};
    } while(!odsParser.parseOptionalComma());
    if (!_seen_maxTPB) {
      odsParser.emitError(odsParser.getCurrentLocation(), "struct is missing required parameter: ") << "maxTPB";
      return {};
    }
    if (!_seen_minBPM) {
      odsParser.emitError(odsParser.getCurrentLocation(), "struct is missing required parameter: ") << "minBPM";
      return {};
    }
  }
  // Parse literal '>'
  if (odsParser.parseGreater()) return {};
  assert(::mlir::succeeded(_result_maxTPB));
  assert(::mlir::succeeded(_result_minBPM));
  return LaunchBoundsAttr::get(odsParser.getContext(),
      mlir::IntegerAttr((*_result_maxTPB)),
      mlir::IntegerAttr((*_result_minBPM)),
      mlir::IntegerAttr((_result_upperBoundClusterSize.value_or(mlir::IntegerAttr()))));
}

void LaunchBoundsAttr::print(::mlir::AsmPrinter &odsPrinter) const {
  ::mlir::Builder odsBuilder(getContext());
  odsPrinter << "<";
  {
    bool _firstPrinted = true;
    if (!_firstPrinted) odsPrinter << ", ";
    _firstPrinted = false;
    odsPrinter << "maxTPB = ";
    odsPrinter.printStrippedAttrOrType(getMaxTPB());
    if (!_firstPrinted) odsPrinter << ", ";
    _firstPrinted = false;
    odsPrinter << "minBPM = ";
    odsPrinter.printStrippedAttrOrType(getMinBPM());
    if (!(getUpperBoundClusterSize() == mlir::IntegerAttr())) {
      if (!_firstPrinted) odsPrinter << ", ";
      _firstPrinted = false;
      odsPrinter << "upperBoundClusterSize = ";
      if (!(getUpperBoundClusterSize() == mlir::IntegerAttr())) {
        odsPrinter.printStrippedAttrOrType(getUpperBoundClusterSize());
      }
    }
  }
  odsPrinter << ">";
}

mlir::IntegerAttr LaunchBoundsAttr::getMaxTPB() const {
  return getImpl()->maxTPB;
}

mlir::IntegerAttr LaunchBoundsAttr::getMinBPM() const {
  return getImpl()->minBPM;
}

mlir::IntegerAttr LaunchBoundsAttr::getUpperBoundClusterSize() const {
  return getImpl()->upperBoundClusterSize;
}

} // namespace cuf
MLIR_DEFINE_EXPLICIT_TYPE_ID(::cuf::LaunchBoundsAttr)
namespace cuf {
namespace detail {
struct ClusterDimsAttrStorage : public ::mlir::AttributeStorage {
  using KeyTy = std::tuple<mlir::IntegerAttr, mlir::IntegerAttr, mlir::IntegerAttr>;
  ClusterDimsAttrStorage(mlir::IntegerAttr x, mlir::IntegerAttr y, mlir::IntegerAttr z) : x(std::move(x)), y(std::move(y)), z(std::move(z)) {}

  KeyTy getAsKey() const {
    return KeyTy(x, y, z);
  }

  bool operator==(const KeyTy &tblgenKey) const {
    return (x == std::get<0>(tblgenKey)) && (y == std::get<1>(tblgenKey)) && (z == std::get<2>(tblgenKey));
  }

  static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
    return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey));
  }

  static ClusterDimsAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
    auto x = std::move(std::get<0>(tblgenKey));
    auto y = std::move(std::get<1>(tblgenKey));
    auto z = std::move(std::get<2>(tblgenKey));
    return new (allocator.allocate<ClusterDimsAttrStorage>()) ClusterDimsAttrStorage(std::move(x), std::move(y), std::move(z));
  }

  mlir::IntegerAttr x;
  mlir::IntegerAttr y;
  mlir::IntegerAttr z;
};
} // namespace detail
ClusterDimsAttr ClusterDimsAttr::get(::mlir::MLIRContext *context, mlir::IntegerAttr x, mlir::IntegerAttr y, mlir::IntegerAttr z) {
  return Base::get(context, std::move(x), std::move(y), std::move(z));
}

::mlir::Attribute ClusterDimsAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
  ::mlir::Builder odsBuilder(odsParser.getContext());
  ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
  (void) odsLoc;
  ::mlir::FailureOr<mlir::IntegerAttr> _result_x;
  ::mlir::FailureOr<mlir::IntegerAttr> _result_y;
  ::mlir::FailureOr<mlir::IntegerAttr> _result_z;
  // Parse literal '<'
  if (odsParser.parseLess()) return {};
  // Parse parameter struct
  bool _seen_x = false;
  bool _seen_y = false;
  bool _seen_z = false;
  {
    const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool {
      // Parse literal '='
      if (odsParser.parseEqual()) return {};
      if (!_seen_x && _paramKey == "x") {
        _seen_x = true;

        // Parse variable 'x'
        _result_x = ::mlir::FieldParser<mlir::IntegerAttr>::parse(odsParser);
        if (::mlir::failed(_result_x)) {
          odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse cuf_ClusterDimsAttr parameter 'x' which is to be a `mlir::IntegerAttr`");
          return {};
        }
      } else if (!_seen_y && _paramKey == "y") {
        _seen_y = true;

        // Parse variable 'y'
        _result_y = ::mlir::FieldParser<mlir::IntegerAttr>::parse(odsParser);
        if (::mlir::failed(_result_y)) {
          odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse cuf_ClusterDimsAttr parameter 'y' which is to be a `mlir::IntegerAttr`");
          return {};
        }
      } else if (!_seen_z && _paramKey == "z") {
        _seen_z = true;

        // Parse variable 'z'
        _result_z = ::mlir::FieldParser<mlir::IntegerAttr>::parse(odsParser);
        if (::mlir::failed(_result_z)) {
          odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse cuf_ClusterDimsAttr parameter 'z' which is to be a `mlir::IntegerAttr`");
          return {};
        }
      } else {
        odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey;
        return {};
      }
      return true;
    };
    for (unsigned odsStructIndex = 0; odsStructIndex < 3; ++odsStructIndex) {
      ::llvm::StringRef _paramKey;
      if (odsParser.parseKeyword(&_paramKey)) {
        odsParser.emitError(odsParser.getCurrentLocation(),
                           "expected a parameter name in struct");
        return {};
      }
      if (!_loop_body(_paramKey)) return {};
      if ((odsStructIndex != 3 - 1) && odsParser.parseComma())
        return {};
    }
  }
  // Parse literal '>'
  if (odsParser.parseGreater()) return {};
  assert(::mlir::succeeded(_result_x));
  assert(::mlir::succeeded(_result_y));
  assert(::mlir::succeeded(_result_z));
  return ClusterDimsAttr::get(odsParser.getContext(),
      mlir::IntegerAttr((*_result_x)),
      mlir::IntegerAttr((*_result_y)),
      mlir::IntegerAttr((*_result_z)));
}

void ClusterDimsAttr::print(::mlir::AsmPrinter &odsPrinter) const {
  ::mlir::Builder odsBuilder(getContext());
  odsPrinter << "<";
  {
    bool _firstPrinted = true;
    if (!_firstPrinted) odsPrinter << ", ";
    _firstPrinted = false;
    odsPrinter << "x = ";
    odsPrinter.printStrippedAttrOrType(getX());
    if (!_firstPrinted) odsPrinter << ", ";
    _firstPrinted = false;
    odsPrinter << "y = ";
    odsPrinter.printStrippedAttrOrType(getY());
    if (!_firstPrinted) odsPrinter << ", ";
    _firstPrinted = false;
    odsPrinter << "z = ";
    odsPrinter.printStrippedAttrOrType(getZ());
  }
  odsPrinter << ">";
}

mlir::IntegerAttr ClusterDimsAttr::getX() const {
  return getImpl()->x;
}

mlir::IntegerAttr ClusterDimsAttr::getY() const {
  return getImpl()->y;
}

mlir::IntegerAttr ClusterDimsAttr::getZ() const {
  return getImpl()->z;
}

} // namespace cuf
MLIR_DEFINE_EXPLICIT_TYPE_ID(::cuf::ClusterDimsAttr)
namespace cuf {
namespace detail {
struct DataTransferKindAttrStorage : public ::mlir::AttributeStorage {
  using KeyTy = std::tuple<::cuf::DataTransferKind>;
  DataTransferKindAttrStorage(::cuf::DataTransferKind value) : value(std::move(value)) {}

  KeyTy getAsKey() const {
    return KeyTy(value);
  }

  bool operator==(const KeyTy &tblgenKey) const {
    return (value == std::get<0>(tblgenKey));
  }

  static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
    return ::llvm::hash_combine(std::get<0>(tblgenKey));
  }

  static DataTransferKindAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
    auto value = std::move(std::get<0>(tblgenKey));
    return new (allocator.allocate<DataTransferKindAttrStorage>()) DataTransferKindAttrStorage(std::move(value));
  }

  ::cuf::DataTransferKind value;
};
} // namespace detail
DataTransferKindAttr DataTransferKindAttr::get(::mlir::MLIRContext *context, ::cuf::DataTransferKind value) {
  return Base::get(context, std::move(value));
}

::mlir::Attribute DataTransferKindAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
  ::mlir::Builder odsBuilder(odsParser.getContext());
  ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
  (void) odsLoc;
  ::mlir::FailureOr<::cuf::DataTransferKind> _result_value;
  // Parse literal '<'
  if (odsParser.parseLess()) return {};

  // Parse variable 'value'
  _result_value = [&]() -> ::mlir::FailureOr<::cuf::DataTransferKind> {
      auto loc = odsParser.getCurrentLocation();
      ::llvm::StringRef enumKeyword;
      if (::mlir::failed(odsParser.parseKeyword(&enumKeyword)))
        return ::mlir::failure();
      auto maybeEnum = ::cuf::symbolizeDataTransferKind(enumKeyword);
      if (maybeEnum)
        return *maybeEnum;
      return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::cuf::DataTransferKind" << " to be one of: " << "device_host" << ", " << "host_device" << ", " << "device_device")};
    }();
  if (::mlir::failed(_result_value)) {
    odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse cuf_DataTransferKindAttr parameter 'value' which is to be a `::cuf::DataTransferKind`");
    return {};
  }
  // Parse literal '>'
  if (odsParser.parseGreater()) return {};
  assert(::mlir::succeeded(_result_value));
  return DataTransferKindAttr::get(odsParser.getContext(),
      ::cuf::DataTransferKind((*_result_value)));
}

void DataTransferKindAttr::print(::mlir::AsmPrinter &odsPrinter) const {
  ::mlir::Builder odsBuilder(getContext());
  odsPrinter << "<";
  odsPrinter << stringifyDataTransferKind(getValue());
  odsPrinter << ">";
}

::cuf::DataTransferKind DataTransferKindAttr::getValue() const {
  return getImpl()->value;
}

} // namespace cuf
MLIR_DEFINE_EXPLICIT_TYPE_ID(::cuf::DataTransferKindAttr)
namespace cuf {

/// Parse an attribute registered to this dialect.
::mlir::Attribute CUFDialect::parseAttribute(::mlir::DialectAsmParser &parser,
                                      ::mlir::Type type) const {
  ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
  ::llvm::StringRef attrTag;
  {
    ::mlir::Attribute attr;
    auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr);
    if (parseResult.has_value())
      return attr;
  }
  
  parser.emitError(typeLoc) << "unknown attribute `"
      << attrTag << "` in dialect `" << getNamespace() << "`";
  return {};
}
/// Print an attribute registered to this dialect.
void CUFDialect::printAttribute(::mlir::Attribute attr,
                         ::mlir::DialectAsmPrinter &printer) const {
  if (::mlir::succeeded(generatedAttributePrinter(attr, printer)))
    return;
  
}
} // namespace cuf

#endif  // GET_ATTRDEF_CLASSES

