Files
TheRock/compiler/amd-llvm/llvm/utils/TableGen/jupyter/LLVM_TableGen.ipynb
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

10 KiB

LLVM TableGen Kernel

This notebook is running llvm-tblgen.

In [1]:
%reset
// This is some tablegen
class Foo {}
------------- Classes -----------------
class Foo {
}
------------- Defs -----------------

Errors printed to stderr are shown.

In [2]:
%reset
This is not tablegen.
<stdin>:1:1: error: Unexpected token at top level
This is not tablegen.
^

Add some classes to get some output.

In [3]:
%reset
class Stuff {}
def thing : Stuff {}
------------- Classes -----------------
class Stuff {
}
------------- Defs -----------------
def thing {	// Stuff
}

By default cells are connected. Meaning that we cache the code and magic directives from the previously run cells.

This means that the next cell still sees the Stuff class.

In [4]:
def other_thing : Stuff {}
------------- Classes -----------------
class Stuff {
}
------------- Defs -----------------
def other_thing {	// Stuff
}
def thing {	// Stuff
}

You can use the magic %reset to clear this cache and start fresh.

In [5]:
%reset
def other_thing : Stuff {}
<stdin>:1:19: error: Couldn't find class 'Stuff'
def other_thing : Stuff {}
                  ^

You can also configure the default reset behaviour using the %config magic.

In [6]:
%config cellreset on
class Thing {}
------------- Classes -----------------
class Thing {
}
------------- Defs -----------------
In [7]:
// The cache is reset here so this is an error.
def AThing: Thing {}
<stdin>:2:13: error: Couldn't find class 'Thing'
def AThing: Thing {}
            ^

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.

In [8]:
class Thing {}
------------- Classes -----------------
class Thing {
}
------------- Defs -----------------
In [9]:
%noreset
// This works because of the noreset above.
def AThing: Thing {}
------------- Classes -----------------
class Thing {
}
------------- Defs -----------------
def AThing {	// Thing
}
In [10]:
// This does not because we're not changing the default.
def AnotherThing: Thing {}
<stdin>:2:19: error: Couldn't find class 'Thing'
def AnotherThing: Thing {}
                  ^
In [11]:
%config cellreset off
%reset
// Here we have an empty cache and default reset behaviour.
------------- Classes -----------------
------------- Defs -----------------

It is not valid to have %reset and %noreset in the same cell.

In [12]:
%reset
%noreset
%reset and %noreset in the same cell is not allowed. Use only one, or neither.

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.

There is a "magic" directive %args that you can use to send command line arguments to llvm-tblgen.

For example, here we have some code that shows a warning.

In [13]:
%reset
class Thing <int A, int B> {
    int num = A;
}
<stdin>:1:25: warning: unused template argument: Thing:B
class Thing <int A, int B> {
                        ^

We can pass an argument to ignore that warning.

In [14]:
%args --no-warn-on-unused-template-args
------------- Classes -----------------
class Thing<int Thing:A = ?, int Thing:B = ?> {
  int num = Thing:A;
}
------------- Defs -----------------

If you have a run of cells without a %reset, the most recent %args is used.

In [15]:
// This passes --no-warn-on-unused-template-args
------------- Classes -----------------
class Thing<int Thing:A = ?, int Thing:B = ?> {
  int num = Thing:A;
}
------------- Defs -----------------
In [16]:
%args
// Now we're not passing the argument so the warning comes back.
<stdin>:1:25: warning: unused template argument: Thing:B
class Thing <int A, int B> {
                        ^

If there are many %args in a cell, the last one is used.

In [17]:
%reset
%args --no-warn-on-unused-template-args
%args
class Thing <int A, int B> {}
<stdin>:1:18: warning: unused template argument: Thing:A
class Thing <int A, int B> {}
                 ^
<stdin>:1:25: warning: unused template argument: Thing:B
class Thing <int A, int B> {}
                        ^