titzer / virgil

A fast and lightweight native programming language
1.22k stars 42 forks source link

Built in interpretor #67

Closed wenq1 closed 2 years ago

wenq1 commented 2 years ago

What IR does the built-in interpreter interpret? Is is wasm? It seems that this basic question is left untouched in the documentation which I have dug through multiple times.

titzer commented 2 years ago

It's an internal format similar to bytecode, but every instruction is represented as an object.

Internally It's called "IC" (for interpreter code) and is here: https://github.com/titzer/virgil/tree/master/aeneas/src/ic

The Virgil compiler only generates IC code from SSA, which it can do before or after the reachability/specialization phase. The translation from SSA to IC is here: https://github.com/titzer/virgil/blob/master/aeneas/src/ssa/SsaIcGen.v3

wenq1 commented 2 years ago

thanks for the clarification