https://github.com/tkf/showcode.jl
A tool for exploring and visualizing Julia code
https://github.com/tkf/showcode.jl
Last synced: 9 months ago
JSON representation
A tool for exploring and visualizing Julia code
- Host: GitHub
- URL: https://github.com/tkf/showcode.jl
- Owner: tkf
- License: mit
- Created: 2020-10-28T01:22:27.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-05-18T12:39:08.000Z (over 3 years ago)
- Last Synced: 2025-03-27T20:20:13.794Z (10 months ago)
- Language: Julia
- Homepage:
- Size: 52.7 KB
- Stars: 24
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ShowCode: Show code in various ways
## Overview
ShowCode.jl provides interfaces like `@code_llvm` and `@code_native`:
```julia
c = @sc_ircode f(args...)
c = @sc_llvm f(args...)
c = @sc_native f(args...)
c = @sc_intel f(args...)
```
## Julia SSA IR
```julia
c = @sc_ircode f(args...)
c # view IR in the REPL
display(c) # (ditto)
c.cfg # control-flow graph (CFG) visualizer
c.cfg_only # CFG without IR in node label
c.dom # dominator tree visualizer
c.dom_only # dominator tree without IR in node label
display(c.cfg) # display CFG
c.llvm # create LLVM IR explore
c.native # create native code explore
c.att # (ditto)
c.intel # create native code explore in intel syntax
edit(c.native)
abspath(c.native)
```
... and so on; type `c.` + TAB to see the full list.
## LLVM IR
```julia
c = @sc_llvm f(args...)
c # view IR in the REPL
display(c) # (ditto)
edit(c) # open the IR in editor
print(c) # print the IR
abspath(c) # file path to the text containing the IR
c.native # create native code explore
c.att # (ditto)
c.intel # create native code explore in intel syntax
eidt(c.native)
abspath(c.native)
c.cfg # control-flow graph (CFG) visualizer
display(c.cfg) # display CFG
edit(c.cfg.png) # open PNG file in your editor
edit(c.cfg.svg) # same for SVG
abspath(c.cfg.png) # file path to the PNG image
c.cfg_only
c.dom
```
... and so on. Type `c.` + TAB to see all the list. All `-dot-*`
options in
[`opt` command line interface](https://llvm.org/docs/Passes.html) are
supported.
## Native Code
```julia
c = @sc_native f(args...)
c = @sc_intel f(args...) # short hand for syntax=:intel
c # view code in the REPL
display(c) # (ditto)
edit(c) # open the code in editor
print(c) # print the code
abspath(c) # file path to the text containing the code
```
## Cthulhu integration
During Cthulhu's descent session, you can press b to
"bookmark" the method you are browsing. This is stored in the global
variable `Cthulhu.BOOKMARKS`. This can be converted to code explores
by:
```julia
c = sc_ircode(Cthulhu.BOOKMARKS[end])
c = sc_llvm(Cthulhu.BOOKMARKS[end])
c = sc_native(Cthulhu.BOOKMARKS[end])
```