#include "Basic/CodeGenIntrinsics.h"
#include "Common/CodeGenTarget.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
#include "llvm/TableGen/TableGenBackend.h"
#include <algorithm>
#include <set>
#include <string>
#include <vector>
usingnamespacellvm;
#define DEBUG_TYPE …
namespace {
int64_t getAsInt(Init *B) { … }
int64_t getInt(Record *R, StringRef Field) { … }
struct GenericEnum { … };
struct GenericField { … };
struct SearchIndex { … };
struct GenericTable { … };
class SearchableTableEmitter { … };
}
int64_t SearchableTableEmitter::getNumericKey(const SearchIndex &Index,
Record *Rec) { … }
bool SearchableTableEmitter::compareBy(Record *LHS, Record *RHS,
const SearchIndex &Index) { … }
void SearchableTableEmitter::emitIfdef(StringRef Guard, raw_ostream &OS) { … }
void SearchableTableEmitter::emitGenericEnum(const GenericEnum &Enum,
raw_ostream &OS) { … }
void SearchableTableEmitter::emitLookupFunction(const GenericTable &Table,
const SearchIndex &Index,
bool IsPrimary,
raw_ostream &OS) { … }
void SearchableTableEmitter::emitLookupDeclaration(const GenericTable &Table,
const SearchIndex &Index,
raw_ostream &OS) { … }
void SearchableTableEmitter::emitGenericTable(const GenericTable &Table,
raw_ostream &OS) { … }
bool SearchableTableEmitter::parseFieldType(GenericField &Field, Init *TypeOf) { … }
std::unique_ptr<SearchIndex> SearchableTableEmitter::parseSearchIndex(
GenericTable &Table, const RecordVal *KeyRecVal, StringRef Name,
const std::vector<StringRef> &Key, bool EarlyOut, bool ReturnRange) { … }
void SearchableTableEmitter::collectEnumEntries(
GenericEnum &Enum, StringRef NameField, StringRef ValueField,
const std::vector<Record *> &Items) { … }
void SearchableTableEmitter::collectTableEntries(
GenericTable &Table, const std::vector<Record *> &Items) { … }
void SearchableTableEmitter::run(raw_ostream &OS) { … }
static TableGen::Emitter::OptClass<SearchableTableEmitter>
X("gen-searchable-tables", "Generate generic binary-searchable table");