Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
320d252
docs: define frontend machine-boundary cleanup plan
dslsdzc Oct 23, 2026
28373e0
refactor: move x86 backend arrays out of shared frontend files
dslsdzc Oct 23, 2026
eeead25
refactor: move backend entry files out of compiler directory
dslsdzc Oct 23, 2026
ebcfd2e
refactor: split HDFG construction from CCR lowering
dslsdzc Oct 23, 2026
6922d06
refactor: route frontend extents and offsets through mapping
dslsdzc Oct 23, 2026
c3d6410
refactor: move frontend environment and builtin lookup into prelude
dslsdzc Oct 23, 2026
a6e4eac
refactor: move CCR record layouts and backend keys to schema modules
dslsdzc Oct 23, 2026
4bb9d0b
refactor: move literal conversion out of the lexer and name the gorou…
dslsdzc Oct 23, 2026
f93dff5
refactor: move the backend stack map out of shared globals
dslsdzc Oct 23, 2026
662abdb
docs: align the frontend boundary plan with the implemented steps
dslsdzc Oct 23, 2026
edff555
docs: define arbitrary-precision int design
dslsdzc Oct 23, 2026
fb14a40
docs: plan arbitrary-precision int implementation
dslsdzc Oct 23, 2026
bb79706
docs: use a pure Core 30-bit bigint runtime
dslsdzc Oct 23, 2026
69bef69
runtime: add pure Core 30-bit arbitrary precision integers
dslsdzc Oct 23, 2026
13c76c3
docs: target CCR v9.1 for bigint format changes
dslsdzc Oct 23, 2026
74de04c
bootstrap: accept arbitrary precision integer literals
dslsdzc Oct 23, 2026
1d28bf4
bootstrap: add tagged bigint backend pipeline
dslsdzc Oct 23, 2026
091e5e2
bootstrap: fix inline str_len and alloc fallthrough
dslsdzc Oct 23, 2026
d1d41e4
bootstrap: complete tagged bigint codegen for user programs
dslsdzc Oct 23, 2026
eeff5c8
frontend: preserve arbitrary precision integer literals
dslsdzc Oct 23, 2026
9bbf21c
backend: add tagged BigInt arithmetic under --big-int
dslsdzc Oct 23, 2026
968eb7f
backend: carry tagged ints through containers and calls
dslsdzc Oct 23, 2026
9195b64
backend: enforce raw-word boundaries for BigInt
dslsdzc Oct 23, 2026
e506f8f
interpreter: execute tagged BigInt values
dslsdzc Oct 23, 2026
3ffcfae
compiler: import BigInt runtime for the interpreter
dslsdzc Oct 23, 2026
91174a6
docs: record the raw-compiler blocker for the default BigInt switch
dslsdzc Oct 23, 2026
809aba3
bigint: switch user programs to tagged ints by default
dslsdzc Oct 23, 2026
6ae8d93
bigint: remove legacy 2-limb backend path
dslsdzc Oct 23, 2026
cf2a4f3
docs: add pattern-matching IR design
dslsdzc Oct 23, 2026
a50e99a
cli: group hidden debug flags in help output
dslsdzc Oct 23, 2026
32a6e00
frontend: remove machine-specific leakage
dslsdzc Oct 23, 2026
6776e62
target: split the combination root into three components
dslsdzc Oct 23, 2026
756ca67
dex: preserve optional payload declarations
dslsdzc Oct 23, 2026
a580a42
docs: specify target-neutral lattice ccr v10
dslsdzc Oct 23, 2026
0095bfd
docs: describe ccr fields as wire roles
dslsdzc Oct 23, 2026
9d4b856
docs: make ccr v10 streaming-friendly
dslsdzc Oct 23, 2026
d509010
docs: use mermaid flowcharts in ccr v10 spec
dslsdzc Oct 23, 2026
52c5c1d
runtime: replace public w64/r64 with cell accessors
dslsdzc Oct 23, 2026
c12b656
docs: add ccr v10 migration implementation plan
dslsdzc Oct 23, 2026
4f90029
docs: clarify ccr v10 task 3 keeps v9 ent bytes
dslsdzc Oct 23, 2026
281d536
test: add ccr v10 wire oracle and negative fixtures
dslsdzc Oct 23, 2026
507c093
ccr: add v10 wire schema constants
dslsdzc Oct 23, 2026
1ce412d
docs: align ccr v10 task 3 with v9 wire freeze
dslsdzc Oct 23, 2026
7608aa5
ccr: derive semantic type ids for v10 nod
dslsdzc Oct 23, 2026
87a9379
ccr: cut over to v10 lattice container and reject v9
dslsdzc Oct 23, 2026
e54c110
ccr: fix v10 header flags and reject legacy target facts
dslsdzc Oct 23, 2026
6d9197e
ccr: move layout out of frontend into target projection
dslsdzc Oct 23, 2026
079a111
ccr: finish removing frontend layout from interp and allocation stride
dslsdzc Oct 23, 2026
231bb64
ccr: keep runtime pointer bound for unknown provenance span
dslsdzc Oct 23, 2026
f9820ae
ccr: make v10 loader consume canonical segment order
dslsdzc Oct 23, 2026
1b8fd15
ccr: harden streaming loader test evidence
dslsdzc Oct 23, 2026
f77d195
docs: scope ccrb distribution to external packer
dslsdzc Oct 23, 2026
bf74dcd
dist: add ccrb bundle with optional coi sidecar
dslsdzc Oct 23, 2026
1c9edba
docs: scope ccr v10 cleanup and keep raw ABI explicit
dslsdzc Oct 23, 2026
057ffba
refactor: remove v9 ccr and residual raw frontend surface
dslsdzc Oct 23, 2026
9400ee5
fix: classify raw ABI calls as SYSTEM at graph level
dslsdzc Oct 23, 2026
86b142d
fix: harden ccr v10 trust boundaries and existence lattice
dslsdzc Oct 23, 2026
0cdf35c
test: give ccr v10 oracle fixtures a valid header flag
dslsdzc Oct 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
316 changes: 314 additions & 2 deletions bootstrap/corec/backend/x86_64_stack_asm.py

