diff mbox

[U-Boot,RFC,07/10] ARM: make gd a function a function for clang

Message ID 1401568344-4441-8-git-send-email-jeroen@myspectrum.nl
State RFC
Delegated to: Tom Rini
Headers show

Commit Message

Jeroen Hofstee May 31, 2014, 8:32 p.m. UTC
---
 arch/arm/include/asm/global_data.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Simon Glass June 3, 2014, 2:20 a.m. UTC | #1
Hi Jeroen,

On 31 May 2014 14:32, Jeroen Hofstee <jeroen@myspectrum.nl> wrote:
> ---
>  arch/arm/include/asm/global_data.h | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
> index 63e4ad5..646d694 100644
> --- a/arch/arm/include/asm/global_data.h
> +++ b/arch/arm/include/asm/global_data.h
> @@ -44,10 +44,27 @@ struct arch_global_data {
>
>  #include <asm-generic/global_data.h>
>
> +#ifdef __clang__
> +
> +#define DECLARE_GLOBAL_DATA_PTR
> +#define gd     get_gd()
> +
> +static __inline volatile gd_t *get_gd(void)
> +{
> +       gd_t *gd_ptr;
> +
> +       __asm__ volatile("mov %0, r9\n" : "=r" (gd_ptr));
> +
> +       return gd_ptr;
> +}
> +
> +#else
> +
>  #ifdef CONFIG_ARM64
>  #define DECLARE_GLOBAL_DATA_PTR                register volatile gd_t *gd asm ("x18")
>  #else
>  #define DECLARE_GLOBAL_DATA_PTR                register volatile gd_t *gd asm ("r9")
>  #endif
> +#endif
>
>  #endif /* __ASM_GBL_DATA_H */

Probably a good idea to copy Albert on these patches. What happens if
you compile ARM64 with Clang?

Regards,
Simon
Jeroen Hofstee June 3, 2014, 7:44 p.m. UTC | #2
On ma, 2014-06-02 at 20:20 -0600, Simon Glass wrote:
> Hi Jeroen,
> 
> On 31 May 2014 14:32, Jeroen Hofstee <jeroen@myspectrum.nl> wrote:
> > ---
> >  arch/arm/include/asm/global_data.h | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> >
> > diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
> > index 63e4ad5..646d694 100644
> > --- a/arch/arm/include/asm/global_data.h
> > +++ b/arch/arm/include/asm/global_data.h
> > @@ -44,10 +44,27 @@ struct arch_global_data {
> >
> >  #include <asm-generic/global_data.h>
> >
> > +#ifdef __clang__
> > +
> > +#define DECLARE_GLOBAL_DATA_PTR
> > +#define gd     get_gd()
> > +
> > +static __inline volatile gd_t *get_gd(void)
> > +{
> > +       gd_t *gd_ptr;
> > +
> > +       __asm__ volatile("mov %0, r9\n" : "=r" (gd_ptr));
> > +
> > +       return gd_ptr;
> > +}
> > +
> > +#else
> > +
> >  #ifdef CONFIG_ARM64
> >  #define DECLARE_GLOBAL_DATA_PTR                register volatile gd_t *gd asm ("x18")
> >  #else
> >  #define DECLARE_GLOBAL_DATA_PTR                register volatile gd_t *gd asm ("r9")
> >  #endif
> > +#endif
> >
> >  #endif /* __ASM_GBL_DATA_H */
> 
> Probably a good idea to copy Albert on these patches. What happens if
> you compile ARM64 with Clang?
> 
> Regards,
> Simon
Jeroen Hofstee June 3, 2014, 7:58 p.m. UTC | #3
Hi Simon (this time with reply..)

On ma, 2014-06-02 at 20:20 -0600, Simon Glass wrote:
> Hi Jeroen,
> 
> On 31 May 2014 14:32, Jeroen Hofstee <jeroen@myspectrum.nl> wrote:
> > ---
> >  arch/arm/include/asm/global_data.h | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> >
> > diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
> > index 63e4ad5..646d694 100644
> > --- a/arch/arm/include/asm/global_data.h
> > +++ b/arch/arm/include/asm/global_data.h
> > @@ -44,10 +44,27 @@ struct arch_global_data {
> >
> >  #include <asm-generic/global_data.h>
> >
> > +#ifdef __clang__
> > +
> > +#define DECLARE_GLOBAL_DATA_PTR
> > +#define gd     get_gd()
> > +
> > +static __inline volatile gd_t *get_gd(void)
> > +{
> > +       gd_t *gd_ptr;
> > +
> > +       __asm__ volatile("mov %0, r9\n" : "=r" (gd_ptr));
> > +
> > +       return gd_ptr;
> > +}
> > +
> > +#else
> > +
> >  #ifdef CONFIG_ARM64
> >  #define DECLARE_GLOBAL_DATA_PTR                register volatile gd_t *gd asm ("x18")
> >  #else
> >  #define DECLARE_GLOBAL_DATA_PTR                register volatile gd_t *gd asm ("r9")
> >  #endif
> > +#endif
> >
> >  #endif /* __ASM_GBL_DATA_H */
> 
> Probably a good idea to copy Albert on these patches. What happens if
> you compile ARM64 with Clang?

As is it will complain that is has no idea what r9 is. At the moment
clang does not have a -ffixed-x18 so there is no polite way to make it
work. With a slightly hacked llvm it seems promising (it compiles at
least and disassembly seems fine). I have no hardware to test it on
though. It would be nice to know if it actually boots..

Perhaps the best thing to do for now is error out and point to the
README explaining why it doesn't work.

Regards,
Jeroen
Simon Glass June 3, 2014, 8 p.m. UTC | #4
Hi Jeroen,

On 3 June 2014 13:58, Jeroen Hofstee <jeroen@myspectrum.nl> wrote:
> Hi Simon (this time with reply..)
>
> On ma, 2014-06-02 at 20:20 -0600, Simon Glass wrote:
>> Hi Jeroen,
>>
>> On 31 May 2014 14:32, Jeroen Hofstee <jeroen@myspectrum.nl> wrote:
>> > ---
>> >  arch/arm/include/asm/global_data.h | 17 +++++++++++++++++
>> >  1 file changed, 17 insertions(+)
>> >
>> > diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
>> > index 63e4ad5..646d694 100644
>> > --- a/arch/arm/include/asm/global_data.h
>> > +++ b/arch/arm/include/asm/global_data.h
>> > @@ -44,10 +44,27 @@ struct arch_global_data {
>> >
>> >  #include <asm-generic/global_data.h>
>> >
>> > +#ifdef __clang__
>> > +
>> > +#define DECLARE_GLOBAL_DATA_PTR
>> > +#define gd     get_gd()
>> > +
>> > +static __inline volatile gd_t *get_gd(void)
>> > +{
>> > +       gd_t *gd_ptr;
>> > +
>> > +       __asm__ volatile("mov %0, r9\n" : "=r" (gd_ptr));
>> > +
>> > +       return gd_ptr;
>> > +}
>> > +
>> > +#else
>> > +
>> >  #ifdef CONFIG_ARM64
>> >  #define DECLARE_GLOBAL_DATA_PTR                register volatile gd_t *gd asm ("x18")
>> >  #else
>> >  #define DECLARE_GLOBAL_DATA_PTR                register volatile gd_t *gd asm ("r9")
>> >  #endif
>> > +#endif
>> >
>> >  #endif /* __ASM_GBL_DATA_H */
>>
>> Probably a good idea to copy Albert on these patches. What happens if
>> you compile ARM64 with Clang?
>
> As is it will complain that is has no idea what r9 is. At the moment
> clang does not have a -ffixed-x18 so there is no polite way to make it
> work. With a slightly hacked llvm it seems promising (it compiles at
> least and disassembly seems fine). I have no hardware to test it on
> though. It would be nice to know if it actually boots..
>
> Perhaps the best thing to do for now is error out and point to the
> README explaining why it doesn't work.

You make it no worse by implementing it with a warning comment in the
code. You could even use #warning perrhaps.

Regards,
Simon
diff mbox

Patch

diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
index 63e4ad5..646d694 100644
--- a/arch/arm/include/asm/global_data.h
+++ b/arch/arm/include/asm/global_data.h
@@ -44,10 +44,27 @@  struct arch_global_data {
 
 #include <asm-generic/global_data.h>
 
+#ifdef __clang__
+
+#define DECLARE_GLOBAL_DATA_PTR
+#define gd	get_gd()
+
+static __inline volatile gd_t *get_gd(void)
+{
+	gd_t *gd_ptr;
+
+	__asm__ volatile("mov %0, r9\n" : "=r" (gd_ptr));
+
+	return gd_ptr;
+}
+
+#else
+
 #ifdef CONFIG_ARM64
 #define DECLARE_GLOBAL_DATA_PTR		register volatile gd_t *gd asm ("x18")
 #else
 #define DECLARE_GLOBAL_DATA_PTR		register volatile gd_t *gd asm ("r9")
 #endif
+#endif
 
 #endif /* __ASM_GBL_DATA_H */