MLIR  20.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
mlir::tblgen::FmtContext Class Reference

Format context containing substitutions for special placeholders. More...

#include "mlir/TableGen/Format.h"

Public Types

enum class  PHKind : char { None , Custom , Builder , Self }
 

Public Member Functions

 FmtContext ()=default
 
 FmtContext (ArrayRef< std::pair< StringRef, StringRef >> subs)
 
FmtContextaddSubst (StringRef placeholder, const Twine &subst)
 
FmtContextwithBuilder (Twine subst)
 
FmtContextwithSelf (Twine subst)
 
std::optional< StringRef > getSubstFor (PHKind placeholder) const
 
std::optional< StringRef > getSubstFor (StringRef placeholder) const
 

Static Public Member Functions

static PHKind getPlaceHolderKind (StringRef str)
 

Detailed Description

Format context containing substitutions for special placeholders.

This context divides special placeholders into two categories: builtin ones and custom ones.

Builtin placeholders are baked into FmtContext and each one of them has a dedicated setter. They can be used in all dialects. Their names follow the convention of $_<name>. The rationale of the leading underscore is to avoid confusion and name collision: op arguments/attributes/results are named as $<name>, and we can potentially support referencing those entities directly in the format template in the future. Custom ones are registered by dialect-specific TableGen backends and use the same unified setter.

Definition at line 40 of file Format.h.

Member Enumeration Documentation

◆ PHKind

Enumerator
None 
Custom 
Builder 
Self 

Definition at line 43 of file Format.h.

Constructor & Destructor Documentation

◆ FmtContext() [1/2]

mlir::tblgen::FmtContext::FmtContext ( )
default

◆ FmtContext() [2/2]

FmtContext::FmtContext ( ArrayRef< std::pair< StringRef, StringRef >>  subs)

Definition at line 26 of file Format.cpp.

References addSubst().

Member Function Documentation

◆ addSubst()

FmtContext & FmtContext::addSubst ( StringRef  placeholder,
const Twine &  subst 
)

Definition at line 31 of file Format.cpp.

Referenced by canUniqueAttrConstraint(), and FmtContext().

◆ getPlaceHolderKind()

FmtContext::PHKind FmtContext::getPlaceHolderKind ( StringRef  str)
static

Definition at line 64 of file Format.cpp.

References Builder, Custom, None, and Self.

◆ getSubstFor() [1/2]

std::optional< StringRef > FmtContext::getSubstFor ( FmtContext::PHKind  placeholder) const

Definition at line 47 of file Format.cpp.

References Custom, and None.

Referenced by mlir::tblgen::FmtObjectBase::format().

◆ getSubstFor() [2/2]

std::optional< StringRef > FmtContext::getSubstFor ( StringRef  placeholder) const

Definition at line 57 of file Format.cpp.

◆ withBuilder()

FmtContext & FmtContext::withBuilder ( Twine  subst)

Definition at line 36 of file Format.cpp.

References Builder.

◆ withSelf()

FmtContext & FmtContext::withSelf ( Twine  subst)

Definition at line 41 of file Format.cpp.

References Self.

Referenced by canUniqueAttrConstraint().


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