Skip to content

A tool for exploring and visualizing Julia code

License

Notifications You must be signed in to change notification settings

vchuravy/ShowCode.jl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ShowCode: Show code in various ways

Overview

ShowCode.jl provides interfaces like @code_llvm and @code_native:

c = @sc_ircode f(args...)
c = @sc_llvm f(args...)
c = @sc_native f(args...)
c = @sc_intel f(args...)

Julia SSA IR

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

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 are supported.

Native Code

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:

c = sc_ircode(Cthulhu.BOOKMARKS[end])
c = sc_llvm(Cthulhu.BOOKMARKS[end])
c = sc_native(Cthulhu.BOOKMARKS[end])

About

A tool for exploring and visualizing Julia code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Julia 100.0%