-
Notifications
You must be signed in to change notification settings - Fork 240
Generalize load-immediate operations on ARM #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The ARMv6 comes in two flavors depending on the version of the Thumb instruction set supported: ARMv6 for the original Thumb, ARMv6T2 for Thumb2. CompCert only supports Thumb2, so its ARMv6 architecture should really be called ARMv6T2. This makes a difference: the GNU assembler rejects most of the instructions CompCert generates for ARMv6 with "-mthumb" if the architecture is specified as ".arch armv6" as opposed to ".arch armv6t2". This patch fixes the architecture specification in the target printer and the internal name of the architecture. It does not change the configure script's flags to avoid breaking changes.
These move-immediate instructions used to be only emitted in Thumb mode, not in ARM mode. As far as I understand ARM's documentation, these instructions are available in *both* modes in ARMv6T2 and above. This should cover all of CompCert's ARM targets. Tested for ARMv6 and ARMv7, both with and without Thumb2. The behavior is now identical to Clang, and the GNU assembler accepts these instructions in all configurations.
|
Indeed, the question is whether we want to support "plain" ARMv6 (before ARMv6T2) or not. If the answer is "yes" we need to keep the old, ORR-based code. If "no", the
What makes you conclude this? If the option |
Yes, it does. Sorry if I was unclear. My understanding is that if However, if CompCert is configured for So I think the check in the target printer could also be written as follows: |
Except, of course, exactly the very instructions being discussed here. Sorry, I'm getting confused by this topic. However:
If the answer to that question is yes, compilers configured for |
- define separate architecture models for ARMv6 and ARMv6T2 - introduce `Archi.move_imm` parameter on ARM to identify models with `movw`/`movt` move-immediate instructions (all except ARMv6, in both ARM and Thumb mode)
|
Added a patch to separate the ARMv6 and ARMv6T2 cases. There are now the following cases:
The generation of For the Let me know if you think this is the way to go. |
|
This looks very good to me, thanks. A few nits in the code review that follows. I don't know if there is commercial interest in "plain" ARMv6 (pre-Thumb-2) processors. Some Raspberry Pis were plain ARMv6: I remember because I had to buy a more modern ARM platform to test the Thumb2 mode of CompCert. At any rate, it cannot hurt to keep plain ARMv6 support in CompCert for the time being. Just for the record: besides |
xavierleroy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of suggestions.
arm/Archi.v
Outdated
| Parameter abi: abi_kind. | ||
|
|
||
| (** Whether to generate [movw] and [movt] instructions. *) | ||
| Parameter move_imm: bool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer a different name and intuitive meaning for this parameter, one that means "plain ARMv6" versus "ARMv6T2 and above". One reason being that there are other instructions that are not in "plain ARMv6" and that we may want to generate some day. Some possible names:
thumb2_supportorT2_supportarmv6_only(with the opposite meaning:truefor ARMv6,falsefor ARMv6T2 and up).
| [ Exact "-mthumb", Set option_mthumb; | ||
| Exact "-marm", Unset option_mthumb; ] | ||
| if Configuration.model = "armv6" then [] (* Thumb needs ARMv6T2 or ARMv7 *) | ||
| else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to nit-pick: the -marm option should be available on ARMv6 as well, so that a user who absolutely wants ARM encoding can express this intention by putting -marm, and still be able to compile on ARMv6.
- rename relevant parameter to `Archi.thumb2_support` - on ARMv6 without Thumb2, silently accept -marm flag (but not -mthumb) - allow generation of `sbfx` in ARM mode if Thumb2 is supported
|
Thanks for the review, I added a new patch. Good point about |
|
I forgot that CompCert is already using the The current code looks good to me. Maybe @m-schmidt or @bschommer would like to have a quick look at it before we merge? |
|
Looks good to us. |
|
All right, I merge, then. |
At least OCaml 4.05 is now required as well as Coq 8.8.
On ARM,
movwandmovtcan always be used to load immediates into general-purpose registers. This used to be only done in Thumb mode. It is simpler than the series oforroperations that used to be emitted in ARM mode.Also, the ARMv6 flavor targeted by CompCert is in fact ARMv6T2 (with Thumb2).