llvm/llvm/lib/TableGen/Record.cpp

//===- Record.cpp - Record implementation ---------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// Implement the tablegen record classes.
//
//===----------------------------------------------------------------------===//

#include "llvm/TableGen/Record.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/SMLoc.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/TGTimer.h"
#include <cassert>
#include <cstdint>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>

usingnamespacellvm;

#define DEBUG_TYPE

//===----------------------------------------------------------------------===//
//    Context
//===----------------------------------------------------------------------===//

namespace llvm {
namespace detail {
/// This class represents the internal implementation of the RecordKeeper.
/// It contains all of the contextual static state of the Record classes. It is
/// kept out-of-line to simplify dependencies, and also make it easier for
/// internal classes to access the uniquer state of the keeper.
struct RecordKeeperImpl {};
} // namespace detail
} // namespace llvm

void detail::RecordKeeperImpl::dumpAllocationStats(raw_ostream &OS) const {}

//===----------------------------------------------------------------------===//
//    Type implementations
//===----------------------------------------------------------------------===//

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void RecTy::dump() const { print(errs()); }
#endif

const ListRecTy *RecTy::getListTy() const {}

bool RecTy::typeIsConvertibleTo(const RecTy *RHS) const {}

bool RecTy::typeIsA(const RecTy *RHS) const {}

const BitRecTy *BitRecTy::get(RecordKeeper &RK) {}

bool BitRecTy::typeIsConvertibleTo(const RecTy *RHS) const{}

const BitsRecTy *BitsRecTy::get(RecordKeeper &RK, unsigned Sz) {}

std::string BitsRecTy::getAsString() const {}

bool BitsRecTy::typeIsConvertibleTo(const RecTy *RHS) const {}

const IntRecTy *IntRecTy::get(RecordKeeper &RK) {}

bool IntRecTy::typeIsConvertibleTo(const RecTy *RHS) const {}

const StringRecTy *StringRecTy::get(RecordKeeper &RK) {}

std::string StringRecTy::getAsString() const {}

bool StringRecTy::typeIsConvertibleTo(const RecTy *RHS) const {}

std::string ListRecTy::getAsString() const {}

bool ListRecTy::typeIsConvertibleTo(const RecTy *RHS) const {}

bool ListRecTy::typeIsA(const RecTy *RHS) const {}

const DagRecTy *DagRecTy::get(RecordKeeper &RK) {}

std::string DagRecTy::getAsString() const {}

static void ProfileRecordRecTy(FoldingSetNodeID &ID,
                               ArrayRef<const Record *> Classes) {}

const RecordRecTy *RecordRecTy::get(RecordKeeper &RK,
                                    ArrayRef<const Record *> UnsortedClasses) {}

const RecordRecTy *RecordRecTy::get(const Record *Class) {}

void RecordRecTy::Profile(FoldingSetNodeID &ID) const {}

std::string RecordRecTy::getAsString() const {}

bool RecordRecTy::isSubClassOf(const Record *Class) const {}

bool RecordRecTy::typeIsConvertibleTo(const RecTy *RHS) const {}

bool RecordRecTy::typeIsA(const RecTy *RHS) const {}

static const RecordRecTy *resolveRecordTypes(const RecordRecTy *T1,
                                             const RecordRecTy *T2) {}

const RecTy *llvm::resolveTypes(const RecTy *T1, const RecTy *T2) {}

//===----------------------------------------------------------------------===//
//    Initializer implementations
//===----------------------------------------------------------------------===//

void Init::anchor() {}

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void Init::dump() const { return print(errs()); }
#endif

RecordKeeper &Init::getRecordKeeper() const {}

UnsetInit *UnsetInit::get(RecordKeeper &RK) {}

Init *UnsetInit::getCastTo(const RecTy *Ty) const {}

Init *UnsetInit::convertInitializerTo(const RecTy *Ty) const {}

static void ProfileArgumentInit(FoldingSetNodeID &ID, Init *Value,
                                ArgAuxType Aux) {}

