Thorn Insights Platform

Inspired by Compiler Explorer, the Bramble compiler is built from the ground up to record every decision made during compilation. This is the Thorn insights platform: a system for building tools and analysis that provides maximum insight into what is happening with your code and why.
This insight data can then be used to review, audit, and analyze everything that the compiler has done.

Parser Insight

Through the Thorn event record, the AST for a program can be reconstructed and viewed as a tree. Helping compiler developers and users, alike, gain insight into how the syntax rules for Bramble work.

AST

Semantic Decisions

With languages that have complex type systems, type errors can become incomprehensible. By integrating insight infrastructure from the ground up, Bramble can use Thorn to record every piece of context leading to a type inference decision and show it in an easy to understand diagram.

Here, a user has selected the expression ^^pp and the Thorn is showing how Bramble resolves the type to an i64. Notice how Thorn highlights the declaration of pp as part of the context used in this resolution.

AST

LLVM Insight

Reflecting our inspiration from Compiler Explorer, Thorn will show how the compiler transforms your code into LLVM IR.

LLVM

Optimization Insight

A core goal of Bramble is to guide users towards writing optimized and efficient code. To do that, it must be easy for beginners and experts to understand how their code gets transformed and use that understanding to write code that leverages the strengths of the compiler and avoids its weaknesses. Thorn will make it trivial to understand how small changes in code can lead to changes in the efficiency of the compiler output.

Here Thorn diagrams how an arithmetic expression is optimized into a precomputed constant by LLVM.

LLVM

Thorn Compiler Event Record

Every decision that the compiler makes, along with all its context, gets recorded by Thorn to an event log.

Anyone can then build their own analysis tools on top of the Thorn platform.

[{"id": 269, "parent_id": 268, "stage": "type-resolver", "source": [165, 166], "ok": "i64"},
{"id": 271, "parent_id": 270, "stage": "type-resolver", "source": [170, 171], "ok": "i64"},
{"id": 270, "parent_id": 268, "stage": "type-resolver", "source": [169, 171], "ok": "i64"},
{"id": 268, "parent_id": 267, "stage": "type-resolver", "source": [164, 172], "ok": "i64"},
{"id": 272, "parent_id": 267, "stage": "type-resolver", "source": [175, 176], "ok": "i64", "ref": [68, 113]},
{"id": 281, "parent_id": 280, "stage": "llvm", "source": [61, 62], "ok": "i64 2"},
{"id": 280, "parent_id": 279, "stage": "llvm", "source": [47, 63], "ok": "  %b = alloca i64, align 8"},
{"id": 279, "parent_id": 278, "stage": "llvm", "source": [47, 63], "ok": "  store i64 2, i64* %b, align 4"},
{"id": 278, "parent_id": 273, "stage": "llvm", "source": [47, 63], "ok": "  %b = alloca i64, align 8"},
{"id": 287, "parent_id": 286, "stage": "llvm", "source": [83, 84], "ok": "  %a1 = load i64, i64* %a, align 4"},
{"id": 288, "parent_id": 286, "stage": "llvm", "source": [87, 88], "ok": "  %b2 = load i64, i64* %b, align 4"},
{"id": 286, "parent_id": 285, "stage": "llvm", "source": [82, 89], "ok": "  %0 = add i64 %a1, %b2"}]