Conversation
This was referenced Sep 28, 2026
alex
force-pushed
the
claude/cool-hamilton-crn96s-ci
branch
from
September 28, 2026 22:10
311d0db to
9995ffe
Compare
alex
force-pushed
the
claude/cool-hamilton-crn96s-tcb
branch
from
September 28, 2026 22:10
ec8a97f to
02073e3
Compare
This was referenced Sep 28, 2026
alex
force-pushed
the
claude/cool-hamilton-crn96s-ci
branch
from
September 29, 2026 23:02
9995ffe to
c25f58f
Compare
alex
force-pushed
the
claude/cool-hamilton-crn96s-tcb
branch
from
September 29, 2026 23:02
02073e3 to
6625c2d
Compare
alex
force-pushed
the
claude/cool-hamilton-crn96s-ci
branch
from
October 1, 2026 02:20
c25f58f to
7e23749
Compare
alex
force-pushed
the
claude/cool-hamilton-crn96s-tcb
branch
2 times, most recently
from
October 1, 2026 13:14
649e7eb to
5197baf
Compare
A model of the subset of the Power ISA (3.1C, Book I) that the implementations will need, in little-endian mode: 64-bit add/subf, addi, li/lis/ori/oris, and/or/xor, the word and doubleword rotates and shifts (rlwinm/rldicl/rldicr), lbz/lwz/ld and stb/stw/std, the byte-reversed lwbrx/ldbrx/stwbrx/stdbrx, mflr/mtlr, bl/blr, and conditions that compare a word or doubleword with zero (cmplwi/cmpldi then beq/bne on cr0). Frames are ELFv2-conformant: the push is stdu r1,-48(r1) (the back chain) then std RS,32(r1), and the pop ld RT,32(r1) then addi r1,r1,48. A call leaves unknown values in LR and in r0, r11 and r12, which ELFv2 lets linkage code change. The target is the ELFv2 C ABI: arguments in r3-r10, r2 and r14-r31 nonvolatile, r13 (the thread pointer) never an operand. Every modelled instruction is in Power ISA 2.07 (POWER8), the baseline of powerpc64le-unknown-linux-gnu, so `requires` is empty. Printer.branch now returns lines, since a PowerPC branch on a register is a comparison and a branch. Golden tests cover every instruction's printing and semantics (checked against qemu-ppc64le), the frames and the ABI. Refs #55 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fw6RULWHCeVgMDGc3wRrwE
alex
force-pushed
the
claude/cool-hamilton-crn96s-tcb
branch
from
October 1, 2026 14:21
5197baf to
9c74d3f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #55. Stacked on #97 (CI); the base will move to
mainonce that lands. This PR is entirely a trust change: it addsTCB/PPC64LE/and changes the shared printer interface. No implementation, spec or generated file changes; those follow in their own PRs (ChaCha20, SHA-256, HMAC-SHA-256), stacked on this one.Trust changes
TCB/PPC64LE/Isa.lean(new): the ISA modelA model of the subset of the Power ISA, Version 3.1C, Book I that the implementations need, in little-endian mode. Each instruction cites the section whose RTL it transcribes:
add,subf(assub),addi/subi,li/lis(addi/addiswithRA = 0),ori,oris,and/or/xor(§3.3.9, §3.3.13): all on the full 64 bits.rlwinm(asrotrwi/srwi; reads the low word and zero-extends its 32-bit result),rldicl(rotrdi/srdi),rldicr(sldi) (§3.3.14).lbz/lwz/ld,stb/stw/std(§3.3.2, §3.3.3), and the byte-reversedlwbrx/ldbrx/stwbrx/stdbrx(§3.3.5). In LE modeMEM(EA, n)is a little-endian read (§1.3.2), so the byte-reversed forms are big-endian accesses. Accesses must lie in the state's permitted regions, or the instruction faults.mflr/mtlr(§3.3.19),bl/blr(§2.4).cmplwi/cmpldiagainst 0 into CR0, thenbeq/bne(§3.3.10, §2.4). CR0 is volatile (ELFv2 §2.2.2.1) and nothing else reads it.Modelling choices (all in the module doc):
r0,r2–r12,r14–r31.r13(thread pointer, reserved by ELFv2 §2.2.2.1) is not aReg, so no code can name it;r1is only moved by frame push/pop.(RA|0)fault withRA = r0(exceptli/lis), and unencodable immediates/displacements fault, so verified code is always encodable.LRand inr0,r11,r12, which ELFv2 lets linkage code change (§2.2.2.1, "Optional Function Linkage"). The printer never emits anopafterbl, so the linker never inserts a TOC-saving stub (§2.2.1).stdu r1,-48(r1)(back chain) thenstd RS,32(r1); popped byld RT,32(r1)thenaddi r1,r1,48.divd) is modelled.requiresis empty: every modelled instruction is in Power ISA 2.07 (POWER8), the baseline ofpowerpc64le-unknown-linux-gnu.TCB/PPC64LE/Target.lean(new): the ELFv2 target64-bit ELF V2 ABI (OpenPOWER, rev. 1.5): arguments in
r3–r10(§2.2.4), result inr3(§2.2.6),preserved=r2andr14–r31(§2.2.2.1;r2must be restored since a naked function hasst_otherentry-point bits 0, §3.4.1), andabiPreservedalso demandsspandLRunchanged (the printer returns withblr).rustCfgisall(target_arch = "powerpc64", target_endian = "little"),rustAbiis"C".TCB/PPC64LE/Print.lean(new): the printerStraightforward mnemonics (
%rNregisters,rotrwi/rotrdi/srwi/srdi/sldias the baserlwinm/rldicl/rldicrforms), returnblr, callbl.TCB/Print.lean(and every target's printer):Printer.branchreturns linesA PowerPC conditional branch on a register is two instructions (a compare, then the branch), so
branch : M.Cond → String → List String; the existing printers wrap their one line in a list. Their output is unchanged (the existing golden tests andEmit.lean --checkconfirm it).Tests (
VerifiedGarbageTest/)PPC64LE.lean: the semantics of every instruction on concrete values, each cross-checked against the same instruction run underqemu-ppc64le.Print.lean: the printing of every instruction, branch, call, return and frame.Frames.lean,Abi.lean: frame push/pop and the ELFv2 argument/stack conventions.Checks
lake build(all proofs and golden tests),lake env lean --run Emit.lean --check,ci/check_lean_imports.py,ci/check_lean_speed.py,ci/check_vectors.py,cargo fmt --check, andcargo clippy/cargo teston x86-64 and (cross-built, under qemu) ppc64le all pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01Fw6RULWHCeVgMDGc3wRrwE
Generated by Claude Code