CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
137 lines
3.7 KiB
C++
137 lines
3.7 KiB
C++
//===- EnumInfo.cpp - EnumInfo wrapper class ----------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir/TableGen/EnumInfo.h"
|
|
#include "mlir/TableGen/Attribute.h"
|
|
#include "llvm/TableGen/Record.h"
|
|
|
|
using namespace mlir;
|
|
using namespace mlir::tblgen;
|
|
|
|
using llvm::DefInit;
|
|
using llvm::Init;
|
|
using llvm::Record;
|
|
|
|
EnumCase::EnumCase(const Record *record) : def(record) {
|
|
assert(def->isSubClassOf("EnumCase") &&
|
|
"must be subclass of TableGen 'EnumCase' class");
|
|
}
|
|
|
|
EnumCase::EnumCase(const DefInit *init) : EnumCase(init->getDef()) {}
|
|
|
|
StringRef EnumCase::getSymbol() const {
|
|
return def->getValueAsString("symbol");
|
|
}
|
|
|
|
StringRef EnumCase::getStr() const { return def->getValueAsString("str"); }
|
|
|
|
int64_t EnumCase::getValue() const { return def->getValueAsInt("value"); }
|
|
|
|
const Record &EnumCase::getDef() const { return *def; }
|
|
|
|
EnumInfo::EnumInfo(const Record *record) : def(record) {
|
|
assert(isSubClassOf("EnumInfo") &&
|
|
"must be subclass of TableGen 'EnumInfo' class");
|
|
}
|
|
|
|
EnumInfo::EnumInfo(const Record &record) : EnumInfo(&record) {}
|
|
|
|
EnumInfo::EnumInfo(const DefInit *init) : EnumInfo(init->getDef()) {}
|
|
|
|
bool EnumInfo::isSubClassOf(StringRef className) const {
|
|
return def->isSubClassOf(className);
|
|
}
|
|
|
|
bool EnumInfo::isEnumAttr() const { return isSubClassOf("EnumAttrInfo"); }
|
|
|
|
std::optional<Attribute> EnumInfo::asEnumAttr() const {
|
|
if (isEnumAttr())
|
|
return Attribute(def);
|
|
return std::nullopt;
|
|
}
|
|
|
|
bool EnumInfo::isBitEnum() const { return isSubClassOf("BitEnumBase"); }
|
|
|
|
StringRef EnumInfo::getEnumClassName() const {
|
|
return def->getValueAsString("className");
|
|
}
|
|
|
|
StringRef EnumInfo::getSummary() const {
|
|
return def->getValueAsString("summary");
|
|
}
|
|
|
|
StringRef EnumInfo::getDescription() const {
|
|
return def->getValueAsString("description");
|
|
}
|
|
|
|
StringRef EnumInfo::getCppNamespace() const {
|
|
return def->getValueAsString("cppNamespace");
|
|
}
|
|
|
|
int64_t EnumInfo::getBitwidth() const { return def->getValueAsInt("bitwidth"); }
|
|
|
|
StringRef EnumInfo::getUnderlyingType() const {
|
|
return def->getValueAsString("underlyingType");
|
|
}
|
|
|
|
StringRef EnumInfo::getUnderlyingToSymbolFnName() const {
|
|
return def->getValueAsString("underlyingToSymbolFnName");
|
|
}
|
|
|
|
StringRef EnumInfo::getStringToSymbolFnName() const {
|
|
return def->getValueAsString("stringToSymbolFnName");
|
|
}
|
|
|
|
StringRef EnumInfo::getSymbolToStringFnName() const {
|
|
return def->getValueAsString("symbolToStringFnName");
|
|
}
|
|
|
|
StringRef EnumInfo::getSymbolToStringFnRetType() const {
|
|
return def->getValueAsString("symbolToStringFnRetType");
|
|
}
|
|
|
|
StringRef EnumInfo::getMaxEnumValFnName() const {
|
|
return def->getValueAsString("maxEnumValFnName");
|
|
}
|
|
|
|
std::vector<EnumCase> EnumInfo::getAllCases() const {
|
|
const auto *inits = def->getValueAsListInit("enumerants");
|
|
|
|
std::vector<EnumCase> cases;
|
|
cases.reserve(inits->size());
|
|
|
|
for (const Init *init : *inits) {
|
|
cases.emplace_back(cast<DefInit>(init));
|
|
}
|
|
|
|
return cases;
|
|
}
|
|
|
|
bool EnumInfo::genSpecializedAttr() const {
|
|
return isSubClassOf("EnumAttrInfo") &&
|
|
def->getValueAsBit("genSpecializedAttr");
|
|
}
|
|
|
|
const Record *EnumInfo::getBaseAttrClass() const {
|
|
return def->getValueAsDef("baseAttrClass");
|
|
}
|
|
|
|
StringRef EnumInfo::getSpecializedAttrClassName() const {
|
|
return def->getValueAsString("specializedAttrClassName");
|
|
}
|
|
|
|
bool EnumInfo::printBitEnumPrimaryGroups() const {
|
|
return def->getValueAsBit("printBitEnumPrimaryGroups");
|
|
}
|
|
|
|
bool EnumInfo::printBitEnumQuoted() const {
|
|
return def->getValueAsBit("printBitEnumQuoted");
|
|
}
|
|
|
|
const Record &EnumInfo::getDef() const { return *def; }
|