[PATCH] ARM: Emit ".code 16" before global inline-asm instructions in thumb mode

Renato Golin renato.golin at linaro.org
Fri Jul 25 01:32:31 PDT 2014

On 25 July 2014 01:29, Eric Christopher <echristo at gmail.com> wrote:
> Does gcc emit a .code16 for file level inline assembly when compiling
> with -mthumb?

Yes, the patch is in line with GCC's behaviour, and I honestly thought
we were doing this, already... :/

We could do better, however, because we do parse and validate inline
assembly. We should be able to tell if the snippet contains ARM/Thumb
code or any .code modifiers, and thus only change after the inline asm
if really needed.

Saleem, I remember you had a look at that, didn't you have a working prototype?

For now, the patch looks good and would be perfect for 99% of the
cases and mostly harmless for the rest. The only problem is if the
code was in ARM mode, with Thumb code in the snippet changed via
.code16, and the user forgot to change it back to ARM before the end
of the snippet. But that's advanced user stupidity detection, and is
an enhancement at best.

Thanks for spotting that!


More information about the llvm-commits mailing list