/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
|*                                                                            *|
|* Enum Utility Declarations                                                  *|
|*                                                                            *|
|* Automatically generated file, do not edit!                                 *|
|* From: GPUDeviceMappingAttr.td                                              *|
|*                                                                            *|
\*===----------------------------------------------------------------------===*/

namespace mlir::gpu {

// GPU address space
enum class AddressSpace : uint32_t {
  Global = 1,
  Workgroup = 2,
  Private = 3,
  Constant = 4,
};

::std::optional<AddressSpace> symbolizeAddressSpace(uint32_t);
::llvm::StringRef stringifyAddressSpace(AddressSpace);
::std::optional<AddressSpace> symbolizeAddressSpace(::llvm::StringRef);
inline constexpr unsigned getMaxEnumValForAddressSpace() {
  return 4;
}


inline ::llvm::StringRef stringifyEnum(AddressSpace enumValue) {
  return stringifyAddressSpace(enumValue);
}

template <typename EnumType>
::std::optional<EnumType> symbolizeEnum(::llvm::StringRef);

template <>
inline ::std::optional<AddressSpace> symbolizeEnum<AddressSpace>(::llvm::StringRef str) {
  return symbolizeAddressSpace(str);
}

} // namespace mlir::gpu

namespace mlir {
template <typename T, typename>
struct FieldParser;

template<>
struct FieldParser<::mlir::gpu::AddressSpace, ::mlir::gpu::AddressSpace> {
  template <typename ParserT>
  static FailureOr<::mlir::gpu::AddressSpace> parse(ParserT &parser) {
    // Parse the keyword/string containing the enum.
    std::string enumKeyword;
    auto loc = parser.getCurrentLocation();
    if (failed(parser.parseOptionalKeywordOrString(&enumKeyword)))
      return parser.emitError(loc, "expected keyword for GPU address space");

    // Symbolize the keyword.
    if (::std::optional<::mlir::gpu::AddressSpace> attr = ::mlir::gpu::symbolizeEnum<::mlir::gpu::AddressSpace>(enumKeyword))
      return *attr;
    return parser.emitError(loc, "expected one of [global, workgroup, private, constant] for GPU address space, got: ") << enumKeyword;
  }
};

/// Support for std::optional, useful in attribute/type definition where the enum is
/// used as:
///
///    let parameters = (ins OptionalParameter<"std::optional<TheEnumName>">:$value);
template<>
struct FieldParser<std::optional<::mlir::gpu::AddressSpace>, std::optional<::mlir::gpu::AddressSpace>> {
  template <typename ParserT>
  static FailureOr<std::optional<::mlir::gpu::AddressSpace>> parse(ParserT &parser) {
    // Parse the keyword/string containing the enum.
    std::string enumKeyword;
    auto loc = parser.getCurrentLocation();
    if (failed(parser.parseOptionalKeywordOrString(&enumKeyword, {"global", "workgroup", "private", "constant"})))
      return std::optional<::mlir::gpu::AddressSpace>{};

    // Symbolize the keyword.
    if (::std::optional<::mlir::gpu::AddressSpace> attr = ::mlir::gpu::symbolizeEnum<::mlir::gpu::AddressSpace>(enumKeyword))
      return attr;
    return parser.emitError(loc, "expected one of [global, workgroup, private, constant] for GPU address space, got: ") << enumKeyword;
  }
};
} // namespace mlir

namespace llvm {
inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::gpu::AddressSpace value) {
  auto valueStr = stringifyEnum(value);
  return p << valueStr;
}
} // namespace llvm

namespace llvm {
template<> struct DenseMapInfo<::mlir::gpu::AddressSpace> {
  using StorageInfo = ::llvm::DenseMapInfo<uint32_t>;

  static unsigned getHashValue(const ::mlir::gpu::AddressSpace &val) {
    return StorageInfo::getHashValue(static_cast<uint32_t>(val));
  }

  static bool isEqual(const ::mlir::gpu::AddressSpace &lhs, const ::mlir::gpu::AddressSpace &rhs) {
    return lhs == rhs;
  }
};
}

