mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[TableGen] Add/edit Doxygen comments to match "TableGen Backend Developer's Guide."
This commit is contained in:
parent
59c322db6b
commit
2483a36836
@ -75,7 +75,7 @@ The ``RecordKeeper`` class provides a few useful functions.
|
||||
|
||||
* Functions to get a subset of the records based on their parent classes.
|
||||
|
||||
* Functions to get individual classes, records, and globals.
|
||||
* Functions to get individual classes, records, and globals, by name.
|
||||
|
||||
A ``RecordKeeper`` instance can be printed to an output stream with the ``<<``
|
||||
operator.
|
||||
@ -252,15 +252,14 @@ corresponding to the record inheriting from those superclasses.
|
||||
The ``Init`` class is used to represent TableGen values. The name derives
|
||||
from *initialization value*. This class should not be confused with the
|
||||
``RecordVal`` class, which represents record fields, both their names and
|
||||
values. The ``Init`` class is the base class for a series of
|
||||
subclasses, one for each of the available value types.
|
||||
|
||||
The primary data member
|
||||
of ``Init`` is an enumerated type that represents the specific type of the
|
||||
value.
|
||||
values. The ``Init`` class is the base class for a series of subclasses, one
|
||||
for each of the available value types. The primary data member of ``Init``
|
||||
is an enumerated type that represents the specific type of the value.
|
||||
|
||||
The ``Init`` class provides a few useful functions.
|
||||
|
||||
* A function to get the type enumerator.
|
||||
|
||||
* A boolean virtual function to determine whether a value is completely
|
||||
specified; that is, has no uninitialized subvalues.
|
||||
|
||||
@ -269,6 +268,8 @@ The ``Init`` class provides a few useful functions.
|
||||
* Virtual functions to cast the value to other types, implement the bit
|
||||
range feature of TableGen, and implement the list slice feature.
|
||||
|
||||
* A virtual function to get a particular bit of the value.
|
||||
|
||||
The subclasses that inherit directly from ``Init`` are
|
||||
``UnsetInit`` and ``TypedInit``.
|
||||
|
||||
|
@ -338,6 +338,7 @@ private:
|
||||
virtual void anchor();
|
||||
|
||||
public:
|
||||
/// Get the kind (type) of the value.
|
||||
InitKind getKind() const { return Kind; }
|
||||
|
||||
protected:
|
||||
@ -348,63 +349,61 @@ public:
|
||||
Init &operator=(const Init &) = delete;
|
||||
virtual ~Init() = default;
|
||||
|
||||
/// This virtual method should be overridden by values that may
|
||||
/// not be completely specified yet.
|
||||
/// Is this a complete value with no unset (uninitialized) subvalues?
|
||||
virtual bool isComplete() const { return true; }
|
||||
|
||||
/// Is this a concrete and fully resolved value without any references or
|
||||
/// stuck operations? Unset values are concrete.
|
||||
virtual bool isConcrete() const { return false; }
|
||||
|
||||
/// Print out this value.
|
||||
/// Print this value.
|
||||
void print(raw_ostream &OS) const { OS << getAsString(); }
|
||||
|
||||
/// Convert this value to a string form.
|
||||
/// Convert this value to a literal form.
|
||||
virtual std::string getAsString() const = 0;
|
||||
/// Convert this value to a string form,
|
||||
/// without adding quote markers. This primaruly affects
|
||||
/// StringInits where we will not surround the string value with
|
||||
/// quotes.
|
||||
|
||||
/// Convert this value to a literal form,
|
||||
/// without adding quotes around a string.
|
||||
virtual std::string getAsUnquotedString() const { return getAsString(); }
|
||||
|
||||
/// Debugging method that may be called through a debugger, just
|
||||
/// Debugging method that may be called through a debugger; just
|
||||
/// invokes print on stderr.
|
||||
void dump() const;
|
||||
|
||||
/// If this initializer is convertible to Ty, return an initializer whose
|
||||
/// type is-a Ty, generating a !cast operation if required. Otherwise, return
|
||||
/// nullptr.
|
||||
/// If this value is convertible to type \p Ty, return a value whose
|
||||
/// type is \p Ty, generating a !cast operation if required.
|
||||
/// Otherwise, return null.
|
||||
virtual Init *getCastTo(RecTy *Ty) const = 0;
|
||||
|
||||
/// Convert to an initializer whose type is-a Ty, or return nullptr if this
|
||||
/// is not possible (this can happen if the initializer's type is convertible
|
||||
/// to Ty, but there are unresolved references).
|
||||
/// Convert to a value whose type is \p Ty, or return null if this
|
||||
/// is not possible. This can happen if the value's type is convertible
|
||||
/// to \p Ty, but there are unresolved references.
|
||||
virtual Init *convertInitializerTo(RecTy *Ty) const = 0;
|
||||
|
||||
/// This method is used to implement the bitrange
|
||||
/// selection operator. Given an initializer, it selects the specified bits
|
||||
/// out, returning them as a new init of bits type. If it is not legal to use
|
||||
/// the bit subscript operator on this initializer, return null.
|
||||
/// This function is used to implement the bit range
|
||||
/// selection operator. Given a value, it selects the specified bits,
|
||||
/// returning them as a new \p Init of type \p bits. If it is not legal
|
||||
/// to use the bit selection operator on this value, null is returned.
|
||||
virtual Init *convertInitializerBitRange(ArrayRef<unsigned> Bits) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// This method is used to implement the list slice
|
||||
/// selection operator. Given an initializer, it selects the specified list
|
||||
/// elements, returning them as a new init of list type. If it is not legal
|
||||
/// to take a slice of this, return null.
|
||||
/// This function is used to implement the list slice
|
||||
/// selection operator. Given a value, it selects the specified list
|
||||
/// elements, returning them as a new \p Init of type \p list. If it
|
||||
/// is not legal to use the slice operator, null is returned.
|
||||
virtual Init *convertInitListSlice(ArrayRef<unsigned> Elements) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// This method is used to implement the FieldInit class.
|
||||
/// Implementors of this method should return the type of the named field if
|
||||
/// they are of record type.
|
||||
/// This function is used to implement the FieldInit class.
|
||||
/// Implementors of this method should return the type of the named
|
||||
/// field if they are of type record.
|
||||
virtual RecTy *getFieldType(StringInit *FieldName) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// This method is used by classes that refer to other
|
||||
/// This function is used by classes that refer to other
|
||||
/// variables which may not be defined at the time the expression is formed.
|
||||
/// If a value is set for the variable later, this method will be called on
|
||||
/// users of the value to allow the value to propagate out.
|
||||
@ -412,8 +411,7 @@ public:
|
||||
return const_cast<Init *>(this);
|
||||
}
|
||||
|
||||
/// This method is used to return the initializer for the specified
|
||||
/// bit.
|
||||
/// Get the \p Init value of the specified bit.
|
||||
virtual Init *getBit(unsigned Bit) const = 0;
|
||||
};
|
||||
|
||||
@ -449,8 +447,7 @@ public:
|
||||
|
||||
/// This method is used to implement the FieldInit class.
|
||||
/// Implementors of this method should return the type of the named field if
|
||||
/// they are of record type.
|
||||
///
|
||||
/// they are of type record.
|
||||
RecTy *getFieldType(StringInit *FieldName) const override;
|
||||
};
|
||||
|
||||
@ -1711,26 +1708,34 @@ raw_ostream &operator<<(raw_ostream &OS, const Record &R);
|
||||
|
||||
class RecordKeeper {
|
||||
friend class RecordRecTy;
|
||||
|
||||
using RecordMap = std::map<std::string, std::unique_ptr<Record>, std::less<>>;
|
||||
|
||||
RecordMap Classes, Defs;
|
||||
FoldingSet<RecordRecTy> RecordTypePool;
|
||||
std::map<std::string, Init *, std::less<>> ExtraGlobals;
|
||||
unsigned AnonCounter = 0;
|
||||
|
||||
public:
|
||||
/// Get the map of classes.
|
||||
const RecordMap &getClasses() const { return Classes; }
|
||||
|
||||
/// Get the map of records (defs).
|
||||
const RecordMap &getDefs() const { return Defs; }
|
||||
|
||||
/// Get the class with the specified name.
|
||||
Record *getClass(StringRef Name) const {
|
||||
auto I = Classes.find(Name);
|
||||
return I == Classes.end() ? nullptr : I->second.get();
|
||||
}
|
||||
|
||||
/// Get the concrete record with the specified name.
|
||||
Record *getDef(StringRef Name) const {
|
||||
auto I = Defs.find(Name);
|
||||
return I == Defs.end() ? nullptr : I->second.get();
|
||||
}
|
||||
|
||||
/// Get the \p Init value of the specified global variable.
|
||||
Init *getGlobal(StringRef Name) const {
|
||||
if (Record *R = getDef(Name))
|
||||
return R->getDefInit();
|
||||
@ -1762,11 +1767,10 @@ public:
|
||||
Init *getNewAnonymousName();
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// High-level helper methods, useful for tablegen backends...
|
||||
// High-level helper methods, useful for tablegen backends.
|
||||
|
||||
/// This method returns all concrete definitions
|
||||
/// that derive from the specified class name. A class with the specified
|
||||
/// name must exist.
|
||||
/// Get all the concrete records that inherit from the specified
|
||||
/// class. The class must be defined.
|
||||
std::vector<Record *> getAllDerivedDefinitions(StringRef ClassName) const;
|
||||
|
||||
void dump() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user