[RFC] Adding BASIC09 frontend tool to LLVM

I would like feedback on whether a BASIC09 frontend/tool would be appropriate for LLVM, and if so, what shape the upstreaming path should take.

I have a working prototype branch here:

https://github.com/DrPitre/llvm-project/tree/basic09-compiler

Summary

The prototype adds a new LLVM tool, basic09c, under llvm/tools/basic09c.

basic09c currently implements:

  • BASIC09 lexing and parsing
  • AST construction and AST dumps
  • initial semantic checks
  • symbol handling
  • LLVM IR emission for a useful subset of the language
  • lit tests for lexer/parser/AST/semantic behavior
  • lit tests for emitted LLVM IR

The frontend is intentionally target-independent. It emits LLVM IR and does not depend on any MC6809 backend or OS-9 support.

Motivation

BASIC09 was a structured BASIC dialect used on OS-9/6809 and OS-9/68K systems, especially the Tandy Color Computer ecosystem. It has procedures, typed variables, arrays, control flow, and a compilation model that makes it a reasonable candidate for preservation through a modern compiler infrastructure.

My goal is to preserve and compile existing BASIC09 programs by lowering them to LLVM IR. Longer term, this could allow BASIC09 programs to target multiple backends, not just historical 6809 systems.

This work started in the context of MC6809/OS-9 experimentation, but I have separated the compiler frontend from that backend-specific work. The frontend should stand on its own.

It’s nice to hear you’re finding LLVM useful for building your compiler.

That said, a niche programming language from the 80’s is never going to meet our criteria for adding new languages to LLVM. See LLVM Developer Policy — LLVM 23.0.0git documentation for the formal policy.

1 Like

Thanks for responding. For niche projects such as this, what are most people doing? Just hosting them on a fork and then occasionally rebasing to keep up with mainline changes? Is there a place for this kind of work to live outside of our own forks?

Language frontends are typically implemented as independent projects that merely use LLVM as a library. It is not necessary to create an LLVM fork for this purpose. You only link against it.

If you’re using the C++ API, which is unstable, you likely want to support only a narrow range of LLVM versions (or even require a specific one). If you’re using the C API, which is semi-stable, supporting a wider range of LLVM versions becomes easier.

1 Like