# Qemu Tcg Backend Adaptation

> Use for adapting a QEMU TCG host backend, including optional op support, constraints, register allocation, host code emission, qemu_ld/st, atomics, and vector ops. Extends qemu-flow-plan and qemu-rlcr-loop.

- **Type:** Skill
- **Install:** `agentstack add skill-processmission-oh-my-qemu-qemu-tcg-backend-adaptation`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [processmission](https://agentstack.voostack.com/s/processmission)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [processmission](https://github.com/processmission)
- **Source:** https://github.com/processmission/oh-my-qemu/tree/main/.agents/skills/qemu-tcg-backend-adaptation
- **Website:** https://processmission.github.io/oh-my-qemu/

## Install

```sh
agentstack add skill-processmission-oh-my-qemu-qemu-tcg-backend-adaptation
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# QEMU TCG Backend Adaptation

Use this domain skill for host backend work under `tcg//`: instruction encoders, `TCG_TARGET_HAS_*`, constraints, `tcg_out_op`, qemu load/store paths, vector emission, and generated host-code bugs.

## Flow dependencies

1. Start with `qemu-flow-plan`.
2. Put host-code logs, TCG dumps, temporary disassembly, benchmark notes, and review files under `build/agent//`.
3. Use `qemu-rlcr-loop` for implementation/debug rounds.
4. Use `qemu-build` for host backend builds.
5. Use `qemu-debug` for TCG logs and `one-insn-per-tb`.
6. Use `qemu-model-verification` for final evidence.

## Hard policy boundary

Do not produce source code intended for QEMU upstream submission. Do not add DCO or review trailers.

## Backend contract

A backend change is correct only when these agree:

- IR op semantics from `include/tcg/tcg-opc.h` and `docs/devel/tcg-ops.rst`;
- host feature flag in `tcg-target-has.h`;
- operand constraints in `tcg-target-con-str.h` and `tcg-target-con-set.h`;
- register class/reserved-register assumptions in `tcg-target.h`;
- `tcg_out_op`, vector emission, or qemu_ld/st implementation in `tcg-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 the plan:

- 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:

- `MemOp` size, 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/v256` and 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/tcg` when available.
- Capture TCG IR and host-code logs proving native emission or fallback.
- Check unsupported host features remain disabled.
- Use `one-insn-per-tb` when 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`.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [processmission](https://github.com/processmission)
- **Source:** [processmission/oh-my-qemu](https://github.com/processmission/oh-my-qemu)
- **License:** MIT
- **Homepage:** https://processmission.github.io/oh-my-qemu/

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-processmission-oh-my-qemu-qemu-tcg-backend-adaptation
- Seller: https://agentstack.voostack.com/s/processmission
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
