Skip to content

Commit

Permalink
Add jump-buttons to get fro Stmt directly to Assembly (#7793)
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Johnson <srj@google.com>
  • Loading branch information
mcourteaux and steven-johnson authored Aug 28, 2023
1 parent 69c75b3 commit 8ac1e1c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/StmtToViz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,9 @@ class HTMLCodePrinter : public IRVisitor {
cost_model = std::move(cm);
}

void print(const Module &m) {
void print(const Module &m, AssemblyInfo asm_info) {
assembly_info = std::move(asm_info);

// Generate a unique ID for this module
int id = gen_unique_id();

Expand Down Expand Up @@ -708,6 +710,7 @@ class HTMLCodePrinter : public IRVisitor {

// Holds cost information for visualized program
IRCostModel cost_model;
AssemblyInfo assembly_info;

/* Private print functions to handle various IR types */
void print(const Buffer<> &buf) {
Expand Down Expand Up @@ -928,6 +931,16 @@ class HTMLCodePrinter : public IRVisitor {
<< "</button>";
}

// Prints a button to sync text with visualization
void print_assembly_button(const void *op) {
int asm_lno = assembly_info.get_asm_lno((uint64_t)op);
if (asm_lno != -1) {
stream << "<button class='icon-btn text-info sync-btn' onclick='scrollToAsm(\"" << asm_lno << "\")'>"
<< " <i class='bi bi-arrow-right-square' title='Jump to Assembly'></i>"
<< "</button>";
}
}

// CUDA kernels are embedded into modules as PTX assembly. This
// routine pretty - prints that assembly format.
void print_cuda_gpu_source_kernels(const std::string &str) {
Expand Down Expand Up @@ -1521,6 +1534,7 @@ class HTMLCodePrinter : public IRVisitor {

// Add a button to jump to this producer/consumer in the viz
print_visualization_button("prodcons-viz-" + std::to_string(id));
print_assembly_button(op);

// Open code block to hold function body
print_html_element("span", "matched", "{");
Expand Down Expand Up @@ -1583,6 +1597,7 @@ class HTMLCodePrinter : public IRVisitor {

// Add a button to jump to this loop in the viz
print_visualization_button("loop-viz-" + std::to_string(id));
print_assembly_button(op);

// Open code block to hold function body
print_html_element("span", "matched", "{");
Expand Down Expand Up @@ -2885,7 +2900,7 @@ class IRVisualizer {
// Generate tab 1/3: Lowered IR code with syntax highlighting in HTML
void generate_ir_tab(const Module &m) {
stream << "<div id='ir-code-tab'>\n";
html_code_printer.print(m);
html_code_printer.print(m, asm_info);
stream << "</div>\n";
}

Expand Down

0 comments on commit 8ac1e1c

Please sign in to comment.