aboutsummaryrefslogtreecommitdiff
path: root/utils/TableGen/SearchableTableEmitter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/TableGen/SearchableTableEmitter.cpp')
-rw-r--r--utils/TableGen/SearchableTableEmitter.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/utils/TableGen/SearchableTableEmitter.cpp b/utils/TableGen/SearchableTableEmitter.cpp
index f98a7c74bf0c..954b63e7253c 100644
--- a/utils/TableGen/SearchableTableEmitter.cpp
+++ b/utils/TableGen/SearchableTableEmitter.cpp
@@ -1,9 +1,8 @@
//===- SearchableTableEmitter.cpp - Generate efficiently searchable tables -==//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// 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
//
//===----------------------------------------------------------------------===//
//
@@ -142,7 +141,7 @@ private:
bool compareBy(Record *LHS, Record *RHS, const SearchIndex &Index);
bool isIntegral(Init *I) {
- return isa<BitsInit>(I) || isIntrinsic(I);
+ return isa<BitsInit>(I) || isa<CodeInit>(I) || isIntrinsic(I);
}
std::string searchableFieldType(const GenericField &Field, TypeContext Ctx) {
@@ -600,9 +599,10 @@ void SearchableTableEmitter::collectTableEntries(
for (auto &Field : Table.Fields) {
auto TI = dyn_cast<TypedInit>(EntryRec->getValueInit(Field.Name));
if (!TI) {
- PrintFatalError(Twine("Record '") + EntryRec->getName() +
- "' in table '" + Table.Name + "' is missing field '" +
- Field.Name + "'");
+ PrintFatalError(EntryRec->getLoc(),
+ Twine("Record '") + EntryRec->getName() +
+ "' in table '" + Table.Name +
+ "' is missing field '" + Field.Name + "'");
}
if (!Field.RecType) {
Field.RecType = TI->getType();
@@ -611,7 +611,7 @@ void SearchableTableEmitter::collectTableEntries(
if (!Ty)
PrintFatalError(Twine("Field '") + Field.Name + "' of table '" +
Table.Name + "' has incompatible type: " +
- Ty->getAsString() + " vs. " +
+ Field.RecType->getAsString() + " vs. " +
TI->getType()->getAsString());
Field.RecType = Ty;
}
@@ -654,8 +654,8 @@ void SearchableTableEmitter::run(raw_ostream &OS) {
StringRef FilterClass = EnumRec->getValueAsString("FilterClass");
Enum->Class = Records.getClass(FilterClass);
if (!Enum->Class)
- PrintFatalError(Twine("Enum FilterClass '") + FilterClass +
- "' does not exist");
+ PrintFatalError(EnumRec->getLoc(), Twine("Enum FilterClass '") +
+ FilterClass + "' does not exist");
collectEnumEntries(*Enum, NameField, ValueField,
Records.getAllDerivedDefinitions(FilterClass));
@@ -675,9 +675,10 @@ void SearchableTableEmitter::run(raw_ostream &OS) {
if (auto TypeOfVal = TableRec->getValue(("TypeOf_" + FieldName).str())) {
if (!parseFieldType(Table->Fields.back(), TypeOfVal->getValue())) {
- PrintFatalError(Twine("Table '") + Table->Name +
- "' has bad 'TypeOf_" + FieldName + "': " +
- TypeOfVal->getValue()->getAsString());
+ PrintFatalError(TableRec->getLoc(),
+ Twine("Table '") + Table->Name +
+ "' has bad 'TypeOf_" + FieldName +
+ "': " + TypeOfVal->getValue()->getAsString());
}
}
}
@@ -705,8 +706,10 @@ void SearchableTableEmitter::run(raw_ostream &OS) {
Record *TableRec = IndexRec->getValueAsDef("Table");
auto It = TableMap.find(TableRec);
if (It == TableMap.end())
- PrintFatalError(Twine("SearchIndex '") + IndexRec->getName() +
- "' refers to non-existing table '" + TableRec->getName());
+ PrintFatalError(IndexRec->getLoc(),
+ Twine("SearchIndex '") + IndexRec->getName() +
+ "' refers to non-existing table '" +
+ TableRec->getName());
GenericTable &Table = *It->second;
Table.Indices.push_back(parseSearchIndex(