[PATCH] D132646: [LLVM][TableGen] Support combined cells in jupyter kernel

Jacques Pienaar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 27 10:51:27 PST 2022


jpienaar added a comment.

LGTM



================
Comment at: llvm/utils/TableGen/jupyter/tablegen_kernel/kernel.py:86
+        Returns a tuple of newline joined code lines and a dictionary of magic.
+        Where the key is the magic name (minus the %) and the values are lists
+        of the arguments to the magic.
----------------
DavidSpickett wrote:
> jpienaar wrote:
> > Wouldn't this collapse all magic to top rather than allowing different magic per section?  And in the examples, it seems we have magic at the top only per sections of code.
> By section do you mean block of code _within_ a cell? If so you are right and this is how I intend that to work, for now at least. This is what I meant by the comment further down about only supporting "cell magic".
> 
> If you're wondering if magic in the middle of a cell will it be sort of moved up and made to apply to the whole cell, it won't. As shown in this test:
> ```
> >>> k.get_magic("%foo a b\\n \\n%foo c d")
>         (' \\n%foo c d', {'foo': ['a', 'b']})
> ```
> After you break the run of lines beginning with `%` we assume it's all source code.
> 
> If you're instead talking about what happens across cells then it goes like this.
> 
> If the cell does a reset then the magic is cleaned and it can set new values as needed. Otherwise we'll merge the magic from the most recent cell with the set of cached magic. For example:
> ```
> %args --disable-the-warning
> // some code that only compiles with a warning disabled.
> ```
> ```
> % args
> // some more code, which will be added to the previous cell content
> ```
> The first cell will compile the second one won't.
> 
> Since the model is based around giving llvm-tblgen one source file and one set of arguments.
> 
> Hopefully that makes sense, if the code gives a different impression I'll fix it and make it clearer.
> 
Ah I thought it collect all arguments and collect all source and pass in to one invocation. Rather, it concatenates source and overrides args (if provided) as you go.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132646/new/

https://reviews.llvm.org/D132646



More information about the llvm-commits mailing list