void ArgumentInit::Profile(FoldingSetNodeID &ID) const {}

ArgumentInit *ArgumentInit::get(Init *Value, ArgAuxType Aux) {}

Init *ArgumentInit::resolveReferences(Resolver &R) const {}

BitInit *BitInit::get(RecordKeeper &RK, bool V) {}

Init *BitInit::convertInitializerTo(const RecTy *Ty) const {}

static void
ProfileBitsInit(FoldingSetNodeID &ID, ArrayRef<Init *> Range) {}

BitsInit *BitsInit::get(RecordKeeper &RK, ArrayRef<Init *> Range) {}

void BitsInit::Profile(FoldingSetNodeID &ID) const {}

Init *BitsInit::convertInitializerTo(const RecTy *Ty) const {}

std::optional<int64_t> BitsInit::convertInitializerToInt() const {}

Init *
BitsInit::convertInitializerBitRange(ArrayRef<unsigned> Bits) const {}

bool BitsInit::isConcrete() const {}

std::string BitsInit::getAsString() const {}

// resolveReferences - If there are any field references that refer to fields
// that have been filled in, we can propagate the values now.
Init *BitsInit::resolveReferences(Resolver &R) const {}

IntInit *IntInit::get(RecordKeeper &RK, int64_t V) {}

std::string IntInit::getAsString() const {}

static bool canFitInBitfield(int64_t Value, unsigned NumBits) {}

Init *IntInit::convertInitializerTo(const RecTy *Ty) const {}

Init *
IntInit::convertInitializerBitRange(ArrayRef<unsigned> Bits) const {}

AnonymousNameInit *AnonymousNameInit::get(RecordKeeper &RK, unsigned V) {}

StringInit *AnonymousNameInit::getNameInit() const {}

std::string AnonymousNameInit::getAsString() const {}

Init *AnonymousNameInit::resolveReferences(Resolver &R) const {}

StringInit *StringInit::get(RecordKeeper &RK, StringRef V, StringFormat Fmt) {}

Init *StringInit::convertInitializerTo(const RecTy *Ty) const {}

static void ProfileListInit(FoldingSetNodeID &ID, ArrayRef<Init *> Range,
                            const RecTy *EltTy) {}

ListInit *ListInit::get(ArrayRef<Init *> Range, const RecTy *EltTy) {}

void ListInit::Profile(FoldingSetNodeID &ID) const {}

Init *ListInit::convertInitializerTo(const RecTy *Ty) const {}

const Record *ListInit::getElementAsRecord(unsigned i) const {}

Init *ListInit::resolveReferences(Resolver &R) const {}

bool ListInit::isComplete() const {}

bool ListInit::isConcrete() const {}

std::string ListInit::getAsString() const {}

Init *OpInit::getBit(unsigned Bit) const {}

static void ProfileUnOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *Op,
                            const RecTy *Type) {}

UnOpInit *UnOpInit::get(UnaryOp Opc, Init *LHS, const RecTy *Type) {}

void UnOpInit::Profile(FoldingSetNodeID &ID) const {}

Init *UnOpInit::Fold(Record *CurRec, bool IsFinal) const {}

Init *UnOpInit::resolveReferences(Resolver &R) const {}

std::string UnOpInit::getAsString() const {}

static void ProfileBinOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS,
                             Init *RHS, const RecTy *Type) {}

BinOpInit *BinOpInit::get(BinaryOp Opc, Init *LHS, Init *RHS,
                          const RecTy *Type) {}

void BinOpInit::Profile(FoldingSetNodeID &ID) const {}

static StringInit *ConcatStringInits(const StringInit *I0,
                                     const StringInit *I1) {}

static StringInit *interleaveStringList(const ListInit *List,
                                        const StringInit *Delim) {}

static StringInit *interleaveIntList(const ListInit *List,
                                     const StringInit *Delim) {}

Init *BinOpInit::getStrConcat(Init *I0, Init *I1) {}

