This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ARM inline assembly usage in Linux kernel


On 19/02/14 23:19, Andrew Pinski wrote:
> On Wed, Feb 19, 2014 at 3:17 PM, Renato Golin <renato.golin@linaro.org> wrote:
>> On 19 February 2014 11:58, Richard Sandiford
>> <rsandifo@linux.vnet.ibm.com> wrote:
>>> I agree that having an unrecognised asm shouldn't be a hard error until
>>> assembly time though.  Saleem, is the problem that this is being rejected
>>> earlier?
>>
>> Hi Andrew, Richard,
>>
>> Thanks for your reviews! We agree that we should actually just ignore
>> the contents until object emission.
>>
>> Just for context, one of the reasons why we enabled inline assembly
>> checks is for some obscure cases when the snippet changes the
>> instructions set (arm -> thumb) and the rest of the function becomes
>> garbage. Our initial implementation was to always emit .arm/.thumb
>> after *any* inline assembly, which would become a nop in the worst
>> case. But since we had easy access to the assembler, we thought: "why
>> not?".
> 
> With the unified assembly format, you should not need those
> .arm/.thumb and in fact emitting them can make things even worse.
> 

Nonsense.  If an inline assembly statement changed the state and didn't
put it back again, then all hell could break loose afterwards, including
getting bogus error messages out of the assembler that would appear to
the user as bugs in the compiler.  Also not all instructions have duals
in the other instruction set (eg. ORN in thumb has no dual in ARM and
RSB has no dual in thumb).

Furthermore, GCC has to understand some things about inline assembly in
order to get literal pool placement (and in Thumb1 branch ranges)
correct.  It has to assume that an inline assembly block generates no
more than 4 bytes of code per statement in the assembly (so .size
<some-large-number>) is certainly going to cause problems.

Inline assembly can't be an entirely opaque blob.

R.

> Thanks,
> Andrew Pinski
> 
> 
>>
>> The idea is now to try to parse the snippet for cases like .arm/.thumb
>> but only emit a warning IFF -Wbad-inline-asm (or whatever) is set (and
>> not to make it on by default), otherwise, ignore. We're hoping our
>> assembler will be able to cope with the multiple levels of indirection
>> automagically. ;)
>>
>> Thanks again!
>> --renato
> 



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]