namespace mlir::gpu {

// barrier execution scope
enum class BarrierScope : uint32_t {
  Subgroup = 1,
  Workgroup = 2,
  Cluster = 3,
};

::std::optional<BarrierScope> symbolizeBarrierScope(uint32_t);
::llvm::StringRef stringifyBarrierScope(BarrierScope);
::std::optional<BarrierScope> symbolizeBarrierScope(::llvm::StringRef);
inline constexpr unsigned getMaxEnumValForBarrierScope() {
  return 3;
}


inline ::llvm::StringRef stringifyEnum(BarrierScope enumValue) {
  return stringifyBarrierScope(enumValue);
}

template <typename EnumType>
::std::optional<EnumType> symbolizeEnum(::llvm::StringRef);

template <>
inline ::std::optional<BarrierScope> symbolizeEnum<BarrierScope>(::llvm::StringRef str) {
  return symbolizeBarrierScope(str);
}

} // namespace mlir::gpu

namespace mlir {
template <typename T, typename>
struct FieldParser;

template<>
struct FieldParser<::mlir::gpu::BarrierScope, ::mlir::gpu::BarrierScope> {
  template <typename ParserT>
  static FailureOr<::mlir::gpu::BarrierScope> parse(ParserT &parser) {
    // Parse the keyword/string containing the enum.
    std::string enumKeyword;
    auto loc = parser.getCurrentLocation();
    if (failed(parser.parseOptionalKeywordOrString(&enumKeyword)))
      return parser.emitError(loc, "expected keyword for barrier execution scope");

    // Symbolize the keyword.
    if (::std::optional<::mlir::gpu::BarrierScope> attr = ::mlir::gpu::symbolizeEnum<::mlir::gpu::BarrierScope>(enumKeyword))
      return *attr;
    return parser.emitError(loc, "expected one of [subgroup, workgroup, cluster] for barrier execution scope, got: ") << enumKeyword;
  }
};

/// Support for std::optional, useful in attribute/type definition where the enum is
/// used as:
///
///    let parameters = (ins OptionalParameter<"std::optional<TheEnumName>">:$value);
template<>
struct FieldParser<std::optional<::mlir::gpu::BarrierScope>, std::optional<::mlir::gpu::BarrierScope>> {
  template <typename ParserT>
  static FailureOr<std::optional<::mlir::gpu::BarrierScope>> parse(ParserT &parser) {
    // Parse the keyword/string containing the enum.
    std::string enumKeyword;
    auto loc = parser.getCurrentLocation();
    if (failed(parser.parseOptionalKeywordOrString(&enumKeyword, {"subgroup", "workgroup", "cluster"})))
      return std::optional<::mlir::gpu::BarrierScope>{};

    // Symbolize the keyword.
    if (::std::optional<::mlir::gpu::BarrierScope> attr = ::mlir::gpu::symbolizeEnum<::mlir::gpu::BarrierScope>(enumKeyword))
      return attr;
    return parser.emitError(loc, "expected one of [subgroup, workgroup, cluster] for barrier execution scope, got: ") << enumKeyword;
  }
};
} // namespace mlir

namespace llvm {
inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::gpu::BarrierScope value) {
  auto valueStr = stringifyEnum(value);
  return p << valueStr;
}
} // namespace llvm

namespace llvm {
template<> struct DenseMapInfo<::mlir::gpu::BarrierScope> {
  using StorageInfo = ::llvm::DenseMapInfo<uint32_t>;

  static unsigned getHashValue(const ::mlir::gpu::BarrierScope &val) {
    return StorageInfo::getHashValue(static_cast<uint32_t>(val));
  }

  static bool isEqual(const ::mlir::gpu::BarrierScope &lhs, const ::mlir::gpu::BarrierScope &rhs) {
    return lhs == rhs;
  }
};
}