static ListInit *ConcatListInits(const ListInit *LHS,
                                 const ListInit *RHS) {}

Init *BinOpInit::getListConcat(TypedInit *LHS, Init *RHS) {}

std::optional<bool> BinOpInit::CompareInit(unsigned Opc, Init *LHS,
                                           Init *RHS) const {}

static std::optional<unsigned> getDagArgNoByKey(DagInit *Dag, Init *Key,
                                                std::string &Error) {}

Init *BinOpInit::Fold(Record *CurRec) const {}

Init *BinOpInit::resolveReferences(Resolver &R) const {}

std::string BinOpInit::getAsString() const {}

static void ProfileTernOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS,
                              Init *MHS, Init *RHS, const RecTy *Type) {}

TernOpInit *TernOpInit::get(TernaryOp Opc, Init *LHS, Init *MHS, Init *RHS,
                            const RecTy *Type) {}

void TernOpInit::Profile(FoldingSetNodeID &ID) const {}

static Init *ItemApply(Init *LHS, Init *MHSe, Init *RHS, Record *CurRec) {}

static Init *ForeachDagApply(Init *LHS, DagInit *MHSd, Init *RHS,
                             Record *CurRec) {}

// Applies RHS to all elements of MHS, using LHS as a temp variable.
static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, const RecTy *Type,
                           Record *CurRec) {}

// Evaluates RHS for all elements of MHS, using LHS as a temp variable.
// Creates a new list with the elements that evaluated to true.
static Init *FilterHelper(Init *LHS, Init *MHS, Init *RHS, const RecTy *Type,
                          Record *CurRec) {}

Init *TernOpInit::Fold(Record *CurRec) const {}

Init *TernOpInit::resolveReferences(Resolver &R) const {}

std::string TernOpInit::getAsString() const {}

static void ProfileFoldOpInit(FoldingSetNodeID &ID, Init *Start, Init *List,
                              Init *A, Init *B, Init *Expr, const RecTy *Type) {}

FoldOpInit *FoldOpInit::get(Init *Start, Init *List, Init *A, Init *B,
                            Init *Expr, const RecTy *Type) {}

void FoldOpInit::Profile(FoldingSetNodeID &ID) const {}

Init *FoldOpInit::Fold(Record *CurRec) const {}

Init *FoldOpInit::resolveReferences(Resolver &R) const {}

Init *FoldOpInit::getBit(unsigned Bit) const {}

std::string FoldOpInit::getAsString() const {}

static void ProfileIsAOpInit(FoldingSetNodeID &ID, const RecTy *CheckType,
                             Init *Expr) {}

IsAOpInit *IsAOpInit::get(const RecTy *CheckType, Init *Expr) {}

void IsAOpInit::Profile(FoldingSetNodeID &ID) const {}

Init *IsAOpInit::Fold() const {}

Init *IsAOpInit::resolveReferences(Resolver &R) const {}

Init *IsAOpInit::getBit(unsigned Bit) const {}

std::string IsAOpInit::getAsString() const {}

static void ProfileExistsOpInit(FoldingSetNodeID &ID, const RecTy *CheckType,
                                Init *Expr) {}

ExistsOpInit *ExistsOpInit::get(const RecTy *CheckType, Init *Expr) {}

void ExistsOpInit::Profile(FoldingSetNodeID &ID) const {}

Init *ExistsOpInit::Fold(Record *CurRec, bool IsFinal) const {}

Init *ExistsOpInit::resolveReferences(Resolver &R) const {}

Init *ExistsOpInit::getBit(unsigned Bit) const {}

std::string ExistsOpInit::getAsString() const {}

const RecTy *TypedInit::getFieldType(StringInit *FieldName) const {}

Init *TypedInit::convertInitializerTo(const RecTy *Ty) const {}

Init *TypedInit::convertInitializerBitRange(ArrayRef<unsigned> Bits) const {}

Init *TypedInit::getCastTo(const RecTy *Ty) const {}

VarInit *VarInit::get(StringRef VN, const RecTy *T) {}

