Message ID | 20191002180047.17144-5-julien.grall@arm.com |
---|---|
State | New |
Headers | show |
Series | xen/arm: Add support to build with clang | expand |
On Wed, 2 Oct 2019, Julien Grall wrote: > Clang is pickier than GCC for the register size in asm statement. It > expects the register size to match the value size. > > The asm statement expects a 32-bit (resp. 64-bit) value on Arm32 > (resp. Arm64) whereas the value is a boolean (Clang consider to be > 32-bit). > > It would be possible to impose 32-bit register for both architecture > but this require the code to use __OP32. However, it does no really > improve the assembly generated. Instead, replace switch the variable to > use register_t. > > Signed-off-by: Julien Grall <julien.grall@arm.com> With or without !! given that it's part of unlikely. Acked-by: Stefano Stabellini <sstabellini@kernel.org> > --- > Changes in v2: > - Use !! per Stefano's request > --- > xen/include/asm-arm/cpufeature.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/xen/include/asm-arm/cpufeature.h b/xen/include/asm-arm/cpufeature.h > index c2c8f3417c..4c5ff6e8ac 100644 > --- a/xen/include/asm-arm/cpufeature.h > +++ b/xen/include/asm-arm/cpufeature.h > @@ -67,14 +67,14 @@ static inline bool cpus_have_cap(unsigned int num) > > /* System capability check for constant cap */ > #define cpus_have_const_cap(num) ({ \ > - bool __ret; \ > + register_t __ret; \ > \ > asm volatile (ALTERNATIVE("mov %0, #0", \ > "mov %0, #1", \ > num) \ > : "=r" (__ret)); \ > \ > - unlikely(__ret); \ > + unlikely(!!__ret); \ > }) > > static inline void cpus_set_cap(unsigned int num) > -- > 2.11.0 >
diff --git a/xen/include/asm-arm/cpufeature.h b/xen/include/asm-arm/cpufeature.h index c2c8f3417c..4c5ff6e8ac 100644 --- a/xen/include/asm-arm/cpufeature.h +++ b/xen/include/asm-arm/cpufeature.h @@ -67,14 +67,14 @@ static inline bool cpus_have_cap(unsigned int num) /* System capability check for constant cap */ #define cpus_have_const_cap(num) ({ \ - bool __ret; \ + register_t __ret; \ \ asm volatile (ALTERNATIVE("mov %0, #0", \ "mov %0, #1", \ num) \ : "=r" (__ret)); \ \ - unlikely(__ret); \ + unlikely(!!__ret); \ }) static inline void cpus_set_cap(unsigned int num)
Clang is pickier than GCC for the register size in asm statement. It expects the register size to match the value size. The asm statement expects a 32-bit (resp. 64-bit) value on Arm32 (resp. Arm64) whereas the value is a boolean (Clang consider to be 32-bit). It would be possible to impose 32-bit register for both architecture but this require the code to use __OP32. However, it does no really improve the assembly generated. Instead, replace switch the variable to use register_t. Signed-off-by: Julien Grall <julien.grall@arm.com> --- Changes in v2: - Use !! per Stefano's request --- xen/include/asm-arm/cpufeature.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)