LLVM 24.0.0git
llvm::Record Class Reference

#include "llvm/TableGen/Record.h"

Classes

struct  AssertionInfo
struct  DumpInfo

Public Types

enum  RecordKind { RK_Def , RK_AnonymousDef , RK_Class , RK_MultiClass }

Public Member Functions

 Record (const Init *N, ArrayRef< SMLoc > locs, RecordKeeper &records, RecordKind Kind=RK_Def)
 Record (StringRef N, ArrayRef< SMLoc > locs, RecordKeeper &records, RecordKind Kind=RK_Def)
 Record (const Record &O)
unsigned getID () const
StringRef getName () const
const Init * getNameInit () const
std::string getNameInitAsString () const
void setName (const Init *Name)
ArrayRef< SMLoc > getLoc () const
void appendLoc (SMLoc Loc)
ArrayRef< SMLoc > getForwardDeclarationLocs () const
void appendReferenceLoc (SMRange Loc) const
 Add a reference to this record value.
ArrayRef< SMRange > getReferenceLocs () const
 Return the references of this record value.
void appendValueReferenceLoc (const Init *Name, SMRange Loc) const
 Add a reference to the value named Name.
void appendValueReferenceLocs (const Record &From, const Init *Name) const
 Add the references to the value named Name in From.
ArrayRef< SMRange > getValueReferenceLocs (const Init *Name) const
 Return the references to the value named Name.
void updateClassLoc (SMLoc Loc)
const RecordRecTy * getType () const
DefInit * getDefInit () const
 get the corresponding DefInit.
bool isClass () const
bool isMultiClass () const
bool isAnonymous () const
ArrayRef< RecordVal > getTemplateArgs () const
 Return the template arguments of this class or multiclass.
ArrayRef< RecordVal > getValues () const
 Return the fields of this record.
ArrayRef< AssertionInfo > getAssertions () const
ArrayRef< DumpInfo > getDumps () const
void getSuperClasses (std::vector< const Record * > &Classes) const
 Append all superclasses in post-order to Classes.
std::vector< const Record * > getSuperClasses () const
 Return all superclasses in post-order.
bool hasDirectSuperClass (const Record *SuperClass) const
 Determine whether this record has the specified direct superclass.
ArrayRef< std::pair< const Record *, SMRange > > getDirectSuperClasses () const
 Return the direct superclasses of this record.
const RecordVal * getTemplateArg (const Init *Name) const
 Return the template argument with the given name, or null if there is none.
RecordVal * getTemplateArg (const Init *Name)
const RecordVal * getValue (const Init *Name) const
 Return the field with the given name, or null if there is none.
const RecordVal * getValue (StringRef Name) const
RecordVal * getValue (const Init *Name)
RecordVal * getValue (StringRef Name)
bool addTemplateArg (const RecordVal &Arg)
 Add a template argument.
void addValue (const RecordVal &RV)
void removeValue (const Init *Name)
void removeValue (StringRef Name)
void addAssertion (SMLoc Loc, const Init *Condition, const Init *Message)
void addDump (SMLoc Loc, const Init *Message)
void appendAssertions (const Record *Rec)
void appendDumps (const Record *Rec)
void checkRecordAssertions ()
void emitRecordDumps ()
void checkUnusedTemplateArgs ()
bool isSubClassOf (const Record *R) const
bool isSubClassOf (StringRef Name) const
void addDirectSuperClass (const Record *R, SMRange Range)
void resolveReferences (const Init *NewName=nullptr)
 If there are any field references that refer to fields that have been filled in, we can propagate the values now.
void resolveReferences (Resolver &R, const RecordVal *SkipVal=nullptr)
 Apply the resolver to the name of the record as well as to the initializers of all fields of the record except SkipVal.
RecordKeeper & getRecords () const
void dump () const
SMLoc getFieldLoc (StringRef FieldName) const
 Return the source location for the named field.