VarInit *VarInit::get(Init *VN, const RecTy *T) {}

StringRef VarInit::getName() const {}

Init *VarInit::getBit(unsigned Bit) const {}

Init *VarInit::resolveReferences(Resolver &R) const {}

VarBitInit *VarBitInit::get(TypedInit *T, unsigned B) {}

std::string VarBitInit::getAsString() const {}

Init *VarBitInit::resolveReferences(Resolver &R) const {}

DefInit::DefInit(const Record *D)
    :{}

Init *DefInit::convertInitializerTo(const RecTy *Ty) const {}

const RecTy *DefInit::getFieldType(StringInit *FieldName) const {}

std::string DefInit::getAsString() const {}

static void ProfileVarDefInit(FoldingSetNodeID &ID, Record *Class,
                              ArrayRef<ArgumentInit *> Args) {}

VarDefInit::VarDefInit(SMLoc Loc, Record *Class, unsigned N)
    :{}

VarDefInit *VarDefInit::get(SMLoc Loc, Record *Class,
                            ArrayRef<ArgumentInit *> Args) {}

void VarDefInit::Profile(FoldingSetNodeID &ID) const {}

DefInit *VarDefInit::instantiate() {}

Init *VarDefInit::resolveReferences(Resolver &R) const {}

Init *VarDefInit::Fold() const {}

std::string VarDefInit::getAsString() const {}

FieldInit *FieldInit::get(Init *R, StringInit *FN) {}

Init *FieldInit::getBit(unsigned Bit) const {}

Init *FieldInit::resolveReferences(Resolver &R) const {}

Init *FieldInit::Fold(Record *CurRec) const {}

bool FieldInit::isConcrete() const {}

static void ProfileCondOpInit(FoldingSetNodeID &ID,
                             ArrayRef<Init *> CondRange,
                             ArrayRef<Init *> ValRange,
                             const RecTy *ValType) {}

void CondOpInit::Profile(FoldingSetNodeID &ID) const {}

CondOpInit *CondOpInit::get(ArrayRef<Init *> CondRange,
                            ArrayRef<Init *> ValRange, const RecTy *Ty) {}

Init *CondOpInit::resolveReferences(Resolver &R) const {}

Init *CondOpInit::Fold(Record *CurRec) const {}

bool CondOpInit::isConcrete() const {}

bool CondOpInit::isComplete() const {}

std::string CondOpInit::getAsString() const {}

Init *CondOpInit::getBit(unsigned Bit) const {}

static void ProfileDagInit(FoldingSetNodeID &ID, Init *V, StringInit *VN,
                           ArrayRef<Init *> ArgRange,
                           ArrayRef<StringInit *> NameRange) {}

DagInit *DagInit::get(Init *V, StringInit *VN, ArrayRef<Init *> ArgRange,
                      ArrayRef<StringInit *> NameRange) {}

DagInit *
DagInit::get(Init *V, StringInit *VN,
             ArrayRef<std::pair<Init*, StringInit*>> args) {}

void DagInit::Profile(FoldingSetNodeID &ID) const {}

const Record *DagInit::getOperatorAsDef(ArrayRef<SMLoc> Loc) const {}

std::optional<unsigned> DagInit::getArgNo(StringRef Name) const {}

Init *DagInit::resolveReferences(Resolver &R) const {}

bool DagInit::isConcrete() const {}

std::string DagInit::getAsString() const {}

//===----------------------------------------------------------------------===//
//    Other implementations
//===----------------------------------------------------------------------===//

RecordVal::RecordVal(Init *N, const RecTy *T, FieldKind K)
    :{}

// This constructor accepts the same arguments as the above, but also
// a source location.
RecordVal::RecordVal(Init *N, SMLoc Loc, const RecTy *T, FieldKind K)
    :{}

StringRef RecordVal::getName() const {}

std::string RecordVal::getPrintType() const {}

bool RecordVal::setValue(Init *V) {}