namespace mlir::gpu {

// a dimension, either 'x', 'y', or 'z'
enum class Dimension : uint32_t {
  x = 0,
  y = 1,
  z = 2,
};

::std::optional<Dimension> symbolizeDimension(uint32_t);
::llvm::StringRef stringifyDimension(Dimension);
::std::optional<Dimension> symbolizeDimension(::llvm::StringRef);
inline constexpr unsigned getMaxEnumValForDimension() {
  return 2;
}


inline ::llvm::StringRef stringifyEnum(Dimension enumValue) {
  return stringifyDimension(enumValue);
}

template <typename EnumType>
::std::optional<EnumType> symbolizeEnum(::llvm::StringRef);

template <>
inline ::std::optional<Dimension> symbolizeEnum<Dimension>(::llvm::StringRef str) {
  return symbolizeDimension(str);
}

} // namespace mlir::gpu

namespace mlir {
template <typename T, typename>
struct FieldParser;

template<>
struct FieldParser<::mlir::gpu::Dimension, ::mlir::gpu::Dimension> {
  template <typename ParserT>
  static FailureOr<::mlir::gpu::Dimension> parse(ParserT &parser) {
    // Parse the keyword/string containing the enum.
    std::string enumKeyword;
    auto loc = parser.getCurrentLocation();
    if (failed(parser.parseOptionalKeywordOrString(&enumKeyword)))
      return parser.emitError(loc, "expected keyword for a dimension, either 'x', 'y', or 'z'");

    // Symbolize the keyword.
    if (::std::optional<::mlir::gpu::Dimension> attr = ::mlir::gpu::symbolizeEnum<::mlir::gpu::Dimension>(enumKeyword))
      return *attr;
    return parser.emitError(loc, "expected one of [x, y, z] for a dimension, either 'x', 'y', or 'z', got: ") << enumKeyword;
  }
};

/// Support for std::optional, useful in attribute/type definition where the enum is
/// used as:
///
///    let parameters = (ins OptionalParameter<"std::optional<TheEnumName>">:$value);
template<>
struct FieldParser<std::optional<::mlir::gpu::Dimension>, std::optional<::mlir::gpu::Dimension>> {
  template <typename ParserT>
  static FailureOr<std::optional<::mlir::gpu::Dimension>> parse(ParserT &parser) {
    // Parse the keyword/string containing the enum.
    std::string enumKeyword;
    auto loc = parser.getCurrentLocation();
    if (failed(parser.parseOptionalKeywordOrString(&enumKeyword, {"x", "y", "z"})))
      return std::optional<::mlir::gpu::Dimension>{};

    // Symbolize the keyword.
    if (::std::optional<::mlir::gpu::Dimension> attr = ::mlir::gpu::symbolizeEnum<::mlir::gpu::Dimension>(enumKeyword))
      return attr;
    return parser.emitError(loc, "expected one of [x, y, z] for a dimension, either 'x', 'y', or 'z', got: ") << enumKeyword;
  }
};
} // namespace mlir

namespace llvm {
inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::gpu::Dimension value) {
  auto valueStr = stringifyEnum(value);
  return p << valueStr;
}
} // namespace llvm

namespace llvm {
template<> struct DenseMapInfo<::mlir::gpu::Dimension> {
  using StorageInfo = ::llvm::DenseMapInfo<uint32_t>;

  static unsigned getHashValue(const ::mlir::gpu::Dimension &val) {
    return StorageInfo::getHashValue(static_cast<uint32_t>(val));
  }

  static bool isEqual(const ::mlir::gpu::Dimension &lhs, const ::mlir::gpu::Dimension &rhs) {
    return lhs == rhs;
  }
};
}

namespace mlir::gpu {

// the possible kinds of launch dimension
enum class DimensionKind : uint32_t {
  Other = 0,
  Block = 1,
  Grid = 2,
  Cluster = 3,
};

::std::optional<DimensionKind> symbolizeDimensionKind(uint32_t);
::llvm::StringRef stringifyDimensionKind(DimensionKind);
::std::optional<DimensionKind> symbolizeDimensionKind(::llvm::StringRef);
inline constexpr unsigned getMaxEnumValForDimensionKind() {
  return 3;
}


inline ::llvm::StringRef stringifyEnum(DimensionKind enumValue) {
  return stringifyDimensionKind(enumValue);
}

template <typename EnumType>
::std::optional<EnumType> symbolizeEnum(::llvm::StringRef);

template <>
inline ::std::optional<DimensionKind> symbolizeEnum<DimensionKind>(::llvm::StringRef str) {
  return symbolizeDimensionKind(str);
}

} // namespace mlir::gpu

