{{ message }}
py: Add AArch64 native emitter and inline assembler. - #19697
Draft
StrideZhou wants to merge 1 commit into
Draft
StrideZhou wants to merge 1 commit into
StrideZhou wants to merge 1 commit into
Conversation
StrideZhou
force-pushed
the
aarch64-pr
branch
from
September 13, 2026 03:47
a5a9dba to
3903c47
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19697 +/- ##
==========================================
+ Coverage 98.55% 98.59% +0.03%
==========================================
Files 182 182
Lines 23335 23335
Branches 5 5
==========================================
+ Hits 22998 23006 +8
+ Misses 336 328 -8
Partials 1 1 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
StrideZhou
force-pushed
the
aarch64-pr
branch
3 times, most recently
from
September 13, 2026 15:12
2316851 to
7d3d35b
Compare
StrideZhou
marked this pull request as ready for review
September 13, 2026 16:38
StrideZhou
marked this pull request as draft
September 14, 2026 06:27
StrideZhou
force-pushed
the
aarch64-pr
branch
2 times, most recently
from
September 14, 2026 16:03
c86997d to
14347f4
Compare
Add support for emitting native and Viper code on AArch64, together with an AArch64 inline assembler and the corresponding instruction encoders. Enable the emitters for the unix AArch64 target and add QEMU virt AArch64 boards, including startup code, exception handling, timer and PL011 UART support, semihosting, GC helpers, and libm primitives. Add inline-assembler and native-emitter tests, plus QEMU and unix AArch64 CI jobs. Persistent native .mpy loading remains disabled because the current .mpy format has no available AArch64 architecture ID. See issue micropython#19386. Signed-off-by: Stride Zhou <stride_anderson@qq.com>
StrideZhou
force-pushed
the
aarch64-pr
branch
from
September 15, 2026 14:42
14347f4 to
b402048
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.

1. Motivation & Problem Statement
Currently, MicroPython lacks runtime native code generation (Native/Viper) and inline assembler support for the 64-bit ARM (AArch64/ARMv8-A) architecture. This limits performance optimization opportunities on modern 64-bit ARM platforms, such as native Unix hosts or QEMU-emulated environments. This PR aims to bridge this gap by providing a complete, robust AArch64 instruction emission and inline assembly framework.
2. Summary of Changes
This PR introduces ~5,400+ lines of code, structured across the following areas:
py/): Added the AArch64 assembler, Native/Viper code emitters, and inline assembler instruction encoders.ports/qemu/):VIRT_AARCH64andVIRT_AARCH64_FLOATboard configurations.shared/runtime/semihosting_aarch64.c).sqrtandsqrtfimplementations using the AArch64fsqrtinstruction (lib/libm/andlib/libm_dbl/).qemu-aarch64user-mode emulation.docs/reference/asm_aarch64.rst, detailing register calling conventions, supported instruction subsets (including Python keyword workarounds likeand_), and known limitations.tests/):native_const64.py,viper_const64.py), large stack frame locals (viper_many_locals.py), and large pointer offsets (viper_ptr_large_offset.py).asm_test.py,native_test.py,viper_test.py) to gracefullySKIPif the target lacks a.mpyarchitecture ID, preventing false CI failures..github/workflows/andtools/ci.sh, including automated ARM GNU toolchain download/verification, QEMU bare-metal build/test, Unix user-mode emulation test, and dedicatedgcovcoverage collection for the new emitter files.3. Testing & Verification
Strictly adhering to project CI standards, the following verifications have been completed:
mpy-crossand the Unix port with AArch64 emitters enabled. Feature detection correctly reportsaarch64.VIRT_AARCH64test suite, inline-assembler tests, and Unix AArch64 bytecode/native test suites, generating accurategcovreports forasmaarch64.c,emitnaarch64.c, andemitinlineaarch64.c.4. Trade-offs, Limitations & Alternatives
(Addressing MicroPython's core concerns regarding code size and architectural compatibility)
+0 +0.000%)..mpyArchitecture ID (Critical Limitation): The current.mpyfile format has exhausted its available architecture IDs. Consequently, persistent native.mpyloading is deliberately disabled for AArch64. Inline assembler and Native/Viper code are compiled at runtime only. This is a pragmatic trade-off; architecture-ID allocation is deferred until the.mpyv7 format and native toolchain design are updated (see Issue mpy-cross/mpy-ld/natmod Please add target for aarch64 #19386).pushandpopoperations automatically pad an odd number of registers with a dummy slot (using the zero register) to maintain strict 16-byte stack pointer (sp) alignment.5. Compliance & Generative AI Declaration