// This version of setValue takes a source location and resets the
// location in the RecordVal.
bool RecordVal::setValue(Init *V, SMLoc NewLoc) {}

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#include "llvm/TableGen/Record.h"
LLVM_DUMP_METHOD void RecordVal::dump() const { errs() << *this; }
#endif

void RecordVal::print(raw_ostream &OS, bool PrintSem) const {}

void Record::updateClassLoc(SMLoc Loc) {}

void Record::checkName() {}

const RecordRecTy *Record::getType() const {}

DefInit *Record::getDefInit() const {}

unsigned Record::getNewUID(RecordKeeper &RK) {}

void Record::setName(Init *NewName) {}

// NOTE for the next two functions:
// Superclasses are in post-order, so the final one is a direct
// superclass. All of its transitive superclases immediately precede it,
// so we can step through the direct superclasses in reverse order.

bool Record::hasDirectSuperClass(const Record *Superclass) const {}

void Record::getDirectSuperClasses(
    SmallVectorImpl<const Record *> &Classes) const {}

void Record::resolveReferences(Resolver &R, const RecordVal *SkipVal) {}

void Record::resolveReferences(Init *NewName) {}

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void Record::dump() const { errs() << *this; }
#endif

raw_ostream &llvm::operator<<(raw_ostream &OS, const Record &R) {}

SMLoc Record::getFieldLoc(StringRef FieldName) const {}

Init *Record::getValueInit(StringRef FieldName) const {}

StringRef Record::getValueAsString(StringRef FieldName) const {}

std::optional<StringRef>
Record::getValueAsOptionalString(StringRef FieldName) const {}

BitsInit *Record::getValueAsBitsInit(StringRef FieldName) const {}

ListInit *Record::getValueAsListInit(StringRef FieldName) const {}

std::vector<const Record *>
Record::getValueAsListOfDefs(StringRef FieldName) const {}

int64_t Record::getValueAsInt(StringRef FieldName) const {}

std::vector<int64_t>
Record::getValueAsListOfInts(StringRef FieldName) const {}

std::vector<StringRef>
Record::getValueAsListOfStrings(StringRef FieldName) const {}

const Record *Record::getValueAsDef(StringRef FieldName) const {}

const Record *Record::getValueAsOptionalDef(StringRef FieldName) const {}

bool Record::getValueAsBit(StringRef FieldName) const {}

bool Record::getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const {}

DagInit *Record::getValueAsDag(StringRef FieldName) const {}

// Check all record assertions: For each one, resolve the condition
// and message, then call CheckAssert().
// Note: The condition and message are probably already resolved,
//       but resolving again allows calls before records are resolved.
void Record::checkRecordAssertions() {}

void Record::emitRecordDumps() {}

// Report a warning if the record has unused template arguments.
void Record::checkUnusedTemplateArgs() {}

RecordKeeper::RecordKeeper()
    :{}

RecordKeeper::~RecordKeeper() = default;

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void RecordKeeper::dump() const { errs() << *this; }
#endif

raw_ostream &llvm::operator<<(raw_ostream &OS, const RecordKeeper &RK) {}

/// GetNewAnonymousName - Generate a unique anonymous name that can be used as
/// an identifier.
Init *RecordKeeper::getNewAnonymousName() {}

ArrayRef<const Record *>
RecordKeeper::getAllDerivedDefinitions(StringRef ClassName) const {}

std::vector<const Record *>
RecordKeeper::getAllDerivedDefinitions(ArrayRef<StringRef> ClassNames) const {}

ArrayRef<const Record *>
RecordKeeper::getAllDerivedDefinitionsIfDefined(StringRef ClassName) const {}

void RecordKeeper::dumpAllocationStats(raw_ostream &OS) const {}

Init *MapResolver::resolve(Init *VarName) {}

Init *RecordResolver::resolve(Init *VarName) {}

Init *TrackUnresolvedResolver::resolve(Init *VarName) {}

Init *HasReferenceResolver::resolve(Init *VarName)
{}