namespace mlir {
template <typename T, typename>
struct FieldParser;

template<>
struct FieldParser<::mlir::gpu::DimensionKind, ::mlir::gpu::DimensionKind> {
  template <typename ParserT>
  static FailureOr<::mlir::gpu::DimensionKind> parse(ParserT &parser) {
    // Parse the keyword/string containing the enum.
    std::string enumKeyword;
    auto loc = parser.getCurrentLocation();
    if (failed(parser.parseOptionalKeywordOrString(&enumKeyword)))
      return parser.emitError(loc, "expected keyword for the possible kinds of launch dimension");

    // Symbolize the keyword.
    if (::std::optional<::mlir::gpu::DimensionKind> attr = ::mlir::gpu::symbolizeEnum<::mlir::gpu::DimensionKind>(enumKeyword))
      return *attr;
    return parser.emitError(loc, "expected one of [other, block, grid, cluster] for the possible kinds of launch dimension, got: ") << enumKeyword;
  }
};

/// Support for std::optional, useful in attribute/type definition where the enum is
/// used as:
///
///    let parameters = (ins OptionalParameter<"std::optional<TheEnumName>">:$value);
template<>
struct FieldParser<std::optional<::mlir::gpu::DimensionKind>, std::optional<::mlir::gpu::DimensionKind>> {
  template <typename ParserT>
  static FailureOr<std::optional<::mlir::gpu::DimensionKind>> parse(ParserT &parser) {
    // Parse the keyword/string containing the enum.
    std::string enumKeyword;
    auto loc = parser.getCurrentLocation();
    if (failed(parser.parseOptionalKeywordOrString(&enumKeyword, {"other", "block", "grid", "cluster"})))
      return std::optional<::mlir::gpu::DimensionKind>{};

    // Symbolize the keyword.
    if (::std::optional<::mlir::gpu::DimensionKind> attr = ::mlir::gpu::symbolizeEnum<::mlir::gpu::DimensionKind>(enumKeyword))
      return attr;
    return parser.emitError(loc, "expected one of [other, block, grid, cluster] for the possible kinds of launch dimension, got: ") << enumKeyword;
  }
};
} // namespace mlir

namespace llvm {
inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::gpu::DimensionKind value) {
  auto valueStr = stringifyEnum(value);
  return p << valueStr;
}
} // namespace llvm

namespace llvm {
template<> struct DenseMapInfo<::mlir::gpu::DimensionKind> {
  using StorageInfo = ::llvm::DenseMapInfo<uint32_t>;

  static unsigned getHashValue(const ::mlir::gpu::DimensionKind &val) {
    return StorageInfo::getHashValue(static_cast<uint32_t>(val));
  }

  static bool isEqual(const ::mlir::gpu::DimensionKind &lhs, const ::mlir::gpu::DimensionKind &rhs) {
    return lhs == rhs;
  }
};
}

namespace mlir::gpu {

// Mapping ids for loop mapping
enum class MappingId : uint64_t {
  DimX = 0,
  DimY = 1,
  DimZ = 2,
  LinearDim0 = 3,
  LinearDim1 = 4,
  LinearDim2 = 5,
  LinearDim3 = 6,
  LinearDim4 = 7,
  LinearDim5 = 8,
  LinearDim6 = 9,
  LinearDim7 = 10,
  LinearDim8 = 11,
  LinearDim9 = 12,
};

::std::optional<MappingId> symbolizeMappingId(uint64_t);
::llvm::StringRef stringifyMappingId(MappingId);
::std::optional<MappingId> symbolizeMappingId(::llvm::StringRef);
inline constexpr unsigned getMaxEnumValForMappingId() {
  return 12;
}


inline ::llvm::StringRef stringifyEnum(MappingId enumValue) {
  return stringifyMappingId(enumValue);
}

template <typename EnumType>
::std::optional<EnumType> symbolizeEnum(::llvm::StringRef);

template <>
inline ::std::optional<MappingId> symbolizeEnum<MappingId>(::llvm::StringRef str) {
  return symbolizeMappingId(str);
}

class MappingIdAttr : public ::mlir::IntegerAttr {
public:
  using ValueType = MappingId;
  using ::mlir::IntegerAttr::IntegerAttr;
  static bool classof(::mlir::Attribute attr);
  static MappingIdAttr get(::mlir::MLIRContext *context, MappingId val);
  MappingId getValue() const;
};

} // namespace mlir::gpu

