aboutsummaryrefslogtreecommitdiff
path: root/llvm/docs/CommandGuide/tblgen.rst
blob: 92186579e682df38c6657bcf686937d8209e9cc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
tblgen - Description to C++ Code
================================

.. program:: tblgen

SYNOPSIS
--------

:program:`clang-tblgen` [*options*] [*filename*]

:program:`lldb-tblgen` [*options*] [*filename*]

:program:`llvm-tblgen` [*options*] [*filename*]

:program:`mlir-tblgen` [*options*] [*filename*]

DESCRIPTION
-----------

:program:`*-tblgen` is a family of programs that translates target
description (``.td``) files into C++ code and other output formats. Most
users of LLVM will not need to use this program. It is used only for
writing parts of the compiler, debugger, and LLVM target backends.

The details of the input and output of the :program:`*-tblgen` programs is
beyond the scope of this short introduction; please see the :doc:`TableGen
Overview <../TableGen/index>` for an introduction and for references to
additional TableGen documents.

The *filename* argument specifies the name of the Target Description (``.td``)
file that TableGen processes.

OPTIONS
-------

General Options
~~~~~~~~~~~~~~~

.. option:: -help

 Print a description of the command line options.

.. option:: -help-list

  Print a description of the command line options in a simple list format.

.. option:: -D=macroname

  Specify the name of a macro to be defined. The name is defined, but it
  has no particular value.

.. option:: -d=filename

  Specify the name of the dependency filename.

.. option:: -debug

  Enable debug output.

.. option:: -dump-json

 Print a JSON representation of all records, suitable for further
 automated processing.

.. option:: -I directory

 Specify where to find other target description files for inclusion.  The
 ``directory`` value should be a full or partial path to a directory that
 contains target description files.

.. option:: -null-backend

  Parse the source files and build the records, but do not run any
  backend. This is useful for timing the frontend.

.. option:: -o filename

 Specify the output file name.  If ``filename`` is ``-``, then
 :program:`*-tblgen` sends its output to standard output.

.. option:: -print-records

 Print all classes and records to standard output (default backend option).

.. option:: -print-detailed-records

  Print a detailed report of all global variables, classes, and records
  to standard output.

.. option:: -stats

  Print a report with any statistics collected by the backend.

.. option:: -time-phases

  Time the parser and backend phases and print a report.

.. option:: -version

 Show the version number of the program.

.. option:: -write-if-changed

  Write the output file only if it is new or has changed.


clang-tblgen Options
~~~~~~~~~~~~~~~~~~~~

.. option:: -gen-clang-attr-classes

  Generate Clang attribute classes.

.. option:: -gen-clang-attr-parser-string-switches

  Generate all parser-related attribute string switches.

.. option:: -gen-clang-attr-subject-match-rules-parser-string-switches

  Generate all parser-related attribute subject match rule string switches.

.. option:: -gen-clang-attr-impl

  Generate Clang attribute implementations.

.. option:: -gen-clang-attr-list"

  Generate a Clang attribute list.

.. option:: -gen-clang-attr-subject-match-rule-list

  Generate a Clang attribute subject match rule list.

.. option:: -gen-clang-attr-pch-read

  Generate Clang PCH attribute reader.

.. option:: -gen-clang-attr-pch-write

  Generate Clang PCH attribute writer.

.. option:: -gen-clang-attr-has-attribute-impl

  Generate a Clang attribute spelling list.

.. option:: -gen-clang-attr-spelling-index

  Generate a Clang attribute spelling index.

.. option:: -gen-clang-attr-ast-visitor

  Generate a recursive AST visitor for Clang attributes.

.. option:: -gen-clang-attr-template-instantiate

  Generate a Clang template instantiate code.

.. option:: -gen-clang-attr-parsed-attr-list

  Generate a Clang parsed attribute list.

.. option:: -gen-clang-attr-parsed-attr-impl

  Generate the Clang parsed attribute helpers.

.. option:: -gen-clang-attr-parsed-attr-kinds

  Generate a Clang parsed attribute kinds.

.. option:: -gen-clang-attr-text-node-dump

  Generate Clang attribute text node dumper.

.. option:: -gen-clang-attr-node-traverse

  Generate Clang attribute traverser.

.. option:: -gen-clang-diags-defs

  Generate Clang diagnostics definitions.

