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

#ifdef GET_ATTRDEF_LIST
#undef GET_ATTRDEF_LIST

::mlir::amdgpu::AddressSpaceAttr,
::mlir::amdgpu::DPPPermAttr,
::mlir::amdgpu::LoadTemporalHintAttr,
::mlir::amdgpu::ScopeAttr

#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(::mlir::amdgpu::AddressSpaceAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
      value = ::mlir::amdgpu::AddressSpaceAttr::parse(parser, type);
      return ::mlir::success(!!value);
    })
    .Case(::mlir::amdgpu::DPPPermAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
      value = ::mlir::amdgpu::DPPPermAttr::parse(parser, type);
      return ::mlir::success(!!value);
    })
    .Case(::mlir::amdgpu::LoadTemporalHintAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
      value = ::mlir::amdgpu::LoadTemporalHintAttr::parse(parser, type);
      return ::mlir::success(!!value);
    })
    .Case(::mlir::amdgpu::ScopeAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
      value = ::mlir::amdgpu::ScopeAttr::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<::mlir::amdgpu::AddressSpaceAttr>([&](auto t) {
      printer << ::mlir::amdgpu::AddressSpaceAttr::getMnemonic();
t.print(printer);
      return ::mlir::success();
    })
    .Case<::mlir::amdgpu::DPPPermAttr>([&](auto t) {
      printer << ::mlir::amdgpu::DPPPermAttr::getMnemonic();
printer << ' ';
t.print(printer);
      return ::mlir::success();
    })
    .Case<::mlir::amdgpu::LoadTemporalHintAttr>([&](auto t) {
      printer << ::mlir::amdgpu::LoadTemporalHintAttr::getMnemonic();
printer << ' ';
t.print(printer);
      return ::mlir::success();
    })
    .Case<::mlir::amdgpu::ScopeAttr>([&](auto t) {
      printer << ::mlir::amdgpu::ScopeAttr::getMnemonic();
printer << ' ';
t.print(printer);
      return ::mlir::success();
    })
    .Default([](auto) { return ::mlir::failure(); });
}

namespace mlir::amdgpu {

namespace detail {

struct AddressSpaceAttrStorage : public ::mlir::AttributeStorage {
  using KeyTy = std::tuple<::mlir::amdgpu::AddressSpace>;
  AddressSpaceAttrStorage(::mlir::amdgpu::AddressSpace 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 AddressSpaceAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
    auto value = std::move(std::get<0>(tblgenKey));
    return new (allocator.allocate<AddressSpaceAttrStorage>()) AddressSpaceAttrStorage(std::move(value));
  }

  ::mlir::amdgpu::AddressSpace value;
};

} // namespace detail
AddressSpaceAttr AddressSpaceAttr::get(::mlir::MLIRContext *context, ::mlir::amdgpu::AddressSpace value) {
  return Base::get(context, std::move(value));
}

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

  // Parse variable 'value'
  _result_value = ::mlir::FieldParser<::mlir::amdgpu::AddressSpace>::parse(odsParser);
  if (::mlir::failed(_result_value)) {
    odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse AMDGPU_AddressSpaceAttr parameter 'value' which is to be a `::mlir::amdgpu::AddressSpace`");
    return {};
  }
  // Parse literal '>'
  if (odsParser.parseGreater()) return {};
  assert(::mlir::succeeded(_result_value));
  return AddressSpaceAttr::get(odsParser.getContext(),
      ::mlir::amdgpu::AddressSpace((*_result_value)));
}

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

::mlir::amdgpu::AddressSpace AddressSpaceAttr::getValue() const {
  return getImpl()->value;
}


} // namespace mlir::amdgpu
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::amdgpu::AddressSpaceAttr)
namespace mlir::amdgpu {

namespace detail {

struct DPPPermAttrStorage : public ::mlir::AttributeStorage {
  using KeyTy = std::tuple<::mlir::amdgpu::DPPPerm>;
  DPPPermAttrStorage(::mlir::amdgpu::DPPPerm 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 DPPPermAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
    auto value = std::move(std::get<0>(tblgenKey));
    return new (allocator.allocate<DPPPermAttrStorage>()) DPPPermAttrStorage(std::move(value));
  }

  ::mlir::amdgpu::DPPPerm value;
};

} // namespace detail
DPPPermAttr DPPPermAttr::get(::mlir::MLIRContext *context, ::mlir::amdgpu::DPPPerm value) {
  return Base::get(context, std::move(value));
}

::mlir::Attribute DPPPermAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
  ::mlir::Builder odsBuilder(odsParser.getContext());
  ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
  (void) odsLoc;
  ::mlir::FailureOr<::mlir::amdgpu::DPPPerm> _result_value;

  // Parse variable 'value'
  _result_value = ::mlir::FieldParser<::mlir::amdgpu::DPPPerm>::parse(odsParser);
  if (::mlir::failed(_result_value)) {
    odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse AMDGPU_DPPPermAttr parameter 'value' which is to be a `::mlir::amdgpu::DPPPerm`");
    return {};
  }
  assert(::mlir::succeeded(_result_value));
  return DPPPermAttr::get(odsParser.getContext(),
      ::mlir::amdgpu::DPPPerm((*_result_value)));
}