Large diffs are not rendered by default.

47 changes: 44 additions & 3 deletions bootstrap/corec/frontend/ir_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from corec.ir.symbol_table import SymbolTable, SymbolKind

class IRGen:
def __init__(self, symtab=None):
def __init__(self, symtab=None, bigint_mode: bool = False):
self.temp_counter = 0
self.bigint_mode = bigint_mode
self.mod = Module("main")
self.current_func = None
self.current_block = None
Expand Down Expand Up @@ -150,8 +151,27 @@ def gen_expr(self, expr):
# 2(a) 视图内建 = **直通**(零代码生成):`@ptr_of(s)` / `@str_of(p)` 不改变那个 64 位字,
# 只改变它在本语言里的看法 ⇒ 直接返回内层表达式的值本身(不发射指令、不建临时变量)。
# 未知名到此不该出现(type_checker 已 fail-closed;此面兜底为 0 以免静默崩溃)。
if expr.name in ('raw_add', 'raw_sub', 'raw_and'):
args = []
for arg in expr.args:
if isinstance(arg, Literal) and arg.kind == 'int':
v = self.new_temp()
self.add_instr(ConstInstr(int(arg.value), 'raw_int', v))
args.append(v)
else:
args.append(self.gen_expr(arg))
dest = self.new_temp()
self.add_instr(BinaryInstr(expr.name, args[0], args[1], dest))
return dest
if expr.name in ('ptr_of', 'str_of') and expr.args:
return self.gen_expr(expr.args[0])
v = self.gen_expr(expr.args[0])
if self.bigint_mode:
dest = self.new_temp()
dest.type = BaseType('int') if expr.name == 'ptr_of' else BaseType('string')
op = 'tag_word' if expr.name == 'ptr_of' else 'untag_word'
self.add_instr(BinaryInstr(op, v, v, dest))
return dest
return v
v = self.new_temp()
self.add_instr(ConstInstr(0, 'int', v))
return v
Expand Down Expand Up @@ -186,6 +206,7 @@ def gen_literal(self, lit):
if lit.kind == 'int': val = int(val)
elif lit.kind == 'dex': val = Dex(int(val)) # 定点缩放整数(精确语义,Task 4)
v = self.new_temp()
v.type = BaseType(lit.kind)
self.add_instr(ConstInstr(val, lit.kind, v))
return v