const Init * getValueInit (StringRef FieldName) const
 Return the initializer for a value with the specified name, or throw an exception if the field does not exist.
bool isValueUnset (StringRef FieldName) const
 Return true if the named field is unset.
StringRef getValueAsString (StringRef FieldName) const
 This method looks up the specified field and returns its value as a string, throwing an exception if the field does not exist or if the value is not a string.
std::optional< StringRef > getValueAsOptionalString (StringRef FieldName) const
 This method looks up the specified field and returns its value as a string, throwing an exception if the value is not a string and std::nullopt if the field does not exist.
const BitsInit * getValueAsBitsInit (StringRef FieldName) const
 This method looks up the specified field and returns its value as a BitsInit, throwing an exception if the field does not exist or if the value is not the right type.
const ListInit * getValueAsListInit (StringRef FieldName) const
 This method looks up the specified field and returns its value as a ListInit, throwing an exception if the field does not exist or if the value is not the right type.
std::vector< const Record * > getValueAsListOfDefs (StringRef FieldName) const
 This method looks up the specified field and returns its value as a vector of records, throwing an exception if the field does not exist or if the value is not the right type.
std::vector< int64_t > getValueAsListOfInts (StringRef FieldName) const
 This method looks up the specified field and returns its value as a vector of integers, throwing an exception if the field does not exist or if the value is not the right type.
std::vector< StringRef > getValueAsListOfStrings (StringRef FieldName) const
 This method looks up the specified field and returns its value as a vector of strings, throwing an exception if the field does not exist or if the value is not the right type.
const Record * getValueAsDef (StringRef FieldName) const
 This method looks up the specified field and returns its value as a Record, throwing an exception if the field does not exist or if the value is not the right type.
