My Project
Classes | Typedefs | Functions
mlir::tblgen Namespace Reference

Classes

struct  AppliedConstraint
 
class  AttrConstraint
 
class  Attribute
 
class  CombinedPred
 
class  ConcatPred
 
class  ConstantAttr
 
class  Constraint
 
class  CPred
 
class  DagLeaf
 
class  DagNode
 
class  Dialect
 
class  EnumAttr
 
class  EnumAttrCase
 
class  FmtContext
 
class  FmtObject
 
class  FmtObjectBase
 
struct  FmtReplacement
 
class  InterfaceOpTrait
 
class  InternalOpTrait
 
struct  NamedAttribute
 
struct  NamedRegion
 
struct  NamedTypeConstraint
 
class  NativeOpTrait
 
class  Operator
 
class  OpInterface
 
class  OpInterfaceMethod
 
class  OpTrait
 
class  Pattern
 
class  Pred
 
class  PredOpTrait
 
class  Region
 
class  StructAttr
 
class  StructFieldAttr
 
class  SubstLeavesPred
 
class  SymbolInfoMap
 
class  Type
 
class  TypeConstraint
 

Typedefs

using Argument = llvm::PointerUnion< NamedAttribute *, NamedTypeConstraint * >
 
using RecordOperatorMap = DenseMap< const llvm::Record *, std::unique_ptr< Operator > >
 

Functions

template<typename... Ts>
auto tgfmt (StringRef fmt, const FmtContext *ctx, Ts &&... vals) -> FmtObject< decltype(std::make_tuple(llvm::detail::build_format_adapter(std::forward< Ts >(vals))...))>
 

Typedef Documentation

◆ Argument

◆ RecordOperatorMap

using mlir::tblgen::RecordOperatorMap = typedef DenseMap<const llvm::Record *, std::unique_ptr<Operator> >

Function Documentation

◆ tgfmt()

template<typename... Ts>
auto mlir::tblgen::tgfmt ( StringRef  fmt,
const FmtContext ctx,
Ts &&...  vals 
) -> FmtObject<decltype(std::make_tuple( llvm::detail::build_format_adapter(std::forward<Ts>(vals))...))>
inline

Formats text by substituting placeholders in format string with replacement parameters.

There are two categories of placeholders accepted, both led by a '$' sign:

  1. Positional placeholder: $[0-9]+
  2. Special placeholder: $[a-zA-Z_][a-zA-Z0-9_]*

Replacement parameters for positional placeholders are supplied as the vals parameter pack with 1:1 mapping. That is, $0 will be replaced by the first parameter in vals, $1 by the second one, and so on. Note that you can use the positional placeholders in any order and repeat any times, for example, "$2 $1 $1 $0" is accepted.

Replacement parameters for special placeholders are supplied using the ctx format context.

The fmt is recorded as a StringRef inside the returned FmtObject. The caller needs to make sure the underlying data is available when the FmtObject is used.

ctx accepts a nullptr if there is no special placeholder is used.

If no substitution is provided for a placeholder or any error happens during format string parsing or replacement, the placeholder will be outputted as-is with an additional marker '<no-subst-found>', to aid debugging.

To print a '$' literally, escape it with '$$'.

This utility function is inspired by LLVM formatv(), with modifications specially tailored for TableGen C++ generation usage:

  1. This utility use '$' instead of '{' and '}' for denoting the placeholder because '{' and '}' are frequently used in C++ code.
  2. This utility does not support format layout because it is rarely needed in C++ code generation.