namespace mlir {
template <typename T, typename>
struct FieldParser;

template<>
struct FieldParser<::mlir::gpu::MappingId, ::mlir::gpu::MappingId> {
  template <typename ParserT>
  static FailureOr<::mlir::gpu::MappingId> parse(ParserT &parser) {
    // Parse the keyword/string containing the enum.
    std::string enumKeyword;
    auto loc = parser.getCurrentLocation();
    if (failed(parser.parseOptionalKeywordOrString(&enumKeyword)))
      return parser.emitError(loc, "expected keyword for Mapping ids for loop mapping");

    // Symbolize the keyword.
    if (::std::optional<::mlir::gpu::MappingId> attr = ::mlir::gpu::symbolizeEnum<::mlir::gpu::MappingId>(enumKeyword))
      return *attr;
    return parser.emitError(loc, "expected one of [x, y, z, linear_dim_0, linear_dim_1, linear_dim_2, linear_dim_3, linear_dim_4, linear_dim_5, linear_dim_6, linear_dim_7, linear_dim_8, linear_dim_9] for Mapping ids for loop mapping, got: ") << enumKeyword;
  }
};

/// Support for std::optional, useful in attribute/type definition where the enum is
/// used as:
///
///    let parameters = (ins OptionalParameter<"std::optional<TheEnumName>">:$value);
template<>
struct FieldParser<std::optional<::mlir::gpu::MappingId>, std::optional<::mlir::gpu::MappingId>> {
  template <typename ParserT>
  static FailureOr<std::optional<::mlir::gpu::MappingId>> parse(ParserT &parser) {
    // Parse the keyword/string containing the enum.
    std::string enumKeyword;
    auto loc = parser.getCurrentLocation();
    if (failed(parser.parseOptionalKeywordOrString(&enumKeyword, {"x", "y", "z", "linear_dim_0", "linear_dim_1", "linear_dim_2", "linear_dim_3", "linear_dim_4", "linear_dim_5", "linear_dim_6", "linear_dim_7", "linear_dim_8", "linear_dim_9"})))
      return std::optional<::mlir::gpu::MappingId>{};

    // Symbolize the keyword.
    if (::std::optional<::mlir::gpu::MappingId> attr = ::mlir::gpu::symbolizeEnum<::mlir::gpu::MappingId>(enumKeyword))
      return attr;
    return parser.emitError(loc, "expected one of [x, y, z, linear_dim_0, linear_dim_1, linear_dim_2, linear_dim_3, linear_dim_4, linear_dim_5, linear_dim_6, linear_dim_7, linear_dim_8, linear_dim_9] for Mapping ids for loop mapping, got: ") << enumKeyword;
  }
};
} // namespace mlir

namespace llvm {
inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::gpu::MappingId value) {
  auto valueStr = stringifyEnum(value);
  return p << valueStr;
}
} // namespace llvm

namespace llvm {
template<> struct DenseMapInfo<::mlir::gpu::MappingId> {
  using StorageInfo = ::llvm::DenseMapInfo<uint64_t>;

  static unsigned getHashValue(const ::mlir::gpu::MappingId &val) {
    return StorageInfo::getHashValue(static_cast<uint64_t>(val));
  }

  static bool isEqual(const ::mlir::gpu::MappingId &lhs, const ::mlir::gpu::MappingId &rhs) {
    return lhs == rhs;
  }
};
}

