qemu-tcg-backend
Skill57 starsChanged 4 months agoMITView on GitHub
Use for adapting a QEMU TCG host backend, including optional op support, constraints, register allocation, host code emission, qemu_ld/st, atomics, vectors, and native-versus-fallback verification.
In this repository17 other files it gives its agents.
- AGENTS.mdAGENTS.md
- qemu-agent-feedbackSkill
- qemu-board-modelingSkill
- qemu-boot-runSkill
- qemu-buildSkill
- qemu-debugSkill
- qemu-imageSkill
- qemu-kernel-buildSkill
- qemu-linux-bootSkill
- qemu-model-verificationSkill
- qemu-peripheral-modelingSkill
- qemu-qtestSkill
- qemu-register-extractionSkill
- qemu-rst-documentationSkill
- qemu-tcg-frontendSkill
- qemu-uboot-buildSkill
- qemu-workflowSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 24
Before changing source or mutable artifacts, record the workspace root, revision, git status --short, pre-existing changes, goal, scope, …
- Very specific: line 31
Keep QEMU builds under source-root builds/build-<target>/.
- Very specific: line 71
Do not enable TCG_TARGET_HAS_* before constraints and emission support are complete.
- Distinctive: line 100
Keep code generation paths allocation-free and simple.
- Very specific: line 128
Run focused tests/tcg when available.
- Distinctive: line 130
Check unsupported host features remain disabled.
- Very specific: line 131
Use one-insn-per-tb when frontend/backend attribution is unclear.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
QEMU TCG Backend Adaptation
Audit workflow
For non-trivial workspace writes, use a stable
.oh-my-qemu/<task-slug>/ directory and create only needed entries:
.oh-my-qemu/<task-slug>/
├── audit.md # Baseline, scope, decisions, evidence, verification, and gaps
├── commands.md # Redacted commands, working directories, and results
├── logs/ # Decisive build, test, runtime, or diagnostic logs
├── scripts/ # Temporary scripts, probes, parsers, and harnesses
└── output/ # Generated deliverables, dependencies, and non-QEMU binariesBefore changing source or mutable artifacts, record the workspace root,
revision, git status --short, pre-existing changes, goal, scope, and
acceptance checks in audit.md. Log exact redacted commands and results in
commands.md; record revisions, configurations, tool versions, and hashes when
they affect reproducibility. Separate observations from inferences and edit
source only when requested.
Keep QEMU builds under source-root builds/build-<target>/; put third-party
dependencies and non-QEMU binaries in task output/. Before writing audit
artifacts or configuring QEMU in a Git worktree, add .agents/,
.oh-my-qemu/, and builds/ to the repository-local file from
git rev-parse --git-path info/exclude; preserve existing entries and avoid
duplicates. Never stage or commit those directories. At handoff, verify them
absent from git status --short. Report the task directory and unresolved gaps.
Workflow
- Record host architecture/features/toolchain, IR semantics, constraints, emitter path, unsupported cases, and allowed source paths.
- Inspect the checked-out backend and generic fallback before enabling an op.
- Work in small reviewable rounds and record changed paths, verification,
review result, and gaps in
audit.md. - Build for the affected host and run focused tests that exercise both native and fallback behavior where applicable.
- Capture bounded host-code/TCG logs and keep unsupported features disabled until constraints, emission, and evidence agree.
QEMU upstream boundary
QEMU's official GitLab and mailing lists are upstream project channels. A
patch becomes an upstream contribution when sent to the mailing-list recipients
selected through MAINTAINERS; do not prepare or send agent-generated patches
for that submission. Local branches, commits, patch files, pushes, and pull
requests are not by themselves QEMU upstream contributions. Perform those Git
actions only when requested and follow the workspace's Git policy.
Backend contract
A backend change is correct only when these agree:
- IR op semantics from
include/tcg/tcg-opc.handdocs/devel/tcg-ops.rst; - host feature flag in
tcg-target-has.h; - operand constraints in
tcg-target-con-str.handtcg-target-con-set.h; - register class/reserved-register assumptions in
tcg-target.h; tcg_out_op, vector emission, or qemu_ld/st implementation intcg-target.c.inc;- tests/logs proving the native path or intentional generic expansion.
Do not enable TCG_TARGET_HAS_* before constraints and emission support are complete.
Classify the change
Record one category in audit.md:
- new host instruction encoder;
- native emission for existing TCG op;
- optional op enablement;
- constraint/register allocation fix;
- qemu_ld/st or atomic path;
- vector op support;
- host feature gating/runtime CPU detection;
- code generation bug investigation.
Emission checklist
Check:
- immediate ranges and sign extension;
- i32 result extension on 64-bit hosts;
- signed vs unsigned conditions;
- branch displacement and relocation/pool handling;
- clobbers and call ABI;
- scalar vs vector register classes;
- host endianness;
- constant materialization;
- instruction-cache flush needs.
Keep code generation paths allocation-free and simple.
qemu_ld/st and atomics
Verify separately:
MemOpsize, sign, and endianness;- TLB fast path vs slow path labels;
- i128 register pairing;
- user-mode vs system-mode differences;
- guest atomicity vs host capability;
- helper calls and clobbers;
- unaligned behavior.
Vector rules
For vectors, verify:
- host vector feature detection;
v64/v128/v256and specific op flags;- element size coverage;
- constant operand forms;
- scalar fallback vs vector path;
tcg_can_emit_vec_op()/tcg_expand_vec_op()behavior.
Verification expectations
- Build the backend on the host.
- Run focused
tests/tcgwhen available. - Capture TCG IR and host-code logs proving native emission or fallback.
- Check unsupported host features remain disabled.
- Use
one-insn-per-tbwhen frontend/backend attribution is unclear.
Upstream references
- QEMU code provenance and AI policy:
docs/devel/code-provenance.rst. - TCG IR semantics:
docs/devel/tcg-ops.rst. - TCG internals:
docs/devel/tcg.rst. - Backend examples:
tcg/aarch64/,tcg/riscv64/,tcg/loongarch64/. - Core declarations:
include/tcg/tcg.h,include/tcg/tcg-opc.h,include/tcg/tcg-op-common.h.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

