Commit Graph

4 Commits

Author SHA1 Message Date
f836f279de Feat: add -S flag to emit LLVM IR
`-S` stops the pipeline after IR emission and writes the `.ll` file
directly to the output path (default `<stem>.ll`). It implies `-c`
(no main required). Combined with `-o`, the IR goes to the specified
path.

Pipeline summary:
  (none)  →  emit → opt → llc → cc  →  executable
  -c      →  emit → opt → llc       →  <stem>.o
  -S      →  emit                   →  <stem>.ll

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-11 20:28:24 +01:00
c2fc83b74b Feat: add LLVM IR backend with opt/llc pipeline
Implements a full LLVM IR text emitter and three-step toolchain:
  1. Emit LLVM IR (.ll) via alloca-based codegen (mem2reg-friendly)
  2. `opt -O2` → optimised IR          (override with FLUXC_OPT)
  3. `llc -filetype=obj` → object file  (override with FLUXC_LLC)
  4. `cc` → link into executable        (override with FLUXC_CC)
     (step 4 skipped in -c mode)

Emitter supports all Flux types, operators, control flow (if/else,
while, loop, break, continue), structs, arrays, pointer operations,
function calls, string literals, and integer literal type inference
via UnboundInt → concrete-type coercion.

Also adds -o <file> CLI flag, exposes CheckResult from the checker
(sigma + phi tables reused by codegen), and updates main.rs to run
the full parse → check → codegen pipeline.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-11 20:21:34 +01:00
9aa6b9694b Feat: add -c flag to skip entry-point check
`fluxc -c <file>` compiles a source file without requiring a `main`
function, matching the convention of C compilers. Pass 4 (entry-point
validation) is skipped when `no_main` is set.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-11 15:36:43 +01:00
415dea6fd2 Feat: improve CLI with help menu and multi-file support
Extracts all argument-parsing and help logic into cli.rs:
- -h / --help: colored usage and options summary
- -V / --version: print version from Cargo.toml
- Unknown flags produce a styled error with a hint
- At least one file required; missing-file error is styled
- Multiple files accepted; exit code 1 if any file has parse errors
2026-03-10 18:49:15 +01:00