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

#ifdef GET_TYPEDEF_LIST
#undef GET_TYPEDEF_LIST

::mlir::acc::DataBoundsType,
::mlir::acc::DeclareTokenType,
::mlir::acc::PrivateType

#endif // GET_TYPEDEF_LIST

#ifdef GET_TYPEDEF_CLASSES
#undef GET_TYPEDEF_CLASSES

static ::mlir::OptionalParseResult generatedTypeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type &value) {
  return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser)
    .Case(::mlir::acc::DataBoundsType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
      value = ::mlir::acc::DataBoundsType::get(parser.getContext());
      return ::mlir::success(!!value);
    })
    .Case(::mlir::acc::DeclareTokenType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
      value = ::mlir::acc::DeclareTokenType::get(parser.getContext());
      return ::mlir::success(!!value);
    })
    .Case(::mlir::acc::PrivateType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
      value = ::mlir::acc::PrivateType::parse(parser);
      return ::mlir::success(!!value);
    })
    .Default([&](llvm::StringRef keyword, llvm::SMLoc) {
      *mnemonic = keyword;
      return std::nullopt;
    });
}

static ::llvm::LogicalResult generatedTypePrinter(::mlir::Type def, ::mlir::AsmPrinter &printer) {
  return ::llvm::TypeSwitch<::mlir::Type, ::llvm::LogicalResult>(def)    .Case<::mlir::acc::DataBoundsType>([&](auto t) {
      printer << ::mlir::acc::DataBoundsType::getMnemonic();
      return ::mlir::success();
    })
    .Case<::mlir::acc::DeclareTokenType>([&](auto t) {
      printer << ::mlir::acc::DeclareTokenType::getMnemonic();
      return ::mlir::success();
    })
    .Case<::mlir::acc::PrivateType>([&](auto t) {
      printer << ::mlir::acc::PrivateType::getMnemonic();
t.print(printer);
      return ::mlir::success();
    })
    .Default([](auto) { return ::mlir::failure(); });
}

namespace mlir::acc {


} // namespace mlir::acc
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::DataBoundsType)
namespace mlir::acc {


} // namespace mlir::acc
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::DeclareTokenType)
namespace mlir::acc {

namespace detail {

struct PrivateTypeStorage : public ::mlir::TypeStorage {
  using KeyTy = std::tuple<mlir::Type>;
  PrivateTypeStorage(mlir::Type baseTy) : baseTy(std::move(baseTy)) {}

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

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

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

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

  mlir::Type baseTy;
};

} // namespace detail
PrivateType PrivateType::get(::mlir::MLIRContext *context, mlir::Type baseTy) {
  return Base::get(context, std::move(baseTy));
}

::mlir::Type PrivateType::parse(::mlir::AsmParser &odsParser) {
  ::mlir::Builder odsBuilder(odsParser.getContext());
  ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
  (void) odsLoc;
  ::mlir::FailureOr<mlir::Type> _result_baseTy;
  // Parse literal '<'
  if (odsParser.parseLess()) return {};

  // Parse variable 'baseTy'
  _result_baseTy = ::mlir::FieldParser<mlir::Type>::parse(odsParser);
  if (::mlir::failed(_result_baseTy)) {
    odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse OpenACC_PrivateType parameter 'baseTy' which is to be a `mlir::Type`");
    return {};
  }
  // Parse literal '>'
  if (odsParser.parseGreater()) return {};
  assert(::mlir::succeeded(_result_baseTy));
  return PrivateType::get(odsParser.getContext(),
      mlir::Type((*_result_baseTy)));
}

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

mlir::Type PrivateType::getBaseTy() const {
  return getImpl()->baseTy;
}


} // namespace mlir::acc
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::acc::PrivateType)
namespace mlir::acc {


/// Parse a type registered to this dialect.
::mlir::Type OpenACCDialect::parseType(::mlir::DialectAsmParser &parser) const {
  ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
  ::llvm::StringRef mnemonic;
  ::mlir::Type genType;
  auto parseResult = generatedTypeParser(parser, &mnemonic, genType);
  if (parseResult.has_value())
    return genType;
  
  parser.emitError(typeLoc) << "unknown  type `"
      << mnemonic << "` in dialect `" << getNamespace() << "`";
  return {};
}
/// Print a type registered to this dialect.
void OpenACCDialect::printType(::mlir::Type type,
                    ::mlir::DialectAsmPrinter &printer) const {
  if (::mlir::succeeded(generatedTypePrinter(type, printer)))
    return;
  
}

} // namespace mlir::acc

#endif // GET_TYPEDEF_CLASSES

