cpetig opened PR #13815 from cpetig:arm32 to bytecodealliance:main:
This is related to https://github.com/bytecodealliance/wasmtime/issues/1173 (might fix parts of that issue once complete)
The goal is to implement ARM32 thumb2 not the original ARM32 commands of e.g. ARM9 as they have less practical relevance.
This for now is a skeleton to get a newly added arm32 backend compiling. Further work will gradually implement instructions and functionality.
Of course the naming and scope of the architecture can already be discussed here.
cpetig updated PR #13815.
cpetig updated PR #13815.
cpetig updated PR #13815.
github-actions[bot] added the label isle on PR #13815.
github-actions[bot] added the label cranelift:meta on PR #13815.
github-actions[bot] added the label cranelift on PR #13815.
github-actions[bot] commented on PR #13815:
Subscribe to Label Action
cc @cfallin, @fitzgen
<details>
This issue or pull request has been labeled: "cranelift", "cranelift:meta", "isle"Thus the following users have been cc'd because of the following labels:
- cfallin: isle
- fitzgen: isle
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
:memo: bjorn3 submitted PR review.
:speech_balloon: bjorn3 created PR review comment:
cg_clif would at the very least need the thumb2 (use thumb2 rather than the original thumb) and thumb-mode (actually use thumb rather than arm instructions) settings to match LLVM. And the current backend you wrote should error when either is not set.
:memo: cpetig submitted PR review.
:speech_balloon: cpetig created PR review comment:
I agree about the erroring part, do you have specific names for the flags in mind so that they are more easily compatible with cg_clif?
:memo: cpetig submitted PR review.
:speech_balloon: cpetig created PR review comment:
I guess other settings are has_fp32, has_fp64, has_dsp, has_cbz, has_it.
:memo: cpetig submitted PR review.
:speech_balloon: cpetig created PR review comment:
I guess this should be "arm32" here, I was unsure which part of the triple this matches to.
:speech_balloon: cpetig edited PR review comment.
cpetig updated PR #13815.
cpetig updated PR #13815.
:memo: cpetig submitted PR review.
:speech_balloon: cpetig created PR review comment:
unintentionally included warning fix (newer Rust compiler)
cpetig updated PR #13815.
cpetig commented on PR #13815:
I re-read all the included code, simplified use statements and removed accidental file edits on other architectures (warning fixes for unused
use something::*;)I think this would be a good initial minimal discussion point. I admit that the ABI implementation is more complex than it would need to be for a minimal inclusion (prepared for i64 arguments and results), but also less complex than it will need to become (floating point arguments (hardware float in Sx registers) aren't handled, yet). I can shrink it to the bare minimum if needed.
I really would like to do more realistic tests for this new architecture as well. But as far as I understand runtime tests are restricted to the architecture they are built on, qemu-user is not an option, yet. Any recommendations? [I was toying with the idea of rustc_codegen_clif]
cpetig updated PR #13815.
cpetig commented on PR #13815:
As this now forms an atomic step towards arm32 support I mark it as ready for review to start the discussion about its final form.
cpetig has marked PR #13815 as ready for review.
cpetig requested fitzgen for a review on PR #13815.
cpetig requested wasmtime-compiler-reviewers for a review on PR #13815.
cpetig requested wasmtime-default-reviewers for a review on PR #13815.
:memo: cpetig submitted PR review:
The bug described in https://bytecodealliance.zulipchat.com/#narrow/channel/217117-cranelift/topic/Arm32.20backend.20.28for.20now.20thumb-2.20only.29.20started/near/608325866 is likely caused by this.
:speech_balloon: cpetig created PR review comment:
similarly here
:speech_balloon: cpetig created PR review comment:
I think this should save clobbers as well.
:speech_balloon: cpetig created PR review comment:
This is a nice optimization but doesn't combine with frame setup.
:memo: cpetig submitted PR review.
:speech_balloon: cpetig created PR review comment:
I think you mean these subtarget flags: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/ARM/ARMSubtarget.h and https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/TargetParser/Triple.h - but at least thumb vs arm is selected by the target triple.
fitzgen unassigned fitzgen from PR #13815 Arm32 thumb2 (Cortex-M) support.
fitzgen requested cfallin for a review on PR #13815.
fitzgen commented on PR #13815:
Moving review to @cfallin because (a) I'm not really knowledgeable about arm32 and (b) I will be out of office next week and don't have time to look at it this week.
cfallin commented on PR #13815:
(I'm also on PTO this week, and traveling next week, so I will look at this the week of Mon Jul 20; happy to do so of course)
:memo: bjorn3 submitted PR review.
:speech_balloon: bjorn3 created PR review comment:
You can select between thumb and arm on a per-function basis in LLVM and Rust, so changing the target triple is not the only way of choosing thumb mode.
#[instruction_set(arm::t32)]lowers to what is effectively#[target_feature(enable = "thumb-mode")]in the LLVM backend of rustc. And a couple of rustc targets also usetarget_features: "+thumb-mode"in the target spec.
Last updated: Jul 29 2026 at 05:03 UTC