Expand Down Expand Up @@ -244,6 +265,10 @@ def gen_binary(self, binop):
right_is_str = isinstance(right.type, BaseType) and right.type.name == 'string'
if left_is_str or right_is_str:
dest.type = BaseType('string')
if dest.type is None:
if (isinstance(left.type, BaseType) and left.type.name == 'int' and
isinstance(right.type, BaseType) and right.type.name == 'int'):
dest.type = BaseType('int')
self.add_instr(BinaryInstr(binop.op, left, right, dest))
return dest

Expand All @@ -265,9 +290,17 @@ def gen_unary(self, unop):
return dest
op = self.gen_expr(unop.operand)
dest = self.new_temp()
if isinstance(op.type, BaseType):
dest.type = op.type
self.add_instr(UnaryInstr(unop.op, op, dest))
return dest

def _call_result_type(self, name):
sym = self.symtab.lookup(name)
if sym and sym.type:
return sym.type
return None

def gen_call(self, call):
if isinstance(call.func, FieldAccess):
module_fn = None
Expand All @@ -276,6 +309,7 @@ def gen_call(self, call):
if module_fn is not None:
args = [self.gen_expr(a) for a in call.args]
dest = self.new_temp()
dest.type = module_fn.return_type
self.add_instr(CallInstr(module_fn.name, args, dest))
return dest
obj_expr = call.func.object
Expand Down Expand Up @@ -304,12 +338,14 @@ def gen_call(self, call):
obj = self.gen_expr(obj_expr)
args = [obj] + [self.gen_expr(a) for a in call.args]
dest = self.new_temp()
dest.type = self._call_result_type(full)
self.add_instr(CallInstr(full, args, dest))
return dest
else:
func_name = self._get_func_name(call.func)
args = [self.gen_expr(a) for a in call.args]
dest = self.new_temp()
dest.type = self._call_result_type(func_name)
self.add_instr(CallInstr(func_name, args, dest))
return dest

Expand Down Expand Up @@ -686,7 +722,12 @@ def gen_let(self, let):
if typ is None:
typ = BaseType('int')
else:
typ = BaseType('unit')
if val_ir is not None and isinstance(val_ir.type, BaseType):
typ = val_ir.type
else:
typ = BaseType('unit')
if typ is None and val_ir is not None and isinstance(val_ir.type, BaseType):
typ = val_ir.type
if typ is None:
typ = BaseType('unit')
var_ir = IRVar(name, VarKind.LOCAL, typ)
Expand Down
2 changes: 0 additions & 2 deletions bootstrap/corec/frontend/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ def read_number(self, first: str) -> Token:
# 不一致处理——两编译器差异 = 各自投影形状差异,非语义分歧。
if is_prefixed:
val = int(n[2:], base)
if val > 9223372036854775807:
self.error("integer literal overflow")
return Token(TokenType.INT_LIT, str(val), start_line, start_col)
if is_float:
return Token(TokenType.FLOAT_LIT, n, start_line, start_col)
Expand Down
3 changes: 3 additions & 0 deletions bootstrap/corec/frontend/name_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def _declare_builtins(self):
('load8', BaseType('int')),
('store8', BaseType('int')),
('load64', BaseType('int')),
('r64', BaseType('int')),
('w64', BaseType('int')),
('str_len', BaseType('int')),
('syscall3', BaseType('int')),
('syscall4', BaseType('int')),
('fiber_init', BaseType('int')),
Expand Down
15 changes: 14 additions & 1 deletion bootstrap/corec/frontend/type_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ def _infer_builtin(self, expr) -> Type:
self.errors.append(f"@{expr.name} expects a {want} expression, got {at}")
return BaseType('never')
return result
if expr.name in ('raw_add', 'raw_sub', 'raw_and'):
if self.unsafe_depth == 0:
self.errors.append(f"@{expr.name} must appear inside an `unsafe` block")
return BaseType('never')
if len(expr.args) != 2:
self.errors.append(f"@{expr.name} expects exactly 2 arguments")
return BaseType('never')
for arg in expr.args:
at = self._infer_expr(arg)
if self._type_name(at) != 'int':
self.errors.append(f"@{expr.name} expects int arguments, got {at}")
return BaseType('never')
return BaseType('int')
self.errors.append(f"unknown @ builtin: {expr.name}")
return BaseType('never')

