[llvm] b2faf75 - [TableGen] Continue improving the comments for the data structures.
Paul C. Anagnostopoulos via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 22 07:02:06 PDT 2020
Author: Paul C. Anagnostopoulos
Date: 2020-10-22T10:00:49-04:00
New Revision: b2faf75568717397a7fced8fe93bbc013df77aaf
URL: https://github.com/llvm/llvm-project/commit/b2faf75568717397a7fced8fe93bbc013df77aaf
DIFF: https://github.com/llvm/llvm-project/commit/b2faf75568717397a7fced8fe93bbc013df77aaf.diff
LOG: [TableGen] Continue improving the comments for the data structures.
Differential Revision: https://reviews.llvm.org/D89901
Added:
Modified:
llvm/docs/TableGen/BackGuide.rst
llvm/include/llvm/TableGen/Record.h
Removed:
################################################################################
diff --git a/llvm/docs/TableGen/BackGuide.rst b/llvm/docs/TableGen/BackGuide.rst
index 430e640778cf..3a84babc4c39 100644
--- a/llvm/docs/TableGen/BackGuide.rst
+++ b/llvm/docs/TableGen/BackGuide.rst
@@ -22,8 +22,8 @@ for C++, but may be any type of file that the backend developer needs.
This document is a guide to writing a backend for TableGen. It is not a
complete reference manual, but rather a guide to using the facilities
provided by TableGen for the backends. For a complete reference to the
-various data structures and functions involved, see the Doxygen
-documentation.
+various data structures and functions involved, see the primary TableGen
+header file (``record.h``) and/or the Doxygen documentation.
This document assumes that you have read the :doc:`TableGen Programmer's
Reference <./ProgRef>`, which provides a detailed reference for coding
diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h
index c0eb88b56be3..c8cd00204172 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -420,7 +420,7 @@ inline raw_ostream &operator<<(raw_ostream &OS, const Init &I) {
}
/// This is the common superclass of types that have a specific,
-/// explicit, type, stored in ValueTy.
+/// explicit type, stored in ValueTy.
class TypedInit : public Init {
RecTy *ValueTy;
@@ -437,6 +437,7 @@ class TypedInit : public Init {
I->getKind() <= IK_LastTypedInit;
}
+ /// Get the type of the Init as a RecTy.
RecTy *getType() const { return ValueTy; }
Init *getCastTo(RecTy *Ty) const override;
@@ -451,7 +452,7 @@ class TypedInit : public Init {
RecTy *getFieldType(StringInit *FieldName) const override;
};
-/// '?' - Represents an uninitialized value
+/// '?' - Represents an uninitialized value.
class UnsetInit : public Init {
UnsetInit() : Init(IK_UnsetInit) {}
@@ -463,6 +464,7 @@ class UnsetInit : public Init {
return I->getKind() == IK_UnsetInit;
}
+ /// Get the singleton unset Init.
static UnsetInit *get();
Init *getCastTo(RecTy *Ty) const override;
@@ -472,8 +474,12 @@ class UnsetInit : public Init {
return const_cast<UnsetInit*>(this);
}
+ /// Is this a complete value with no unset (uninitialized) subvalues?
bool isComplete() const override { return false; }
+
bool isConcrete() const override { return true; }
+
+ /// Get the string representation of the Init.
std::string getAsString() const override { return "?"; }
};
@@ -1395,6 +1401,8 @@ class DagInit final : public TypedInit, public FoldingSetNode,
// High-Level Classes
//===----------------------------------------------------------------------===//
+/// This class represents a field in a record, including its name, type,
+/// value, and source location.
class RecordVal {
friend class Record;
@@ -1407,22 +1415,37 @@ class RecordVal {
RecordVal(Init *N, RecTy *T, bool P);
RecordVal(Init *N, SMLoc Loc, RecTy *T, bool P);
+ /// Get the name of the field as a StringRef.
StringRef getName() const;
+
+ /// Get the name of the field as an Init.
Init *getNameInit() const { return Name; }
+ /// Get the name of the field as a std::string.
std::string getNameInitAsString() const {
return getNameInit()->getAsUnquotedString();
}
+ /// Get the source location of the point where the field was defined.
const SMLoc &getLoc() const { return Loc; }
+
bool getPrefix() const { return TyAndPrefix.getInt(); }
+
+ /// Get the type of the field value as a RecTy.
RecTy *getType() const { return TyAndPrefix.getPointer(); }
+
+ /// Get the value of the field as an Init.
Init *getValue() const { return Value; }
+ /// Set the value of the field from an Init.
bool setValue(Init *V);
+
+ /// Set the value and source location of the field.
bool setValue(Init *V, SMLoc NewLoc);
void dump() const;
+
+ /// Print the value to an output stream, possibly with a semicolon.
void print(raw_ostream &OS, bool PrintSem = true) const;
};
More information about the llvm-commits
mailing list