.. option:: -clang-component component

  Only use warnings from specified component.

.. option:: -gen-clang-diag-groups

  Generate Clang diagnostic groups.

.. option:: -gen-clang-diags-index-name

  Generate Clang diagnostic name index.

.. option:: -gen-clang-basic-reader

  Generate Clang BasicReader classes.

.. option:: -gen-clang-basic-writer

  Generate Clang BasicWriter classes.

.. option:: -gen-clang-comment-nodes

  Generate Clang AST comment nodes.

.. option:: -gen-clang-decl-nodes

  Generate Clang AST declaration nodes.

.. option:: -gen-clang-stmt-nodes

  Generate Clang AST statement nodes.

.. option:: -gen-clang-type-nodes

  Generate Clang AST type nodes.

.. option:: -gen-clang-type-reader

  Generate Clang AbstractTypeReader class.

.. option:: -gen-clang-type-writer

  Generate Clang AbstractTypeWriter class.

.. option:: -gen-clang-opcodes

  Generate Clang constexpr interpreter opcodes.

.. option:: -gen-clang-sa-checkers

  Generate Clang static analyzer checkers.

.. option:: -gen-clang-comment-html-tags

  Generate efficient matchers for HTML tag names that are used in
  documentation comments.

.. option:: -gen-clang-comment-html-tags-properties

  Generate efficient matchers for HTML tag properties.

.. option:: -gen-clang-comment-html-named-character-references

  Generate function to translate named character references to UTF-8 sequences.

.. option:: -gen-clang-comment-command-info

  Generate command properties for commands that are used in documentation comments.

.. option:: -gen-clang-comment-command-list

  Generate list of commands that are used in documentation comments.

.. option:: -gen-clang-opencl-builtins

  Generate OpenCL builtin declaration handlers.

.. option:: -gen-arm-neon

  Generate ``arm_neon.h`` for Clang.

.. option:: -gen-arm-fp16

  Generate ``arm_fp16.h`` for Clang.

.. option:: -gen-arm-bf16

  Generate ``arm_bf16.h`` for Clang.

.. option:: -gen-arm-neon-sema

  Generate ARM NEON sema support for Clang.

.. option:: -gen-arm-neon-test

  Generate ARM NEON tests for Clang.

.. option:: -gen-arm-immcheck-types

  Generate ``arm_immcheck_types.inc`` for Clang.

.. option:: -gen-arm-sve-header

  Generate ``arm_sve.h`` for Clang.

.. option:: -gen-arm-sve-builtins

  Generate ``arm_sve_builtins.inc`` for Clang.

.. option:: -gen-arm-sve-builtin-codegen

  Generate ``arm_sve_builtin_cg_map.inc`` for Clang.

.. option:: -gen-arm-sve-typeflags

  Generate ``arm_sve_typeflags.inc`` for Clang.

.. option:: -gen-arm-sve-sema-rangechecks

  Generate ``arm_sve_sema_rangechecks.inc`` for Clang.

.. option:: -gen-arm-mve-header

  Generate ``arm_mve.h`` for Clang.

.. option:: -gen-arm-mve-builtin-def

  Generate ARM MVE builtin definitions for Clang.

.. option:: -gen-arm-mve-builtin-sema

  Generate ARM MVE builtin sema checks for Clang.

.. option:: -gen-arm-mve-builtin-codegen

  Generate ARM MVE builtin code-generator for Clang.

.. option:: -gen-arm-mve-builtin-aliases

  Generate list of valid ARM MVE builtin aliases for Clang.

.. option:: -gen-arm-cde-header

  Generate ``arm_cde.h`` for Clang.

.. option:: -gen-arm-cde-builtin-def

  Generate ARM CDE builtin definitions for Clang.

.. option:: -gen-arm-cde-builtin-sema

  Generate ARM CDE builtin sema checks for Clang.

.. option:: -gen-arm-cde-builtin-codegen

  Generate ARM CDE builtin code-generator for Clang.

.. option:: -gen-arm-cde-builtin-aliases

  Generate list of valid ARM CDE builtin aliases for Clang.

.. option:: -gen-riscv-vector-header

  Generate ``riscv_vector.h`` for Clang.

.. option:: -gen-riscv-vector-builtins

  Generate ``riscv_vector_builtins.inc`` for Clang.

.. option:: -gen-riscv-vector-builtin-codegen

  Generate ``riscv_vector_builtin_cg.inc`` for Clang.

