llvm-project/mlir/tools/mlir-tblgen/CppGenUtilities.h
Peng Chen 3138f6cc8c
[MLIR] Generate cpp comments for TableGen summary and description (#139606)
This commit takes the `summary` and `description` of TableGen files and
generate a cpp comments on top of the declarations of generated cpp
classes. 

The main motivation is to improve the developer experience. When people
work on compilers from an IDE, they will be able to hover over the
symbols (e.g. `"ADialect::BOp"`) in their cpp code and see the summary
and descriptions without having to referring to the `.td` files.
2025-05-14 22:09:48 +02:00

30 lines
1.1 KiB
C++

//===- CppGenUtilities.h - MLIR cpp gen utilities ---------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines common utilities for generating cpp files from tablegen
// structures.
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_TOOLS_MLIRTBLGEN_CPPGENUTILITIES_H_
#define MLIR_TOOLS_MLIRTBLGEN_CPPGENUTILITIES_H_
#include "llvm/ADT/StringRef.h"
namespace mlir {
namespace tblgen {
// Emit the summary and description as a C++ comment, perperly aligned placed
// adjacent to the class declaration of generated classes.
std::string emitSummaryAndDescComments(llvm::StringRef summary,
llvm::StringRef description);
} // namespace tblgen
} // namespace mlir
#endif // MLIR_TOOLS_MLIRTBLGEN_CPPGENUTILITIES_H_