MCPcopy Create free account
hub / github.com/NVIDIA/cuda-tile / parseGenericEnumAttr

Function parseGenericEnumAttr

lib/Bytecode/Reader/BytecodeReader.cpp:447–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

445/// Generic helper to parse an enum attribute.
446template <typename AttrType>
447static LogicalResult parseGenericEnumAttr(EncodingReader &reader,
448 MLIRContext &context,
449 AttrType &nativeValue) {
450 uint64_t rawEnumValueU64;
451 if (failed(reader.readVarInt(rawEnumValueU64)))
452 return reader.emitError() << "failed to read VarInt for enum attribute.";
453 uint32_t rawEnumValue = static_cast<uint32_t>(rawEnumValueU64);
454
455 using EnumType = decltype(std::declval<AttrType>().getValue());
456 static_assert(!std::is_void_v<EnumType>,
457 "EnumType cannot be void for enum attribute.");
458 std::optional<EnumType> enumOpt = symbolizeEnum<EnumType>(rawEnumValue);
459 if (!enumOpt)
460 return reader.emitError()
461 << "invalid integer value for enum type: " << rawEnumValue;
462 nativeValue = AttrType::get(&context, enumOpt.value());
463 return success();
464}
465
466//===----------------------------------------------------------------------===//
467// LazyTypeTable: Manages lazy parsing and caching of types from the type

Callers 1

parseOpAttributeMethod · 0.85

Calls 2

readVarIntMethod · 0.80
emitErrorMethod · 0.80

Tested by

no test coverage detected