Skip to main content

rucc_base/
lib.rs

1//! Arenas, interning, index newtypes and the small data structures the rest of the
2//! compiler is built out of.
3//!
4//! Design: `spec/03-architecture.md`. Layer rank 0, see `spec/18-package-layout.md`.
5//!
6//! Nothing in here knows anything about C. That is deliberate: this is the one crate every
7//! other crate depends on, so anything C-specific that leaks in here becomes impossible to
8//! avoid later.
9//!
10//! [`rules`] is here for the same reason, one level up. It is the walk over the automaton a
11//! rule file compiles into, and both `rucc-opt` rewriting IR to IR and `rucc-codegen` lowering
12//! IR to machine terms match with it. A rewrite and a lowering are the same claim about two
13//! terms, so writing the walk twice would be writing two chances to disagree.
14//!
15//! [`float`] is here for the same reason. Binary floating point is not a C question, and both
16//! ends of the compiler need the same answer to it: the lexer converting a constant and the
17//! optimizer folding one have to agree to the last bit, and neither may ask the host what a
18//! number means, because the same source has to give the same bits whoever compiles it.
19//!
20//! # Status
21//!
22//! The index newtypes, the interner and the software float are real and used. The arena is a
23//! thin wrapper for now and grows with `M2`. The rule matcher is real and used by the x86-64
24//! selector, and gains its second caller with the rewrite rules of `M4.2`. The float has both
25//! halves of what a constant needs: conversion from text, and the arithmetic the constant
26//! evaluator folds with, each of them correctly rounded and neither of them asking the host
27//! anything.
28//!
29//! This crate is tier 3 in `spec/18-package-layout.md` section 18.5: its Rust API is
30//! explicitly unstable and will change without a major version bump.
31
32#![doc(html_root_url = "https://docs.rs/rucc-base/0.6.3")]
33
34mod decimal;
35pub mod float;
36pub mod index;
37pub mod intern;
38pub mod rules;
39mod scope;
40
41pub use index::{Idx, IdxRange};
42pub use intern::{Interner, Symbol, sym};
43pub use scope::ScopeMap;