void DPPPermAttr::print(::mlir::AsmPrinter &odsPrinter) const {
  ::mlir::Builder odsBuilder(getContext());
  odsPrinter.printStrippedAttrOrType(getValue());
}

::mlir::amdgpu::DPPPerm DPPPermAttr::getValue() const {
  return getImpl()->value;
}


} // namespace mlir::amdgpu
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::amdgpu::DPPPermAttr)
namespace mlir::amdgpu {

namespace detail {

struct LoadTemporalHintAttrStorage : public ::mlir::AttributeStorage {
  using KeyTy = std::tuple<::mlir::amdgpu::LoadTemporalHint>;
  LoadTemporalHintAttrStorage(::mlir::amdgpu::LoadTemporalHint 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 LoadTemporalHintAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
    auto value = std::move(std::get<0>(tblgenKey));
    return new (allocator.allocate<LoadTemporalHintAttrStorage>()) LoadTemporalHintAttrStorage(std::move(value));
  }

  ::mlir::amdgpu::LoadTemporalHint value;
};

} // namespace detail
LoadTemporalHintAttr LoadTemporalHintAttr::get(::mlir::MLIRContext *context, ::mlir::amdgpu::LoadTemporalHint value) {
  return Base::get(context, std::move(value));
}

::mlir::Attribute LoadTemporalHintAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
  ::mlir::Builder odsBuilder(odsParser.getContext());
  ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
  (void) odsLoc;
  ::mlir::FailureOr<::mlir::amdgpu::LoadTemporalHint> _result_value;

  // Parse variable 'value'
  _result_value = ::mlir::FieldParser<::mlir::amdgpu::LoadTemporalHint>::parse(odsParser);
  if (::mlir::failed(_result_value)) {
    odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse AMDGPU_LoadTemporalHintAttr parameter 'value' which is to be a `::mlir::amdgpu::LoadTemporalHint`");
    return {};
  }
  assert(::mlir::succeeded(_result_value));
  return LoadTemporalHintAttr::get(odsParser.getContext(),
      ::mlir::amdgpu::LoadTemporalHint((*_result_value)));
}

void LoadTemporalHintAttr::print(::mlir::AsmPrinter &odsPrinter) const {
  ::mlir::Builder odsBuilder(getContext());
  odsPrinter.printStrippedAttrOrType(getValue());
}

::mlir::amdgpu::LoadTemporalHint LoadTemporalHintAttr::getValue() const {
  return getImpl()->value;
}


} // namespace mlir::amdgpu
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::amdgpu::LoadTemporalHintAttr)
namespace mlir::amdgpu {

namespace detail {

struct ScopeAttrStorage : public ::mlir::AttributeStorage {
  using KeyTy = std::tuple<::mlir::amdgpu::Scope>;
  ScopeAttrStorage(::mlir::amdgpu::Scope 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 ScopeAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
    auto value = std::move(std::get<0>(tblgenKey));
    return new (allocator.allocate<ScopeAttrStorage>()) ScopeAttrStorage(std::move(value));
  }

  ::mlir::amdgpu::Scope value;
};

} // namespace detail
ScopeAttr ScopeAttr::get(::mlir::MLIRContext *context, ::mlir::amdgpu::Scope value) {
  return Base::get(context, std::move(value));
}

::mlir::Attribute ScopeAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
  ::mlir::Builder odsBuilder(odsParser.getContext());
  ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
  (void) odsLoc;
  ::mlir::FailureOr<::mlir::amdgpu::Scope> _result_value;

  // Parse variable 'value'
  _result_value = ::mlir::FieldParser<::mlir::amdgpu::Scope>::parse(odsParser);
  if (::mlir::failed(_result_value)) {
    odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse AMDGPU_CacheScopeAttr parameter 'value' which is to be a `::mlir::amdgpu::Scope`");
    return {};
  }
  assert(::mlir::succeeded(_result_value));
  return ScopeAttr::get(odsParser.getContext(),
      ::mlir::amdgpu::Scope((*_result_value)));
}

void ScopeAttr::print(::mlir::AsmPrinter &odsPrinter) const {
  ::mlir::Builder odsBuilder(getContext());
  odsPrinter.printStrippedAttrOrType(getValue());
}

::mlir::amdgpu::Scope ScopeAttr::getValue() const {
  return getImpl()->value;
}


} // namespace mlir::amdgpu
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::amdgpu::ScopeAttr)
namespace mlir::amdgpu {


/// Parse an attribute registered to this dialect.
::mlir::Attribute AMDGPUDialect::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 AMDGPUDialect::printAttribute(::mlir::Attribute attr,
                         ::mlir::DialectAsmPrinter &printer) const {
  if (::mlir::succeeded(generatedAttributePrinter(attr, printer)))
    return;
  
}

} // namespace mlir::amdgpu

#endif // GET_ATTRDEF_CLASSES

