Bril:用于教授编译器的中间语言

  • Bril creation and purpose: Created for a PhD-level compilers course to support implementation projects. It's not very interesting from a compiler engineering perspective but good for teaching. It's the only compiler IL designed specifically for education.
  • Bril features:

    • JSON-based: Programs are JSON documents. It allows students to use any programming language and has no required framework. Can be composed with Unix pipelines.
    • Instruction-based: An assembly-like, typed, ANF language. Prioritizes fast start, easy component mixing, simple semantics, and regular syntax over code size, compiler speed, and generated code performance.
  • Language design:

    • Good: print is a core opcode for easy examples. Extensible with loosey-goosey additions like new opcodes and data types.
    • Bad: Extremely ANF with constants in separate instructions. No systematic way to manage extensions.
    • Ugly: Does not require SSA initially but has caused headaches with undefinedness and correctness problems in the aftermarket SSA retrofit.
  • The Bril ecosystem: A lot of tools have been contributed by CS 6120 students since its creation. There are various language extensions and a sampling of tools in the monorepo. One customer built a web playground. Many more random tools can be found on GitHub.
阅读 6
0 条评论