const Record * getValueAsOptionalDef (StringRef FieldName) const
 This method looks up the specified field and returns its value as a Record, returning null if the field exists but is "uninitialized" (i.e.
bool getValueAsBit (StringRef FieldName) const
 This method looks up the specified field and returns its value as a bit, throwing an exception if the field does not exist or if the value is not the right type.
bool getValueAsBitOrUnset (StringRef FieldName, bool &Unset) const
 This method looks up the specified field and returns its value as a bit.
int64_t getValueAsInt (StringRef FieldName) const
 This method looks up the specified field and returns its value as an int64_t, throwing an exception if the field does not exist or if the value is not the right type.
const DagInit * getValueAsDag (StringRef FieldName) const
 This method looks up the specified field and returns its value as an Dag, throwing an exception if the field does not exist or if the value is not the right type.

Static Public Member Functions

static unsigned getNewUID (RecordKeeper &RK)

Detailed Description

Definition at line 1675 of file Record.h.

Member Enumeration Documentation

◆ RecordKind

Enumerator
RK_Def 
RK_AnonymousDef 
RK_Class 
RK_MultiClass 

Definition at line 1697 of file Record.h.

Constructor & Destructor Documentation

◆ Record() [1/3]

◆ Record() [2/3]

llvm::Record::Record ( StringRef N,
ArrayRef< SMLoc > locs,
RecordKeeper & records,
RecordKind Kind = RK_Def )
inlineexplicit

Definition at line 1741 of file Record.h.

References llvm::get(), N, Record(), and RK_Def.

◆ Record() [3/3]

llvm::Record::Record ( const Record & O)
inline

Definition at line 1748 of file Record.h.

References getNewUID(), getRecords(), and Record().

Member Function Documentation

◆ addAssertion()

void llvm::Record::addAssertion ( SMLoc Loc,
const Init * Condition,
const Init * Message )
inline

Definition at line 1916 of file Record.h.

◆ addDirectSuperClass()

void llvm::Record::addDirectSuperClass ( const Record * R,
SMRange Range )
inline

Definition at line 1956 of file Record.h.

References assert(), isSubClassOf(), Range, and Record().

◆ addDump()

void llvm::Record::addDump ( SMLoc Loc,
const Init * Message )
inline

Definition at line 1920 of file Record.h.

◆ addTemplateArg()

bool llvm::Record::addTemplateArg ( const RecordVal & Arg)
inline

Add a template argument.

Return false, without adding it, if there is already a template argument with the same name.

Definition at line 1890 of file Record.h.

References assert(), llvm::RecordVal::getNameInit(), getTemplateArg(), and llvm::RecordVal::isTemplateArg().

◆ addValue()

void llvm::Record::addValue ( const RecordVal & RV)
inline

◆ appendAssertions()

void llvm::Record::appendAssertions ( const Record * Rec)
inline

Definition at line 1924 of file Record.h.

References Record().

◆ appendDumps()

void llvm::Record::appendDumps ( const Record * Rec)
inline

Definition at line 1928 of file Record.h.

References Record().

◆ appendLoc()

void llvm::Record::appendLoc ( SMLoc Loc)
inline

Definition at line 1771 of file Record.h.

◆ appendReferenceLoc()

void llvm::Record::appendReferenceLoc ( SMRange Loc) const
inline

Add a reference to this record value.

Definition at line 1778 of file Record.h.

◆ appendValueReferenceLoc()

void llvm::Record::appendValueReferenceLoc ( const Init * Name,
SMRange Loc ) const
inline

Add a reference to the value named Name.

Definition at line 1784 of file Record.h.

◆ appendValueReferenceLocs()

void llvm::Record::appendValueReferenceLocs ( const Record & From,
const Init * Name ) const
inline

Add the references to the value named Name in From.

Definition at line 1789 of file Record.h.

References llvm::append_range(), and Record().

◆ checkRecordAssertions()

void Record::checkRecordAssertions ( )

◆ checkUnusedTemplateArgs()

void Record::checkUnusedTemplateArgs ( )

Definition at line 3136 of file Record.cpp.

References getTemplateArgs(), and llvm::PrintWarning().

◆ dump()

LLVM_DUMP_METHOD void Record::dump ( ) const

Definition at line 2906 of file Record.cpp.

References llvm::errs(), and LLVM_DUMP_METHOD.

◆ emitRecordDumps()

void Record::emitRecordDumps ( )

Definition at line 3125 of file Record.cpp.

References llvm::dumpMessage(), and getDumps().

◆ getAssertions()

ArrayRef< AssertionInfo > llvm::Record::getAssertions ( ) const
inline

Definition at line 1824 of file Record.h.

Referenced by checkRecordAssertions().

◆ getDefInit()

DefInit * Record::getDefInit ( ) const

get the corresponding DefInit.

Definition at line 2827 of file Record.cpp.

Referenced by llvm::TernOpInit::Fold().

◆ getDirectSuperClasses()

ArrayRef< std::pair< const Record *, SMRange > > llvm::Record::getDirectSuperClasses ( ) const
inline

Return the direct superclasses of this record.

Definition at line 1848 of file Record.h.

Referenced by getType().

◆ getDumps()

ArrayRef< DumpInfo > llvm::Record::getDumps ( ) const
inline

Definition at line 1825 of file Record.h.

Referenced by emitRecordDumps().

◆ getFieldLoc()

SMLoc Record::getFieldLoc ( StringRef FieldName) const

Return the source location for the named field.

Definition at line 2942 of file Record.cpp.

References getLoc(), getName(), getValue(), and llvm::PrintFatalError().

◆ getForwardDeclarationLocs()

ArrayRef< SMLoc > llvm::Record::getForwardDeclarationLocs ( ) const
inline

Definition at line 1773 of file Record.h.

◆ getID()

unsigned llvm::Record::getID ( ) const
inline

Definition at line 1758 of file Record.h.

◆ getLoc()

◆ getName()

◆ getNameInit()

const Init * llvm::Record::getNameInit ( ) const
inline

◆ getNameInitAsString()

std::string llvm::Record::getNameInitAsString ( ) const
inline

Definition at line 1764 of file Record.h.

References llvm::Init::getAsUnquotedString(), and getNameInit().

Referenced by llvm::CondOpInit::Fold().

◆ getNewUID()

unsigned Record::getNewUID ( RecordKeeper & RK)
static

Definition at line 2835 of file Record.cpp.

References llvm::RecordKeeper::getImpl(), and detail::RecordKeeperImpl::LastRecordID.

Referenced by Record(), and Record().

◆ getRecords()

RecordKeeper & llvm::Record::getRecords ( ) const
inline

Definition at line 1977 of file Record.h.

Referenced by getValue(), QualifiedNameOfImplicitName(), QualifyName(), Record(), and removeValue().

◆ getReferenceLocs()

ArrayRef< SMRange > llvm::Record::getReferenceLocs ( ) const
inline

Return the references of this record value.

Definition at line 1781 of file Record.h.

◆ getSuperClasses() [1/2]

std::vector< const Record * > llvm::Record::getSuperClasses ( ) const
inline

Return all superclasses in post-order.

Definition at line 1836 of file Record.h.

References getSuperClasses().

Referenced by getSuperClasses().

◆ getSuperClasses() [2/2]

void llvm::Record::getSuperClasses ( std::vector< const Record * > & Classes) const
inline

Append all superclasses in post-order to Classes.

Definition at line 1828 of file Record.h.

References llvm::make_first_range(), and Record().

◆ getTemplateArg() [1/2]

RecordVal * llvm::Record::getTemplateArg ( const Init * Name)
inline

Definition at line 1861 of file Record.h.

References Record().

◆ getTemplateArg() [2/2]

const RecordVal * llvm::Record::getTemplateArg ( const Init * Name) const
inline

Return the template argument with the given name, or null if there is none.

Definition at line 1854 of file Record.h.

Referenced by addTemplateArg().

◆ getTemplateArgs()

ArrayRef< RecordVal > llvm::Record::getTemplateArgs ( ) const
inline

Return the template arguments of this class or multiclass.

Definition at line 1819 of file Record.h.

Referenced by checkUnusedTemplateArgs().

◆ getType()

◆ getValue() [1/4]

RecordVal * llvm::Record::getValue ( const Init * Name)
inline

Definition at line 1878 of file Record.h.

References Record().

◆ getValue() [2/4]

const RecordVal * llvm::Record::getValue ( const Init * Name) const
inline

Return the field with the given name, or null if there is none.

Use getTemplateArg() to look up template arguments.

Definition at line 1868 of file Record.h.

Referenced by addValue(), getFieldLoc(), getValue(), getValueAsOptionalString(), and getValueInit().

◆ getValue() [3/4]

RecordVal * llvm::Record::getValue ( StringRef Name)
inline

Definition at line 1883 of file Record.h.

References Record().

◆ getValue() [4/4]

const RecordVal * llvm::Record::getValue ( StringRef Name) const
inline

Definition at line 1874 of file Record.h.

References llvm::StringInit::get(), getRecords(), and getValue().

◆ getValueAsBit()

bool Record::getValueAsBit ( StringRef FieldName) const

This method looks up the specified field and returns its value as a bit, throwing an exception if the field does not exist or if the value is not the right type.

Definition at line 3073 of file Record.cpp.

References llvm::dyn_cast(), getLoc(), getName(), getValueInit(), I, and llvm::PrintFatalError().

◆ getValueAsBitOrUnset()

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

This method looks up the specified field and returns its value as a bit.

If the field is unset, sets Unset to true and returns false.

Definition at line 3081 of file Record.cpp.

References llvm::dyn_cast(), getLoc(), getName(), getValueInit(), I, llvm::isa(), llvm::PrintFatalError(), and llvm::Unset.

◆ getValueAsBitsInit()

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

This method looks up the specified field and returns its value as a BitsInit, throwing an exception if the field does not exist or if the value is not the right type.

Definition at line 2982 of file Record.cpp.

References llvm::dyn_cast(), getLoc(), getName(), getValueInit(), I, and llvm::PrintFatalError().

◆ getValueAsDag()

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

This method looks up the specified field and returns its value as an Dag, throwing an exception if the field does not exist or if the value is not the right type.

Definition at line 3094 of file Record.cpp.

References llvm::dyn_cast(), getLoc(), getName(), getValueInit(), I, and llvm::PrintFatalError().

◆ getValueAsDef()

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

This method looks up the specified field and returns its value as a Record, throwing an exception if the field does not exist or if the value is not the right type.

Definition at line 3055 of file Record.cpp.

References llvm::dyn_cast(), getLoc(), getName(), getValueInit(), I, llvm::PrintFatalError(), and Record().

◆ getValueAsInt()

int64_t Record::getValueAsInt ( StringRef FieldName) const

This method looks up the specified field and returns its value as an int64_t, throwing an exception if the field does not exist or if the value is not the right type.

Definition at line 3013 of file Record.cpp.

References llvm::dyn_cast(), getLoc(), getName(), getValueInit(), I, II, and llvm::PrintFatalError().

Referenced by llvm::LessRecordRegister::operator()().

◆ getValueAsListInit()

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

This method looks up the specified field and returns its value as a ListInit, throwing an exception if the field does not exist or if the value is not the right type.

Definition at line 2990 of file Record.cpp.

References llvm::dyn_cast(), getLoc(), getName(), getValueInit(), I, and llvm::PrintFatalError().

Referenced by getValueAsListOfDefs(), getValueAsListOfInts(), and getValueAsListOfStrings().

◆ getValueAsListOfDefs()

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

This method looks up the specified field and returns its value as a vector of records, throwing an exception if the field does not exist or if the value is not the right type.

Definition at line 2999 of file Record.cpp.

References llvm::dyn_cast(), getLoc(), getName(), getValueAsListInit(), I, llvm::List, and llvm::PrintFatalError().

◆ getValueAsListOfInts()

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

This method looks up the specified field and returns its value as a vector of integers, throwing an exception if the field does not exist or if the value is not the right type.

Definition at line 3024 of file Record.cpp.

References llvm::dyn_cast(), getLoc(), getName(), getValueAsListInit(), I, II, llvm::List, and llvm::PrintFatalError().

◆ getValueAsListOfStrings()

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

This method looks up the specified field and returns its value as a vector of strings, throwing an exception if the field does not exist or if the value is not the right type.

Definition at line 3040 of file Record.cpp.

References llvm::dyn_cast(), getLoc(), getName(), getValueAsListInit(), I, llvm::List, and llvm::PrintFatalError().

◆ getValueAsOptionalDef()

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

This method looks up the specified field and returns its value as a Record, returning null if the field exists but is "uninitialized" (i.e.

set to ?), and throwing an exception if the field does not exist or if its value is not the right type.

Definition at line 3063 of file Record.cpp.

References llvm::dyn_cast(), getLoc(), getName(), getValueInit(), I, llvm::isa(), llvm::PrintFatalError(), and Record().

◆ getValueAsOptionalString()

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

This method looks up the specified field and returns its value as a string, throwing an exception if the value is not a string and std::nullopt if the field does not exist.

Definition at line 2967 of file Record.cpp.

References llvm::dyn_cast(), getLoc(), getName(), getValue(), llvm::isa(), and llvm::PrintFatalError().

◆ getValueAsString()

StringRef Record::getValueAsString ( StringRef FieldName) const

This method looks up the specified field and returns its value as a string, throwing an exception if the field does not exist or if the value is not a string.

Definition at line 2958 of file Record.cpp.

References llvm::dyn_cast(), getLoc(), getName(), getValueInit(), I, and llvm::PrintFatalError().

Referenced by llvm::LessRecordFieldName::operator()().

◆ getValueInit()

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

Return the initializer for a value with the specified name, or throw an exception if the field does not exist.

Definition at line 2950 of file Record.cpp.

References getLoc(), getName(), getValue(), and llvm::PrintFatalError().

Referenced by getValueAsBit(), getValueAsBitOrUnset(), getValueAsBitsInit(), getValueAsDag(), getValueAsDef(), getValueAsInt(), getValueAsListInit(), getValueAsOptionalDef(), getValueAsString(), and isValueUnset().

◆ getValueReferenceLocs()

ArrayRef< SMRange > llvm::Record::getValueReferenceLocs ( const Init * Name) const
inline

Return the references to the value named Name.

Definition at line 1796 of file Record.h.

◆ getValues()

ArrayRef< RecordVal > llvm::Record::getValues ( ) const
inline

Return the fields of this record.

Definition at line 1822 of file Record.h.

◆ hasDirectSuperClass()

bool llvm::Record::hasDirectSuperClass ( const Record * SuperClass) const
inline

Determine whether this record has the specified direct superclass.

Definition at line 1843 of file Record.h.

References llvm::is_contained(), llvm::make_first_range(), and Record().

◆ isAnonymous()

bool llvm::Record::isAnonymous ( ) const
inline

Definition at line 1816 of file Record.h.

References RK_AnonymousDef.

◆ isClass()

bool llvm::Record::isClass ( ) const
inline

Definition at line 1812 of file Record.h.

References RK_Class.

◆ isMultiClass()

bool llvm::Record::isMultiClass ( ) const
inline

Definition at line 1814 of file Record.h.

References RK_MultiClass.

Referenced by QualifyName().

◆ isSubClassOf() [1/2]

bool llvm::Record::isSubClassOf ( const Record * R) const
inline

Definition at line 1934 of file Record.h.

References llvm::make_first_range(), and Record().

Referenced by addDirectSuperClass(), and llvm::RecordRecTy::isSubClassOf().

◆ isSubClassOf() [2/2]

bool llvm::Record::isSubClassOf ( StringRef Name) const
inline

Definition at line 1942 of file Record.h.

References llvm::dyn_cast(), llvm::make_first_range(), and Record().

◆ isValueUnset()

bool llvm::Record::isValueUnset ( StringRef FieldName) const
inline

Return true if the named field is unset.

Definition at line 1995 of file Record.h.

References getValueInit(), and llvm::isa().

◆ removeValue() [1/2]

void llvm::Record::removeValue ( const Init * Name)
inline

Definition at line 1904 of file Record.h.

References llvm::find_if(), and llvm_unreachable.

Referenced by removeValue().

◆ removeValue() [2/2]

void llvm::Record::removeValue ( StringRef Name)
inline

Definition at line 1912 of file Record.h.

References llvm::StringInit::get(), getRecords(), and removeValue().

◆ resolveReferences() [1/2]

void Record::resolveReferences ( const Init * NewName = nullptr)

If there are any field references that refer to fields that have been filled in, we can propagate the values now.

This is a final resolve: any error messages, e.g. due to undefined !cast references, are generated now.

Definition at line 2898 of file Record.cpp.

References resolveReferences().

Referenced by llvm::FieldInit::resolveReferences(), and resolveReferences().

◆ resolveReferences() [2/2]

void Record::resolveReferences ( Resolver & R,
const RecordVal * SkipVal = nullptr )

Apply the resolver to the name of the record as well as to the initializers of all fields of the record except SkipVal.

The resolver should not resolve any of the fields itself, to avoid recursion / infinite loops.

Definition at line 2855 of file Record.cpp.

References llvm::concat(), llvm::dyn_cast(), llvm::Init::getAsUnquotedString(), getLoc(), getNameInit(), llvm::Value::getType(), llvm::PrintFatalError(), llvm::Init::resolveReferences(), and setName().

◆ setName()

void Record::setName ( const Init * Name)

◆ updateClassLoc()

void Record::updateClassLoc ( SMLoc Loc)

Definition at line 2805 of file Record.cpp.

References assert().


The documentation for this class was generated from the following files: