MLIR
20.0.0git
|
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) | |
FmtContext & | addSubst (StringRef placeholder, const Twine &subst) |
FmtContext & | withBuilder (Twine subst) |
FmtContext & | withSelf (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) |
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.
|
strong |
|
default |
FmtContext::FmtContext | ( | ArrayRef< std::pair< StringRef, StringRef >> | subs | ) |
Definition at line 26 of file Format.cpp.
References addSubst().
FmtContext & FmtContext::addSubst | ( | StringRef | placeholder, |
const Twine & | subst | ||
) |
Definition at line 31 of file Format.cpp.
Referenced by canUniqueAttrConstraint(), and FmtContext().
|
static |
std::optional< StringRef > FmtContext::getSubstFor | ( | FmtContext::PHKind | placeholder | ) | const |
Definition at line 47 of file Format.cpp.
Referenced by mlir::tblgen::FmtObjectBase::format().
std::optional< StringRef > FmtContext::getSubstFor | ( | StringRef | placeholder | ) | const |
Definition at line 57 of file Format.cpp.
FmtContext & FmtContext::withBuilder | ( | Twine | subst | ) |
Definition at line 36 of file Format.cpp.
References Builder.
FmtContext & FmtContext::withSelf | ( | Twine | subst | ) |