4 "cell_type": "markdown",
8 "# LLVM TableGen Kernel"
12 "cell_type": "markdown",
16 "This notebook is running `llvm-tblgen`."
27 "output_type": "stream",
29 "------------- Classes -----------------\n",
32 "------------- Defs -----------------\n"
38 "// This is some tablegen\n",
43 "cell_type": "markdown",
47 "Errors printed to stderr are shown."
60 "output_type": "stream",
62 "<stdin>:1:1: error: Unexpected token at top level\n",
63 "This is not tablegen.\n",
70 "This is not tablegen."
74 "cell_type": "markdown",
78 "Add some classes to get some output."
89 "output_type": "stream",
91 "------------- Classes -----------------\n",
94 "------------- Defs -----------------\n",
95 "def thing {\t// Stuff\n",
103 "def thing : Stuff {}"
107 "cell_type": "markdown",
111 "By default cells are connected. Meaning that we cache the code and magic directives from the previously run cells.\n",
113 "This means that the next cell still sees the `Stuff` class."
118 "execution_count": 4,
126 "output_type": "stream",
128 "------------- Classes -----------------\n",
131 "------------- Defs -----------------\n",
132 "def other_thing {\t// Stuff\n",
134 "def thing {\t// Stuff\n",
140 "def other_thing : Stuff {}"
144 "cell_type": "markdown",
148 "You can use the magic `%reset` to clear this cache and start fresh."
153 "execution_count": 5,
159 "output_type": "stream",
161 "<stdin>:1:19: error: Couldn't find class 'Stuff'\n",
162 "def other_thing : Stuff {}\n",
169 "def other_thing : Stuff {}"
173 "cell_type": "markdown",
177 "You can also configure the default reset behaviour using the `%config` magic."
182 "execution_count": 6,
188 "output_type": "stream",
190 "------------- Classes -----------------\n",
193 "------------- Defs -----------------\n"
198 "%config cellreset on\n",
204 "execution_count": 7,
210 "output_type": "stream",
212 "<stdin>:2:13: error: Couldn't find class 'Thing'\n",
213 "def AThing: Thing {}\n",
219 "// The cache is reset here so this is an error.\n",
220 "def AThing: Thing {}"
224 "cell_type": "markdown",
228 "The default value is `off`, meaning cells are connected. If you want to override the default for one cell only, use the `%reset` or `%noreset` magic. These always override the default."
233 "execution_count": 8,
239 "output_type": "stream",
241 "------------- Classes -----------------\n",
244 "------------- Defs -----------------\n"
254 "execution_count": 9,
260 "output_type": "stream",
262 "------------- Classes -----------------\n",
265 "------------- Defs -----------------\n",
266 "def AThing {\t// Thing\n",
273 "// This works because of the noreset above.\n",
274 "def AThing: Thing {}"
279 "execution_count": 10,
285 "output_type": "stream",
287 "<stdin>:2:19: error: Couldn't find class 'Thing'\n",
288 "def AnotherThing: Thing {}\n",
294 "// This does not because we're not changing the default.\n",
295 "def AnotherThing: Thing {}"
300 "execution_count": 11,
306 "output_type": "stream",
308 "------------- Classes -----------------\n",
309 "------------- Defs -----------------\n"
314 "%config cellreset off\n",
316 "// Here we have an empty cache and default reset behaviour."
320 "cell_type": "markdown",
324 "It is not valid to have `%reset` and `%noreset` in the same cell."
329 "execution_count": 12,
335 "output_type": "stream",
337 "%reset and %noreset in the same cell is not allowed. Use only one, or neither."
347 "cell_type": "markdown",
351 "Consider setting `cellreset` to the majority usecase for your notebook. For example a tutorial building a large example across many cells will likely want it `off`. One with many standalone examples, `on`.\n",
353 "There is a \"magic\" directive `%args` that you can use to send command line arguments to `llvm-tblgen`.\n",
355 "For example, here we have some code that shows a warning."
360 "execution_count": 13,
366 "output_type": "stream",
368 "<stdin>:1:25: warning: unused template argument: Thing:B\n",
369 "class Thing <int A, int B> {\n",
376 "class Thing <int A, int B> {\n",
382 "cell_type": "markdown",
386 "We can pass an argument to ignore that warning."
391 "execution_count": 14,
397 "output_type": "stream",
399 "------------- Classes -----------------\n",
400 "class Thing<int Thing:A = ?, int Thing:B = ?> {\n",
401 " int num = Thing:A;\n",
403 "------------- Defs -----------------\n"
408 "%args --no-warn-on-unused-template-args"
412 "cell_type": "markdown",
416 "If you have a run of cells without a `%reset`, the most recent `%args` is used."
421 "execution_count": 15,
427 "output_type": "stream",
429 "------------- Classes -----------------\n",
430 "class Thing<int Thing:A = ?, int Thing:B = ?> {\n",
431 " int num = Thing:A;\n",
433 "------------- Defs -----------------\n"
438 "// This passes --no-warn-on-unused-template-args"
443 "execution_count": 16,
449 "output_type": "stream",
451 "<stdin>:1:25: warning: unused template argument: Thing:B\n",
452 "class Thing <int A, int B> {\n",
459 "// Now we're not passing the argument so the warning comes back."
463 "cell_type": "markdown",
467 "If there are many `%args` in a cell, the last one is used."
472 "execution_count": 17,
478 "output_type": "stream",
480 "<stdin>:1:18: warning: unused template argument: Thing:A\n",
481 "class Thing <int A, int B> {}\n",
483 "<stdin>:1:25: warning: unused template argument: Thing:B\n",
484 "class Thing <int A, int B> {}\n",
491 "%args --no-warn-on-unused-template-args\n",
493 "class Thing <int A, int B> {}"
499 "display_name": "LLVM TableGen",
500 "language": "tablegen",
504 "file_extension": ".td",
505 "mimetype": "text/x-tablegen",
507 "pygments_lexer": "text"