.. option:: -gen-riscv-sifive-vector-builtins

  Generate ``riscv_sifive_vector_builtins.inc`` for Clang.

.. option:: -gen-riscv-sifive-vector-builtin-codegen

  Generate ``riscv_sifive_vector_builtin_cg.inc`` for Clang.

.. option:: -gen-attr-docs

  Generate attribute documentation.

.. option:: -gen-diag-docs

  Generate diagnostic documentation.

.. option:: -gen-opt-docs

  Generate option documentation.

.. option:: -gen-clang-data-collectors

  Generate data collectors for AST nodes.

.. option:: -gen-clang-test-pragma-attribute-supported-attributes

  Generate a list of attributes supported by ``#pragma`` Clang attribute for
  testing purposes.


lldb-tblgen Options
~~~~~~~~~~~~~~~~~~~

.. option:: gen-lldb-option-defs

  Generate lldb OptionDefinition values.

.. option:: gen-lldb-property-defs

  Generate lldb PropertyDefinition values.

.. option:: gen-lldb-property-enum-defs

  Generate lldb PropertyDefinition enum values.


llvm-tblgen Options
~~~~~~~~~~~~~~~~~~~

.. option:: -gen-asm-matcher

 Generate assembly instruction matcher.

.. option:: -match-prefix=prefix

  Make -gen-asm-matcher match only instructions with the given *prefix*.

.. option:: -gen-asm-parser

 Generate assembly instruction parser.

.. option:: -asmparsernum=n

 Make -gen-asm-parser emit assembly parser number *n*.

.. option:: -gen-asm-writer

 Generate assembly writer.

.. option:: -asmwriternum=n

 Make -gen-asm-writer emit assembly writer number *n*.

.. option:: -gen-attrs

  Generate attributes.

.. option:: -gen-automata

  Generate generic automata.

.. option:: -gen-callingconv

  Generate calling convention descriptions.

.. option:: -gen-compress-inst-emitter

  Generate RISC-V compressed instructions.

.. option:: -gen-ctags

  Generate ctags-compatible index.

.. option:: -gen-dag-isel

 Generate a DAG (directed acyclic graph) instruction selector.

.. option:: -instrument-coverage

  Make -gen-dag-isel generate tables to help identify the patterns matched.

.. option:: -omit-comments

  Make -gen-dag-isel omit comments. The default is false.

.. option:: -gen-dfa-packetizer

 Generate DFA Packetizer for VLIW targets.

.. option:: -gen-directive-decl

  Generate directive related declaration code (header file).

.. option:: -gen-directive-gen

  Generate directive related implementation code part.

.. option:: -gen-directive-impl

  Generate directive related implementation code.

.. option:: -gen-disassembler

  Generate disassembler.

.. option:: -gen-emitter

 Generate machine code emitter.

.. option:: -gen-exegesis

  Generate llvm-exegesis tables.

.. option:: -gen-fast-isel

  Generate a "fast" instruction selector.

.. option:: -gen-global-isel

  Generate GlobalISel selector.

.. option:: -gisel-coverage-file=filename

  Specify the file from which to retrieve coverage information.

.. option:: -instrument-gisel-coverage

  Make -gen-global-isel generate coverage instrumentation.

.. option:: -optimize-match-table

  Make -gen-global-isel generate an optimized version of the match table.

.. option:: -warn-on-skipped-patterns

  Make -gen-global-isel explain why a pattern was skipped for inclusion.

.. option:: -gen-global-isel-combiner

  Generate GlobalISel combiner.

.. option:: -combiners=list

  Make -gen-global-isel-combiner emit the specified combiners.

.. option:: -gicombiner-debug-cxxpreds

  Add debug comments to all C++ predicates emitted by -gen-global-isel-combiner

.. option:: -gicombiner-stop-after-parse

  Make -gen-global-isel-combiner stop processing after parsing rules and dump state.

.. option:: -gen-instr-info

 Generate instruction descriptions.

.. option:: -gen-instr-docs

 Generate instruction documentation.

.. option:: -gen-intrinsic-enums

 Generate intrinsic enums.

.. option:: -intrinsic-prefix=prefix

  Make -gen-intrinsic-enums generate intrinsics with this target *prefix*.

.. option:: -gen-intrinsic-impl

 Generate intrinsic information.