Expand Down Expand Up @@ -571,7 +584,7 @@ def _infer_expr(self, expr: Expr) -> Type:
def _infer_call(self, call: Call) -> Type:
# Handle runtime functions (defined in rt.s, no decl node)
rt_funcs = {'alloc', 'get_arg', 'syscall3', 'syscall4', 'fiber_init', 'fiber_switch',
'load8', 'store8',
'load8', 'store8', 'r64', 'w64', 'str_len',
'load_str_ptr', 'store_str_ptr',
'g_set_curg', 'g_get_curg', 'm_start_workers'}
if isinstance(call.func, Ident) and call.func.name in rt_funcs:
Expand Down
71 changes: 54 additions & 17 deletions build_selfhost_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
段内/段间**相对顺序 = 行为定义面**(平铺编译单元的声明序/全局序),分段只做
命名与按序组合,顺序与拆分前逐一对应,不可乱序。
架构轴 `arch_x86_64_files` × 格式轴 `format_elf_files` × OS 轴 `os_linux_files`
(波 1 落位:Task 1 三轴搬迁 + 组合根 / Task 3/4 frame·tag2l 入架构轴 /
(波 1 落位:Task 1 三轴搬迁 + 组合根 / Task 3/4 frame 入架构轴 /
Task 2/5/6 entry·callseq·syscall 入 OS 轴——**全轴已就位**)+ 组合根
`x86_linux_target_files`(target triple 命名:project-mode 入口链,不入
`x86_linux_elf_target_files`(target triple 命名:project-mode 入口链,不入
concat——见段注释)。
"""
import sys, os, subprocess, io, contextlib
Expand All @@ -35,11 +35,13 @@
common_files = [
'src/runtime/arena_globals.cr',
'src/runtime/rt.cr',
'src/kernel/bytes.cr',
'src/stdlib/io.cr',
'src/stdlib/fmt.cr',
'src/stdlib/cli.cr',
'src/stdlib/toml.cr',
'src/compiler/ast.cr',
'src/compiler/ccr_schema.cr',
'src/compiler/globals.cr',
'src/compiler/dyn_arr.cr',
]
Expand All @@ -57,15 +59,21 @@
]

# ① 架构轴 x86_64:寄存器分配 CAG + 指令编码 + 字节尺寸单源(sizes.cr)
# + int 多字 M1 tag/2L 编码族(tag2l.cr——波 1 Task 4 自 instr.cr 整搬)。
# 段内顺序 = 「被依赖者先」惯例(函数可见性与顺序无关):tag2l 消费 instr 的
# 编码原语 → instr 之后;frame.cr → tag2l(pf_epilogue 函数尾块调 e2_mw_*;
# tag2l 反向消费 frame 的 g2_tag_off——同轴双向引用,波 1 Task 4 裁定可接受)。
# + tagged BigInt 立即数/装箱辅助(int_rep.cr)与运行时 blob。
arch_x86_64_files = [
# Target layout helpers. corearch reconstructs NOD access widths and array
# strides from these instead of reading target facts back from .ccr. They
# depend only on common_files (ast/dyn_arr type rows), not on the frontend.
'src/compiler/mapping.cr',
'src/arch/x86_64/x86_mapping.cr',
'src/arch/x86_64/backend_schema.cr',
'src/arch/x86_64/backend_globals.cr',
'src/arch/x86_64/backend_arrays.cr',
'src/arch/x86_64/regalloc.cr',
'src/arch/x86_64/sizes.cr',
'src/arch/x86_64/int_rep.cr',
'src/runtime/bigint_blob.cr',
'src/arch/x86_64/instr.cr',
'src/arch/x86_64/tag2l.cr',
'src/arch/x86_64/frame.cr',
]

Expand Down Expand Up @@ -120,19 +128,19 @@
'src/stdlib/goroutine.cr',
'src/stdlib/chan.cr',
'src/stdlib/sched.cr',
'src/compiler/backend_flags.cr',
'src/compiler/corearch.cr',
'src/arch/x86_64/backend_flags.cr',
'src/arch/x86_64/corearch.cr',
]

# 组合根(x86_64-linux target triple):project-mode 入口链——`corec build
# src/targets/x86_64-linux` 的入口 = 该目录 main.cr(load_project 直读)+
# 组合根(x86_64/linux/elf target triple):project-mode 入口链——`corec build
# src/targets/x86_64/linux/elf` 的入口 = 该目录 main.cr(load_project 直读)+
# _import.cr(load_imports 直读)+ Core.toml(工程名)。**不入 concat**:
# main.cr 的 fn main 与 concat 追加的 wrapper 冲突,且其 .cr 经 project-mode
# 独立收编(stage0/stage 链即此入口)。仅纳入清单存在性守卫。
x86_linux_target_files = [
'src/targets/x86_64-linux/main.cr',
'src/targets/x86_64-linux/_import.cr',
'src/targets/x86_64-linux/Core.toml',
x86_linux_elf_target_files = [
'src/targets/x86_64/linux/elf/main.cr',
'src/targets/x86_64/linux/elf/_import.cr',
'src/targets/x86_64/linux/elf/Core.toml',
]


Expand Down Expand Up @@ -314,15 +322,28 @@ def main():
corec_files = [
'src/runtime/arena_globals.cr',
'src/runtime/rt.cr',
'src/kernel/bytes.cr',
'src/stdlib/io.cr',
'src/stdlib/fmt.cr',
'src/runtime/bigint.cr',
'src/stdlib/cli.cr',
'src/compiler/ast.cr',
'src/compiler/ccr_schema.cr',
'src/compiler/globals.cr',
'src/compiler/dyn_arr.cr',
'src/compiler/literal.cr',
'src/compiler/big_lit.cr',
'src/compiler/lexer.cr',
'src/compiler/parser.cr',
'src/compiler/checker.cr',
'src/compiler/mapping.cr',
'src/arch/x86_64/x86_mapping.cr',
'src/compiler/prelude.cr',
'src/arch/x86_64/x86_frontend_abi.cr',
'src/os/linux/linux_frontend_abi.cr',
'src/runtime/runtime_frontend_abi.cr',
'src/targets/x86_64/linux/elf/target_abi.cr',
'src/targets/x86_64/linux/elf/frontend_target.cr',
# R2 P0 类型项引擎(建层):类型项 DAG 表 + 构造去重 → 判定引擎(桩)→ 自测通道。
# 置于 checker 之后(计划 Step 9 指定位置);引擎尚无 checker 侧消费者,
# 本批为纯增量(checker/ir_gen/后端零改动 = 产物零变化)。
Expand Down Expand Up @@ -361,6 +382,7 @@ def main():
'src/compiler/monomorph.cr',
'src/compiler/pass.cr',
'src/compiler/dataflow.cr',
'src/compiler/ccr_lower.cr',
'src/compiler/ccr_io.cr',
'src/lattice/ent_kernel.cr',
'src/compiler/module.cr',
Expand All @@ -386,13 +408,13 @@ def main():

# corearch — backend: .ccr → binary/asm
# 段顺序 = 行为定义面:common → hit → kernel → 架构轴 → 格式轴 → OS 轴
# → 后端收尾(与拆分前清单逐一对应)。组合根 x86_linux_target_files 不入
# → 后端收尾(与拆分前清单逐一对应)。组合根 x86_linux_elf_target_files 不入
# concat(见段注释)——单独纳入存在性守卫。
corearch_files = (common_files + hit_engine_files + kernel_files +
arch_x86_64_files + format_elf_files + os_linux_files +
backend_support_files)
guard_manifest(corearch_files, 'corearch')
guard_manifest(x86_linux_target_files, 'x86_64-linux target')
guard_manifest(x86_linux_elf_target_files, 'x86_64/linux/elf target')
compile_and_assemble(
concat(corearch_files, wrapper_fn='corearch_main'),
label='corearch',
Expand All @@ -418,12 +440,27 @@ def main():
'src/stdlib/goroutine.cr',
'src/stdlib/chan.cr',
'src/stdlib/sched.cr',
'src/kernel/bytes.cr',
'src/compiler/ast.cr',
'src/compiler/ccr_schema.cr',
'src/compiler/globals.cr',
'src/compiler/dyn_arr.cr',
'src/compiler/literal.cr',
'src/compiler/big_lit.cr',
'src/compiler/lexer.cr',
'src/compiler/parser.cr',
'src/compiler/checker.cr',
# The shared target descriptor (targets/.../frontend_target.cr) answers
# @sizeOf/@alignOf/@field through the target mapping, so the LSP links
# the same target-neutral interface + x86 implementation as corec.
'src/compiler/mapping.cr',
'src/arch/x86_64/x86_mapping.cr',
'src/compiler/prelude.cr',
'src/arch/x86_64/x86_frontend_abi.cr',
'src/os/linux/linux_frontend_abi.cr',
'src/runtime/runtime_frontend_abi.cr',
'src/targets/x86_64/linux/elf/target_abi.cr',
'src/targets/x86_64/linux/elf/frontend_target.cr',
# R2 P1:checker 的判定入口引用桥接层(sh_term_of_ti;影子挂点已随 P5 T5 下线)→
# corelsp 也必须链接 引擎 + 桥接层(相对顺序与 corec 一致;corearch 无 checker 仍不含)。
'src/compiler/type_terms.cr',
Expand Down
2 changes: 1 addition & 1 deletion docs/maintainer/adr/adr-0017-concurrency-gmp.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

## 决策

- 采用与 Go runtime 同构的 GMP 简化模型:G = `goroutine`(`fiber`,16KB 栈,独立 arena),M = machine,P 不分离,合并到 M;没有 `GOMAXPROCS`,M 的数量等于 CPU 核数。
- 采用与 Go runtime 同构的 GMP 简化模型:G = `goroutine`(`fiber`,16KB 栈,独立 arena),M = machine,P 不分离,合并到 M;没有 `GOMAXPROCS`,M 的数量等于 CPU 核数。栈尺寸常量是 `src/stdlib/goroutine.cr` 的 `G_STACK_SIZE`。
- G 状态机(`_Gidle`/`_Grunnable`/`_Grunning`/`_Gwaiting`/`_Gdead`);本地 run queue 加全局队列偷取;切换是用户态 `fiber_switch`(协作式)。
- channel 通信(环形缓冲 + `send_wait`/`recv_wait` 队列,值拷贝语义);go 返回 `result_ch`。

Expand Down
6 changes: 6 additions & 0 deletions docs/maintainer/design/coi-optimization-knowledge-sidecar.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

设计状态:定稿,尚未实现。`g_opt_meta` 的现状核对、格式展开、检查细节和待定事项见实现记录 `docs/superpowers/implementation/2026-09-23-coi-revision-audit.md`。

## 分发边界:`.ccrb`

`.ccrb` 是外部分发包装,不是新的程序格式。它由一个 zstd 帧包裹确定性 tar,固定包含 `manifest` 和 `program.ccr`,可选携带 `coi/<target>.coi`。打包和解包由 `tools/ccrb.py` 完成;`corearch` 只读取解包后的 raw `.ccr`,不实现 zstd,也不读取 `.ccrb`。

在这个包装层里,`.coi` 只是可选、不透明、可删除的旁挂 payload。本文件不定义 `.coi` 记录的内容;完整 `.coi` 语义仍属于独立计划 `docs/superpowers/plans/2026-09-23-coi-implementation.md`。删除 `.coi` 条目不改变 `program.ccr` 的字节。

## 核心规则

删除全部 `.coi` 文件,程序仍然正确、仍然可读。删除只允许增加编译成本或降低优化质量。
Expand Down
8 changes: 4 additions & 4 deletions docs/maintainer/design/regalloc-cache-mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

寄存器分配是缓存语义在编码层的一个映射实例。缓存语义的规则以 `docs/academic/cache-semantics.md` 为准;层定义见 `docs/maintainer/design/materialization-space.md`;存在区间的表示见 `docs/maintainer/design/existence-structure.md`。

设计决策记录见 `docs/superpowers/specs/2026-08-27-regalloc-cache-mapping-design.md`。分配器的逻辑契约见 `src/compiler/regalloc-consistency.cr` 的 v6 分支。
设计决策记录见 `docs/superpowers/specs/2026-08-27-regalloc-cache-mapping-design.md`。分配器的逻辑契约见 `docs/maintainer/design/regalloc-consistency.md` 的 v6 分支。

## 术语

Expand Down Expand Up @@ -91,7 +91,7 @@ recipe 无法判定 => 不可移除(失败关闭)
判定有两个应用位置:

1. 规约契约:`.cr` 内联规约,走 `spec-design` 体系的翻译桥和 CIC 内核,健全性由内核保证。旧格式已经废弃,见 `adr/adr-0001`。
2. 编译器自检:分配器的逻辑契约在 `src/compiler/regalloc-consistency.cr` 的 v6 分支,运行自检在 `opt.cr` 一侧。
2. 编译器自检:分配器的逻辑契约在 `docs/maintainer/design/regalloc-consistency.md` 的 v6 分支,运行自检在 `opt.cr` 一侧。

## 分配器:上下文贪心

Expand Down Expand Up @@ -132,7 +132,7 @@ recipe 无法判定 => 不可移除(失败关闭)
| 分支 | `alloc_registers` 现状 | 契约和自检 |
|---|---|---|
| develop(基线) | 朴素线性扫描:first/last 区间,5 个 callee-saved 寄存器,没有溢写;负编码寄存器,由 g2_slot 机械翻译 | 无 |
| lattice-ir-v6(推进中) | CAG 重写,修复 rc=0 的根因,加入真实寄存器分配和 watchdog 验证 | `regalloc-consistency.cr` 记录机制、`opt.cr` 映射和三层正确性定位;verify 运行自检 |
| lattice-ir-v6(推进中) | CAG 重写,修复 rc=0 的根因,加入真实寄存器分配和 watchdog 验证 | `docs/maintainer/design/regalloc-consistency.md` 记录机制、`opt.cr` 映射和三层正确性定位;verify 运行自检 |

设计与代码的对应:

Expand All @@ -159,4 +159,4 @@ recipe 无法判定 => 不可移除(失败关闭)
- RegionCheck 和存在区间实现:`docs/maintainer/design/pointer-model.md`
- 规约体系:`docs/maintainer/design/spec-design.md`
- 执行标注空间:`docs/maintainer/design/execution-annotation-space.md`
- 契约文档:`src/compiler/regalloc-consistency.cr` 的 v6 分支
- 契约文档:`docs/maintainer/design/regalloc-consistency.md` 的 v6 分支
Loading
Loading