On 01/28/2015 10:17 AM, Ard Biesheuvel wrote:
> On 28 January 2015 at 14:11, Alex Elder <el...@linaro.org> wrote:
>> On 01/28/2015 05:15 AM, Ard Biesheuvel wrote:
>>> On 28 January 2015 at 05:18, Behan Webster <beh...@converseincode.com> 
>>> wrote:
>>>> From: Alex Elder <el...@linaro.org>
>>>>
>>>> My GCC-based build environment likes to call register r12 by the
>>>> name "ip" in inline asm.  Behan Webster informed me that his Clang-
>>>> based build environment likes "r12" instead.
>>>>
>>>> Try to make them both happy.
>>>>
>>>> Signed-off-by: Alex Elder <el...@linaro.org>
>>>> Signed-off-by: Behan Webster <beh...@converseincode.com>
>>>> ---
>>>>  arch/arm/mach-bcm/bcm_kona_smc.c | 9 +++++++--
>>>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/arch/arm/mach-bcm/bcm_kona_smc.c 
>>>> b/arch/arm/mach-bcm/bcm_kona_smc.c
>>>> index a55a7ec..3937bd5 100644
>>>> --- a/arch/arm/mach-bcm/bcm_kona_smc.c
>>>> +++ b/arch/arm/mach-bcm/bcm_kona_smc.c
>>>> @@ -106,9 +106,14 @@ int __init bcm_kona_smc_init(void)
>>>>   * request result appropriately.  This result value is found in r0
>>>>   * when the "smc" request completes.
>>>>   */
>>>> +#ifdef __clang__
>>>> +#define R12    "r12"
>>>> +#else  /* !__clang__ */
>>>> +#define R12    "ip"    /* gcc calls r12 "ip" */
>>>> +#endif /* !__clang__ */
>>>
>>> Why not just use r12 for both?
>>
>> Yes, that would have been an obvious fix.  But the
>> assembler (in the GCC environment) doesn't accept that.
>>
> 
> Mine has no problems with it at all
> 
> $ echo 'mov r12, #0' | arm-linux-gnueabihf-gcc -c -x assembler-with-cpp -
> 
> and grepping for r12 under arch/arm suggests the same

The use of "r12" is fine.  But it's not just the assembler,
I believe it also involves gcc.

The problem is with the use of the __asmeq(x, y) macro.

If I assign the "ip" variable with "r12":
        register u32 ip asm("r12");     /* Also called ip */

Then that's fine.  However, this line then causes an error:
                __asmeq("%0", "r12")

Apparently gcc uses register "ip" when it sees asm("r12").  So
attempting to verify the desired register got used with __asmeq()
causes a string mismatch--"ip" is not equal to "r12".

So I could use:

        register u32 ip asm("r12");     /* Also called ip */
                ...
                __asmeq("%0", "ip")

And that will build.  But it's a little non-intuitive, and
I suspect that clang might (rightfully) have a failure in
this __asmeq() call.

                                        -Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to