.. option:: -gen-opt-parser-defs

  Generate options definitions.

.. option:: -gen-opt-rst

  Generate option RST.

.. option:: -gen-pseudo-lowering

 Generate pseudo instruction lowering.

.. option:: -gen-register-bank

  Generate register bank descriptions.

.. option:: -gen-register-info

  Generate registers and register classes info.

.. option:: -register-info-debug

  Make -gen-register-info dump register information for debugging.

.. option:: -gen-searchable-tables

  Generate generic searchable tables. See :doc:`TableGen BackEnds <../TableGen/BackEnds>`
  for a detailed description.

.. option:: -gen-subtarget

 Generate subtarget enumerations.

.. option:: -gen-x86-EVEX2VEX-tables

  Generate X86 EVEX to VEX compress tables.

.. option:: -gen-x86-fold-tables

  Generate X86 fold tables.

.. option:: -long-string-literals

  When emitting large string tables, prefer string literals over
  comma-separated char literals. This can be a readability and
  compile-time performance win, but upsets some compilers.

.. option:: -print-enums

 Print enumeration values for a class.

.. option:: -class=classname

 Make -print-enums print the enumeration list for the specified class.

.. option:: -print-sets

 Print expanded sets for testing DAG exprs.


mlir-tblgen Options
~~~~~~~~~~~~~~~~~~~

.. option:: -gen-avail-interface-decls

  Generate availability interface declarations.

.. option:: -gen-avail-interface-defs

  Generate op interface definitions.

.. option:: -gen-dialect-doc

  Generate dialect documentation.

.. option:: -dialect

  The dialect to generate.

.. option:: -gen-directive-decl

  Generate declarations for directives (OpenMP, etc.).

.. option:: -gen-enum-decls

  Generate enum utility declarations.

.. option:: -gen-enum-defs

  Generate enum utility definitions.

.. option:: -gen-enum-from-llvmir-conversions

  Generate conversions of EnumAttrs from LLVM IR.

.. option:: -gen-enum-to-llvmir-conversions

  Generate conversions of EnumAttrs to LLVM IR.

.. option:: -gen-llvmir-conversions

  Generate LLVM IR conversions.

.. option:: -gen-llvmir-intrinsics

  Generate LLVM IR intrinsics.

.. option:: -llvmir-intrinsics-filter

  Only keep the intrinsics with the specified substring in their record name.

.. option:: -dialect-opclass-base

  The base class for the ops in the dialect we are to emit.

.. option:: -gen-op-decls

  Generate operation declarations.

.. option:: -gen-op-defs

  Generate operation definitions.

.. option:: -asmformat-error-is-fatal

  Emit a fatal error if format parsing fails.

.. option:: -op-exclude-regex

  Regular expression of name of ops to exclude (no filter if empty).

.. option:: -op-include-regex

  Regular expression of name of ops to include (no filter if empty).

.. option:: -gen-op-doc

  Generate operation documentation.

.. option:: -gen-pass-decls

  Generate operation documentation.

.. option:: -name namestring

  The name of this group of passes.

.. option:: -gen-pass-doc

  Generate pass documentation.

.. option:: -gen-rewriters

  Generate pattern rewriters.

.. option:: -gen-spirv-avail-impls

  Generate SPIR-V operation utility definitions.

.. option:: -gen-spirv-capability-implication

  Generate utility function to return implied capabilities for a given capability.

.. option:: -gen-spirv-enum-avail-decls

  Generate SPIR-V enum availability declarations.

.. option:: -gen-spirv-enum-avail-defs

  Generate SPIR-V enum availability definitions.

.. option:: -gen-spirv-op-utils

  Generate SPIR-V operation utility definitions.

.. option:: -gen-spirv-serialization

  Generate SPIR-V (de)serialization utilities and functions.

.. option:: -gen-struct-attr-decls

  Generate struct utility declarations.

.. option:: -gen-struct-attr-defs

  Generate struct utility definitions.

.. option:: -gen-typedef-decls

  Generate TypeDef declarations.

.. option:: -gen-typedef-defs

  Generate TypeDef definitions.

.. option:: -typedefs-dialect name

  Generate types for this dialect.

EXIT STATUS
-----------

If :program:`*-tblgen` succeeds, it will exit with 0.  Otherwise, if an error
occurs, it will exit with a non-zero value.