MLIR
20.0.0git
|
A class used to emit C++ classes from Tablegen. More...
#include "mlir/TableGen/Class.h"
Public Member Functions | |
virtual | ~Class ()=default |
Class (const Class &)=delete | |
Explicitly delete the copy constructor. More... | |
template<typename NameT , typename = std::enable_if_t<!std::is_same<NameT, Class>::value>> | |
Class (NameT &&name, bool isStruct=false) | |
Create a class with a name, and whether it should be declared as a class or struct . More... | |
template<Method::Properties Properties = Method::None, typename... Args> | |
Constructor * | addConstructor (Args &&...args) |
Add a new constructor to this class and prune and constructors made redundant by it. More... | |
template<Method::Properties Properties = Method::None, typename RetTypeT , typename NameT > | |
Method * | addMethod (RetTypeT &&retType, NameT &&name, Method::Properties properties, ArrayRef< MethodParameter > parameters) |
Add a new method to this class and prune any methods made redundant by it. More... | |
template<Method::Properties Properties = Method::None, typename RetTypeT , typename NameT > | |
Method * | addMethod (RetTypeT &&retType, NameT &&name, ArrayRef< MethodParameter > parameters) |
Add a method with statically-known properties. More... | |
template<Method::Properties Properties = Method::None, typename RetTypeT , typename NameT , typename... Args> | |
Method * | addMethod (RetTypeT &&retType, NameT &&name, Method::Properties properties, Args &&...args) |
template<Method::Properties Properties = Method::None, typename RetTypeT , typename NameT , typename... Args> | |
Method * | addMethod (RetTypeT &&retType, NameT &&name, Args &&...args) |
Add a method with statically-known properties. More... | |
template<Method::Properties Properties = Method::None, typename RetTypeT , typename NameT , typename... Args> | |
Method * | addStaticMethod (RetTypeT &&retType, NameT &&name, Args &&...args) |
Add a static method. More... | |
template<Method::Properties Properties = Method::None, typename RetTypeT , typename NameT , typename... Args> | |
Method * | addStaticInlineMethod (RetTypeT &&retType, NameT &&name, Args &&...args) |
Add an inline static method. More... | |
template<Method::Properties Properties = Method::None, typename RetTypeT , typename NameT , typename... Args> | |
Method * | addInlineMethod (RetTypeT &&retType, NameT &&name, Args &&...args) |
Add an inline method. More... | |
template<Method::Properties Properties = Method::None, typename RetTypeT , typename NameT , typename... Args> | |
Method * | addConstMethod (RetTypeT &&retType, NameT &&name, Args &&...args) |
Add a const method. More... | |
template<Method::Properties Properties = Method::None, typename RetTypeT , typename NameT , typename... Args> | |
Method * | declareMethod (RetTypeT &&retType, NameT &&name, Args &&...args) |
Add a declaration for a method. More... | |
template<Method::Properties Properties = Method::None, typename RetTypeT , typename NameT , typename... Args> | |
Method * | declareStaticMethod (RetTypeT &&retType, NameT &&name, Args &&...args) |
Add a declaration for a static method. More... | |
template<typename TypeT , typename NameT > | |
void | addField (TypeT &&type, NameT &&name) |
Add a new field to the class. More... | |
ParentClass & | addParent (ParentClass parent) |
Add a parent class. More... | |
template<typename ParamT > | |
void | addTemplateParam (ParamT param) |
Add a template parameter. More... | |
template<typename ContainerT > | |
void | addTemplateParams (ContainerT &&container) |
Add a list of template parameters. More... | |
StringRef | getClassName () const |
Return the C++ name of the class. More... | |
void | writeDeclTo (raw_ostream &rawOs) const |
Write the declaration of this class, all declarations, and definitions of inline functions. More... | |
void | writeDefTo (raw_ostream &rawOs) const |
Write the definitions of thiss class's out-of-line constructors and methods. More... | |
void | writeDeclTo (raw_indented_ostream &os) const |
Write the declaration of this class, all declarations, and definitions of inline functions. More... | |
void | writeDefTo (raw_indented_ostream &os) const |
Write the definitions of thiss class's out-of-line constructors and methods. More... | |
template<typename DeclT , typename... Args> | |
DeclT * | declare (Args &&...args) |
Add a declaration. More... | |
virtual void | finalize () |
The declaration of a class needs to be "finalized". More... | |
Protected Member Functions | |
Constructor * | addConstructorAndPrune (Constructor &&newCtor) |
Add a new constructor if it is not made redundant by any existing constructors and prune and existing constructors made redundant. More... | |
Method * | addMethodAndPrune (Method &&newMethod) |
Add a new method if it is not made redundant by any existing methods and prune and existing methods made redundant. More... | |
Visibility | getLastVisibilityDecl () const |
Get the last visibility declaration. More... | |
Protected Attributes | |
std::string | className |
The C++ class name. More... | |
SmallVector< ParentClass > | parents |
The list of parent classes. More... | |
std::vector< std::unique_ptr< Method > > | methods |
The pending list of methods and constructors. More... | |
SmallVector< Field > | fields |
The pending list of private class fields. More... | |
bool | isStruct |
Whether this is a class or a struct . More... | |
std::vector< std::unique_ptr< ClassDeclaration > > | declarations |
A list of declarations in the class, emitted in order. More... | |
SetVector< std::string, SmallVector< std::string >, StringSet<> > | templateParams |
An optional list of class template parameters. More... | |
A class used to emit C++ classes from Tablegen.
Contains a list of public methods and a list of private fields to be emitted.
|
virtualdefault |
|
delete |
Explicitly delete the copy constructor.
This is to work around a gcc-5 bug with std::is_trivially_move_constructible.
|
inline |
|
inline |
|
inline |
Add a new constructor to this class and prune and constructors made redundant by it.
Returns null if the constructor was not added. Else, returns a pointer to the new constructor.
Definition at line 666 of file Class.h.
References addConstructorAndPrune(), mlir::tblgen::Method::Constructor, getClassName(), mlir::tblgen::Method::Inline, and templateParams.
|
protected |
Add a new constructor if it is not made redundant by any existing constructors and prune and existing constructors made redundant.
Referenced by addConstructor().
|
inline |
|
inline |
|
inline |
Add a method with statically-known properties.
Definition at line 713 of file Class.h.
References addMethod().
|
inline |
Add a method with statically-known properties.
Definition at line 696 of file Class.h.
References addMethod().
|
inline |
Definition at line 704 of file Class.h.
References addMethod().
|
inline |
Add a new method to this class and prune any methods made redundant by it.
Returns null if the method was not added (because an existing method would make it redundant). Else, returns a pointer to the new method.
Definition at line 682 of file Class.h.
References addMethodAndPrune(), mlir::tblgen::Method::Inline, and templateParams.
Referenced by addMethod().
Add a new method if it is not made redundant by any existing methods and prune and existing methods made redundant.
Referenced by addMethod().
ParentClass& mlir::tblgen::Class::addParent | ( | ParentClass | parent | ) |
Add a parent class.
|
inline |
|
inline |
|
inline |
Add a template parameter.
Definition at line 786 of file Class.h.
References mlir::tblgen::stringify(), and templateParams.
|
inline |
Add a list of template parameters.
Definition at line 792 of file Class.h.
References templateParams.
|
inline |
Add a declaration.
The declaration is appended directly to the list of class declarations.
Definition at line 822 of file Class.h.
References declarations.
|
inline |
|
inline |
|
virtual |
The declaration of a class needs to be "finalized".
Class constructors, methods, and fields can be added in any order, regardless of whether they are public or private. These are stored in lists separate from list of declarations declarations
.
So that the generated C++ code is somewhat organised, public methods are declared together, and so are private methods and class fields. This function iterates through all the added methods and fields and organises them into the list of declarations, adding visibility declarations as needed, as follows:
Class::finalize
clears the lists of pending methods and fields, and can be called multiple times.
|
inline |
Return the C++ name of the class.
Definition at line 797 of file Class.h.
References className.
Referenced by addConstructor().
|
protected |
Get the last visibility declaration.
void mlir::tblgen::Class::writeDeclTo | ( | raw_indented_ostream & | os | ) | const |
Write the declaration of this class, all declarations, and definitions of inline functions.
|
inline |
void mlir::tblgen::Class::writeDefTo | ( | raw_indented_ostream & | os | ) | const |
Write the definitions of thiss class's out-of-line constructors and methods.
|
inline |
|
protected |
|
protected |
|
protected |
The pending list of private class fields.
Definition at line 867 of file Class.h.
Referenced by addField().
|
protected |
|
protected |
|
protected |
|
protected |
An optional list of class template parameters.
Definition at line 875 of file Class.h.
Referenced by addConstructor(), addMethod(), addTemplateParam(), and addTemplateParams().