[PATCH] D72425: [OptRemark] RFC: Introduce a message table for OptRemarks
Andrei Elovikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 17:12:34 PDT 2020
a.elovikov added inline comments.
================
Comment at: llvm/test/TableGen/opt-remark-diag.td:20
+
+// CHECK-ENUMS: enum OptRemarkDiagGroup_Test1 {
+// CHECK-ENUMS: RemarkName = 10000,
----------------
thegameg wrote:
> What would be the use case of these enums? Can't the same be achieved by not quoting `RemarkName` and `Test1` in the `OPT_REMARK(` macros like in `clang/include/clang/Driver/Options.h`:
>
> ```
> enum ID {
> OPT_INVALID = 0, // This is not an option ID.
> #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
> HELPTEXT, METAVAR, VALUES) \
> OPT_##ID,
> #include "clang/Driver/Options.inc"
> LastOption
> #undef OPTION
> };
> ```
I'm more interested in what other use-cases for OPT_REMARKs are. I believe C++ macros and tablegen serve the same purpose so I'm not sure if it's beneficial to use both at the same time. On the other hand, I want to extend the .td description of remarks to simple statistics so that each remark will be something like "number of <smth>: X" and auto-generate most of the code for handling it. I.e., given
```
let Group = StatisticsFoo in {
def remark_statistic_one : OptRemark<"StatisticOne", "Number of EventOne: %{Arg}>;
def remark_statistic_two : OptRemark<"StatisticTwo", "Number of EventTwo: %{Arg}>;
}
```
I'd like to be able to generate
```
struct StatisticsFooStorage {
NumStatisticOne = 0;
NumStatisticTwo = 0;
void emit(RemarkEmitter Emitter) {
Emitter.emit(StatisticOneRemarkString.format(NumStatisticOne);
Emitter.emit(StatisticTwoRemarkString.format(NumStatisticTwo);
}
}
```
And actual optizmiation
```
StatisticsFooStorage StatStorage;
// ...
if (something)
++StatStorage.NumStatisticOne;
//
RemarksEmitter Emitter;
StatStorage.emit(Emitter);
```
I think writing direct tblgen emitter for this might be easier than using the OPT_REMARK macros (although that would probably be doable as well).
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72425/new/
https://reviews.llvm.org/D72425
More information about the llvm-commits
mailing list