协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
compiler-toolchain【开发与工程】Compiler toolchain development for custom processor ISAs — LLVM/GCC backend, assembler, linker scripts, runtime libraries, and regression validation. Use when building a compiler for a custom RISC-V extension, proprietary ISA, or any processor where no existing toolchain targets it correctly.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
When this skill is loaded and a user presents a compiler or ISA task, do not
execute stages directly. Immediately spawn the
digital-chip-design-agents:compiler-orchestrator agent and pass the full user
request and any available context to it. The orchestrator enforces the stage
sequence, loop-back rules, and sign-off criteria defined below.
Use the domain rules in this file only when the orchestrator reads this skill mid-flow for stage-specific guidance, or when the user asks a targeted reference question rather than requesting a full flow execution.
Before executing or advising on any stage, read the following files if they exist:
memory/compiler/knowledge.md — known failure patterns, successful tool flags, PDK/tool quirks.
Incorporate its guidance into every stage decision. If absent, proceed without it.memory/compiler/run_state.md — current run identity (run_id, design_name, tool,
last_stage). Use this to resume correctly after interruption. If absent, a new run
is starting; the orchestrator will create this file before the first stage.This pre-run read applies whether this skill is loaded by a user or called by the orchestrator mid-flow. It ensures the fix database is consulted before any diagnosis step.
Build and validate a complete compiler toolchain (LLVM or GCC based) for a custom processor ISA. Bridges hardware and software — without a working toolchain no software can run on the designed chip.
clang, llc, llvm-mc, llvm-objdump) — primary toolchain for new ISA backendsgcc, as, ld, objdump) — alternative backend; well-tested for RISC-V extensionsqemu-system-*) — instruction-accurate ISA emulation for toolchain validation without hardwaregreenhills) — safety-critical compiler and debugger IDEiar) — certified compiler for ARM/RISC-Varmcc, dialect arm) — LLVM-based compiler for Arm targets| ISA Feature | Toolchain Component |
|---|---|
| Instruction encoding | Assembler, disassembler |
| Register file | Register allocator, ABI |
| Calling convention | ABI, function call lowering |
| Branch/jump | Control flow, delay slot handling |
| Load/store addressing | Memory access patterns |
| SIMD/vector | Auto-vectorisation, intrinsics |
| Atomics | Memory model, concurrency |
| Multiply/divide | Integer arithmetic lowering |
| FPU presence | FP ABI (hard-float vs soft-float) |
| Custom instructions | Intrinsics, builtin functions |
<arch>-<vendor>-<os>RegisterInfo.td: register classes, aliases, reserved registersInstrInfo.td: all instruction definitions with encodingCallingConv.td: argument and return value register rulesSchedModel.td: latency and throughput per instruction classTargetMachine.cpp: entry point, subtarget selectionISelDAGToDAG.cpp: selection DAG → machine instruction loweringFrameLowering.cpp: stack frame, prologue/epilogueAsmPrinter.cpp: assembly text emissionllvm-tblgen compiles .td without errorsllc compiles C snippets; verify .s output manuallyllvm-mc --show-encoding verifies instruction encoding| Issue | Fix |
|---|---|
| TableGen pattern not matching | Add explicit Pat<> with matching operand types |
| Stack corrupt | Verify prologue saves all callee-saved regs |
| Calling convention mismatch | Cross-check CCAssignToReg vs ABI spec |
R_<ARCH>_*.section, .global, .type, .size, .align all working.debug_info emitted for a C function (needed for GDB)readelf -aMEMORY {
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
}
ENTRY(_start)
SECTIONS {
.text : { *(.text.reset) *(.text*) *(.rodata*) } > FLASH
.data : { *(.data*) } > RAM AT > FLASH
.bss : { *(.bss*) *(COMMON); PROVIDE(__bss_end = .); } > RAM
.stack : { . = ALIGN(16); PROVIDE(__stack_top = .); . += STACK_SIZE; } > RAM
}
crt0.S): copy .data LMA→VMA; zero .bss; call main()__stack_top; size configurable at link time.data initialised correctly at runtime.bss zeroed at startup| Library | Contents | Source |
|---|---|---|
| compiler-rt | Integer multiply/divide, soft-float | LLVM |
| newlib/picolibc | C standard library (bare-metal) | Port |
| libstdc++/libc++ | C++ standard library | LLVM/GCC |
| libm | Math library | newlib |
_write, _read, _sbrk, _exit, _close_sbrk: heap using __heap_start/__heap_end linker symbols_write: route to UART or semihosting for debug output.init_array section to linker scriptprintf, malloc, memcpy, strlen: all functionalmain()| Tier | Pass Criteria |
|---|---|
| Smoke (hello world) | 100% |
| Unit (per-instruction asm tests) | 100% |
| Compiler (C feature tests) | ≥ 99% |
| Runtime (C library tests) | ≥ 99% |
| Application (representative workloads) | Correct output |
| Performance | Within 10% of target |
After each stage completes (regardless of whether an orchestrator session is active),
write or overwrite one JSON record in memory/compiler/experiences.jsonl keyed by
run_id. This ensures data is persisted even if the flow is interrupted or called
without full orchestrator context.
Use run_id = compiler_<YYYYMMDD>_<HHMMSS> (set once at flow start; reuse on each
stage update). Every JSON record written must include a top-level "run_id" field
whose value matches this key — this is what makes overwrites unambiguous. Set
signoff_achieved: false until the final sign-off stage completes.
Write memory/compiler/run_state.md as the first action before launching any tool:
run_id: compiler_<YYYYMMDD>_<HHMMSS>
design_name: <design>
tool: <primary tool>
start_time: <ISO-8601>
last_stage: <first stage name>
Update last_stage after each stage completes. This file lets wakeup-loop prompts
and resumed sessions identify the correct run without relying on in-memory state.
Create the file and parent directories if they do not exist.
If mcp__plugin_ecc_memory__add_observations is available in this session, emit each
applied fix as an observation to entity chip-design-compiler-fixes after writing to
experiences.jsonl. Skip silently if the tool is absent — JSONL is the canonical record.