mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 07:04:04 -05:00
LLVM TableGen: Improve docstring for Actions Override and add example (#5711)
A majority of the actions/backends expect to find certain classes and definitions in the source code. There's no canonical reference for this so it's a combination of incomplete docs and the actual uses in llvm-project. (most of the time I expect people will come from llvm-project to experiment, rather than the other way around) I've added an example that uses the Searchable Tables backend. <!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE IT Thanks for taking the time to improve CE. We really appreciate it. Before opening the PR, please make sure that the tests & linter pass their checks, by running `make check`. In the best case scenario, you are also adding tests to back up your changes, but don't sweat it if you don't. We can discuss them at a later date. Feel free to append your name to the CONTRIBUTORS.md file Thanks again, we really appreciate this! -->
This commit is contained in:
20
examples/tablegen/searchable_tables.td
Normal file
20
examples/tablegen/searchable_tables.td
Normal file
@@ -0,0 +1,20 @@
|
||||
// This example uses the Searchable Tables backend, aka --gen-searchable-tables.
|
||||
// To choose the backend, select it as the "Action" in the "Overrides" menu,
|
||||
// or add "--gen-searchable-tables" to the compiler options.
|
||||
// For more details:
|
||||
// https://llvm.org/docs/TableGen/BackEnds.html#searchabletables-reference
|
||||
|
||||
include "llvm/TableGen/SearchableTable.td"
|
||||
|
||||
class Pair<string name, int value> : SearchableTable {
|
||||
let SearchableFields = ["Name", "Value"];
|
||||
let EnumValueField = "Value";
|
||||
|
||||
string Name = name;
|
||||
bits<2> Value = value;
|
||||
}
|
||||
|
||||
def : Pair<"Example 0", 0b00>;
|
||||
def : Pair<"Example 1", 0b01>;
|
||||
def : Pair<"Example 2", 0b10>;
|
||||
def : Pair<"Example 3", 0b11>;
|
||||
@@ -32,7 +32,13 @@ export class TableGenCompiler extends BaseCompiler {
|
||||
display_title: 'Action',
|
||||
description:
|
||||
'The action to perform, which is the backend you wish to ' +
|
||||
'run. By default, the records are just printed as text.',
|
||||
'run. By default, the records are just printed as text. ' +
|
||||
'Many backends expect to find certain classes and defnitions ' +
|
||||
'in your source code. You may find details of those in the ' +
|
||||
'<a href="https://llvm.org/docs/TableGen/BackEnds.html" target="_blank">documentation</a>, ' +
|
||||
'but if not, refer to use of the backend in the ' +
|
||||
'<a href="https://github.com/llvm/llvm-project" target="_blank">LLVM Project</a> ' +
|
||||
'by searching for the command line name e.g. "gen-attrs".',
|
||||
flags: ['<value>'],
|
||||
values: possibleActions,
|
||||
default: '--print-records',
|
||||
|
||||
Reference in New Issue
Block a user