summaryrefslogtreecommitdiff
path: root/chapter23/README.md
Commit message (Collapse)AuthorAgeFilesLines
* Popular use grouping for RegAllocCliff Click2026-09-201-19/+79
| | | | Fix arm BL encodings; ADD/SUB with reversed sign.
* Chapter 25: add separate compilation and simplify SSA constructionCliff Click2026-08-101-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce Chapter 25 with separately compiled Simple modules, serialized IR, cross-compilation-unit linking, and native system-library integration. This also completes a broad parser and type-system cleanup needed to make graph construction independent of incomplete parse-time type information. Separate compilation and linking - Add compilation-unit Start/Stop nodes and track functions, classes, aliases, and global indices across compilation-unit boundaries. - Serialize canonical types and ideal graph nodes into ELF objects, including dependency metadata, relocations, global/local bitset remapping, and dense memory-alias information. - Load dependent objects on demand, recursively resolve source and object paths, relink calls and function pointers, and preserve external C symbols. - Distinguish the post-optimization ownership hook from unknown callers so private call graphs can remain precise while public functions remain externally callable. - Add command-line and build support for compiling modules and the reusable `sys` object library. Parser, constructors, and SSA - Replace inline constructor expansion with a hidden default `<init>` followed by an explicit user constructor declared as `new Type = { ... }`. - Keep the default constructor private, pass private object memory through constructor calls, and require user constructors to initialize non-default fields before the object escapes. - Track possibly-uninitialized fields in parser `Var` state and diagnose early reads without encoding parser-only constraints in Load and Store nodes. - Make ordinary parser memory bulk and recover precise alias slices in the optimizer using `MemMerge`, `MemPhi`, and `BulkMemPhi` nodes. - Remove parser-supplied type constraints from Loads and ordinary Phis, defer integer/float arithmetic selection, and keep call shape driven by syntax instead of provisional inferred types. - Preserve chained field declarations as static parser information when flow types are not yet available, including postfix field updates through calls. Types, functions, and escape analysis - Add `TypeScalar` as the common lattice family for integer, float, memory pointer, and function-pointer values, with scalar TOP/BOT values for generic Loads, Stores, parameters, and invalid intermediate expressions. - Represent unresolved struct definitions directly with the `TypeStruct` forward-reference flag while retaining the separate open-structure concept; close and canonicalize recursive structures without side maps. - Add explicit `FunPtrNode` references so constant function pointers retain a graph edge to their Return, and keep referenced functions alive until Opto proves the pointer dead. - Refine public-function and class-initializer escape handling, including public-only fallback escape sets and monotone compilation-unit summaries. - Add guards, proof casts, read-only propagation, pointer-to-integer conversion for non-null FFI arguments, and consistent deep mutability checks at calls. Optimization and code generation - Make weak and unresolved graph inputs compute conservatively and monotonically throughout iterative peepholes and SCCP. - Preserve independent memory slices when sharpening Stores, retain control on conditional Stores, and freeze Store widths from their target field types. - Extend serialization for new node kinds, scalar types, Store modes, function pointers, and memory partitions, preserving serialize/deserialize bijection. - Complete native selection and encoding support across x86-64, RISC-V, and ARM, including FFI pointer conversion and missing integer operations. - Fix x86 immediate multiply REX encoding and assorted scheduling, register allocation, spilling, relocation, and constant-pool issues exposed by the larger linked graphs. System library, tests, and documentation - Compile and link the Simple `sys` library, including libc bindings, I/O, scanners, strings, vectors, array helpers, and executable entry points. - Add Chapter 25 module, serialization, constructor, forward-reference, postfix-update, system, Hello World, and Bubble Sort coverage; update golden graphs and spill expectations for the new IR shape. - Add module and type-system documentation, parser-simplification design notes, grammar updates, examples, diagrams, and graph visualization assets. The resulting compiler passes the raw Chapter 1-24 suite and the Chapter 25 system and separate-compilation tests, including a freshly rebuilt `sys.o` and the native Bubble Sort example.
* minor typoesCliff Click2026-01-251-1/+1
|
* More docsCliff Click2025-08-161-2/+2
|
* Squashed commit of the following:Cliff Click2025-06-131-308/+354
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 2c31fa61d71fcbcf160edef5aba874913e63859a Author: Cliff Click <cliffc@acm.org> Date: Sat Jun 7 16:34:11 2025 -0700 README, comments commit 8be23b15ad007509c9006a121328ce6615b912f6 Author: Cliff Click <cliffc@acm.org> Date: Sat Jun 7 10:16:20 2025 -0700 Cleanup on sys ADT BubbleSort looks cleaner Cleanup recursive type handling commit 145f977b53b3a9e89e984ae7af4bb3d8fd7768bb Author: Cliff Click <cliffc@acm.org> Date: Fri Jun 6 15:47:09 2025 -0700 More methods Removing a Phi keeps mintype lifting until consumers no longer expect it. Load, Store, MemMerge all "peek" through mem Cast and MemMerge. Bugfix, clone a constant near a required spill-use when passing constant stack arg. Bugfix, missing dep when upgrading a type allows inlining. Bugfix NegX86 is 2-adr Bugfix, x86 cmp imm vs mem cannot swap args. Bugfix, methods save/restore struct init values. Bugfix, method vars can be set. Repeat psudo-optimistic pass removing dead calls (tree shaking). Add basic lib calls for Vectors for i64 and u8. commit 04953c112a83de6127b6b2058a4bfbc344a3a02b Author: Cliff Click <cliffc@acm.org> Date: Tue Jun 3 15:58:03 2025 -0700 improve BubbleSort Bugfix uctrlSkipEmpty did not stop at Calls. Bugfix Phi skip mem alias uses 1 as default mem. Bugfix cyclic install uses uniform walking method to catch all cases. Drop % to mark static methods. Methods are static when not using the 'self' argument. Encoding records when it inserts function header padding, so the ASMPrinter gets offsets right. Encoding improve BB layout other things being equal. commit f42903ff30c533a78adfdc43407da29711a83ad9 Author: Cliff Click <cliffc@acm.org> Date: Mon Jun 2 09:31:09 2025 -0700 Methods Block scoping now carries more Kind info, including constructor Type; fold Kind and lexSize info together. Static calls need extra syntax `{% args ->body }` Mem Phis more precise minType. Mem Phi peeks through MemMerge. TypeMem BOT/TOP alias is now#1 to match the Parsers notion of "all mem". Missing dep. Eval2 constant array bugfix. commit aeb0a01e27e63ff6f8a2399523aa9f5922643d17 Author: Cliff Click <cliffc@acm.org> Date: Sat May 31 14:55:11 2025 -0700 READMEs commit dc1afb8d65a35e90b6495bd6dbaaf8d0d0149569 Author: Cliff Click <cliffc@acm.org> Date: Sat May 31 11:43:09 2025 -0700 Cyclic types! Handle cyclic types: thats that indirectly through a chain of types, point back to themselves. Make all type walkers cycle-aware. New cyclic-aware versions of hash and eq. In addition to hash-consing/interning types, also recycle allocated-but-interned types. Hash-consing has a 99.9% hit rate, so nearly all created types intern, and get recycles. This keeps the total count of types low (by 1000x) which keeps the type UID low, which keeps bit vectors for cyclic type walkers fast. Move TypeStruct._con field into the normal array body field "[]". Rename Field._type to Field._t to avoid shadowing prior _type field. commit fc6f6277e18fcf30f3770698572c307fc0913132 Author: Cliff Click <cliffc@acm.org> Date: Sun May 25 10:06:06 2025 -0700 Progress on cyclic types Types can reset between tests. Rename Phi _declaredType to _minType. Lifts to min type. Broken CFG can have null idom Field offsets by name only, can be delayed even more. Bug dying FunNode looks "inProgress" Move sys.smp to smp dir commit d4544c2740f8effb2edd08293ca19382d4f0aa01 Author: Cliff Click <cliffc@acm.org> Date: Sun May 25 09:57:51 2025 -0700 Move utils to a util directory commit 9462acc2e8b200b499fe4308e3f6a3a6a2d8ac0b Author: Cliff Click <cliffc@acm.org> Date: Wed May 14 14:50:13 2025 -0700 Hitting self-recursive types Changes for allowing locals to be non-const by default. Changes to track `_one` single-ton fields that will get moved to a class. Field offset constants; will become a real int constant once layout is determined, which waits until fields are decided to be in the class or instance; also if the field contents can be put in a smaller size. commit a1f3a27146fa40cb85aef90934250cf5b77be736 Author: Cliff Click <cliffc@acm.org> Date: Sun May 11 16:14:04 2025 -0700 Minor progress bug commit f21ccb089f7963b76cae553ff948b8cc056b0b82 Author: Cliff Click <cliffc@acm.org> Date: Sun May 11 15:28:35 2025 -0700 Ch 23 initial tests commit 89131d2ffa145e6cdbba95abed9abb7989e6822f Author: Cliff Click <cliffc@acm.org> Date: Sun May 11 15:19:02 2025 -0700 First commit ch23
* Clean up stacked mergememCliff Click2025-05-111-2/+8
|
* READMECliff Click2025-05-061-0/+406