[PATCH 1/2] target/arm/cpu.h: restrict cpu-defs.h to target specific code

Pierrick Bouvier posted 2 patches 2 weeks ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>
[PATCH 1/2] target/arm/cpu.h: restrict cpu-defs.h to target specific code
Posted by Pierrick Bouvier 2 weeks ago
Allow to use this header from common code, which we do in next commit.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/cpu.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 657ff4ab20b..b8042f65bb4 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -25,7 +25,9 @@
 #include "hw/core/registerfields.h"
 #include "cpu-qom.h"
 #include "exec/cpu-common.h"
+#ifdef COMPILING_PER_TARGET
 #include "exec/cpu-defs.h"
+#endif
 #include "exec/cpu-interrupt.h"
 #include "exec/gdbstub.h"
 #include "exec/page-protection.h"
-- 
2.47.3
Re: [PATCH 1/2] target/arm/cpu.h: restrict cpu-defs.h to target specific code
Posted by Philippe Mathieu-Daudé 1 week, 6 days ago
On 12/3/26 23:47, Pierrick Bouvier wrote:
> Allow to use this header from common code, which we do in next commit.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   target/arm/cpu.h | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index 657ff4ab20b..b8042f65bb4 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -25,7 +25,9 @@
>   #include "hw/core/registerfields.h"
>   #include "cpu-qom.h"
>   #include "exec/cpu-common.h"
> +#ifdef COMPILING_PER_TARGET
>   #include "exec/cpu-defs.h"
> +#endif

Since there are no other uses of COMPILING_PER_TARGET in this
header, this clearly mean "exec/cpu-defs.h" isn't required here
at all but elsewhere:

-- >8 --
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 657ff4ab20b..445d5a8a31d 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -25,7 +25,6 @@
  #include "hw/core/registerfields.h"
  #include "cpu-qom.h"
  #include "exec/cpu-common.h"
-#include "exec/cpu-defs.h"
  #include "exec/cpu-interrupt.h"
  #include "exec/gdbstub.h"
  #include "exec/page-protection.h"
diff --git a/include/exec/helper-head.h.inc b/include/exec/helper-head.h.inc
index 5b248fd7138..5603c9941a7 100644
--- a/include/exec/helper-head.h.inc
+++ b/include/exec/helper-head.h.inc
@@ -46,6 +46,7 @@
  #define dh_ctype(t) dh_ctype_##t

  #ifdef COMPILING_PER_TARGET
+# include "exec/cpu-defs.h"
  # ifdef TARGET_LONG_BITS
  #  if TARGET_LONG_BITS == 32
  #   define dh_alias_tl i32
---
Re: [PATCH 1/2] target/arm/cpu.h: restrict cpu-defs.h to target specific code
Posted by Pierrick Bouvier 1 week, 6 days ago
On 3/12/26 8:48 PM, Philippe Mathieu-Daudé wrote:
> On 12/3/26 23:47, Pierrick Bouvier wrote:
>> Allow to use this header from common code, which we do in next commit.
>>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>>    target/arm/cpu.h | 2 ++
>>    1 file changed, 2 insertions(+)
>>
>> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
>> index 657ff4ab20b..b8042f65bb4 100644
>> --- a/target/arm/cpu.h
>> +++ b/target/arm/cpu.h
>> @@ -25,7 +25,9 @@
>>    #include "hw/core/registerfields.h"
>>    #include "cpu-qom.h"
>>    #include "exec/cpu-common.h"
>> +#ifdef COMPILING_PER_TARGET
>>    #include "exec/cpu-defs.h"
>> +#endif
> 
> Since there are no other uses of COMPILING_PER_TARGET in this
> header, this clearly mean "exec/cpu-defs.h" isn't required here
> at all but elsewhere:
> 
> -- >8 --
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index 657ff4ab20b..445d5a8a31d 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -25,7 +25,6 @@
>    #include "hw/core/registerfields.h"
>    #include "cpu-qom.h"
>    #include "exec/cpu-common.h"
> -#include "exec/cpu-defs.h"
>    #include "exec/cpu-interrupt.h"
>    #include "exec/gdbstub.h"
>    #include "exec/page-protection.h"
> diff --git a/include/exec/helper-head.h.inc b/include/exec/helper-head.h.inc
> index 5b248fd7138..5603c9941a7 100644
> --- a/include/exec/helper-head.h.inc
> +++ b/include/exec/helper-head.h.inc
> @@ -46,6 +46,7 @@
>    #define dh_ctype(t) dh_ctype_##t
> 
>    #ifdef COMPILING_PER_TARGET
> +# include "exec/cpu-defs.h"
>    # ifdef TARGET_LONG_BITS
>    #  if TARGET_LONG_BITS == 32
>    #   define dh_alias_tl i32
> ---

Yes, that's the right place.
I was tempted to moved it there, but decided to stick to target/arm/cpu 
header instead. Your idea is probably better though, feel free to send 
patches for it!

Re: [PATCH 1/2] target/arm/cpu.h: restrict cpu-defs.h to target specific code
Posted by Philippe Mathieu-Daudé 1 week, 6 days ago
On 13/3/26 04:48, Philippe Mathieu-Daudé wrote:
> On 12/3/26 23:47, Pierrick Bouvier wrote:
>> Allow to use this header from common code, which we do in next commit.
>>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>>   target/arm/cpu.h | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
>> index 657ff4ab20b..b8042f65bb4 100644
>> --- a/target/arm/cpu.h
>> +++ b/target/arm/cpu.h
>> @@ -25,7 +25,9 @@
>>   #include "hw/core/registerfields.h"
>>   #include "cpu-qom.h"
>>   #include "exec/cpu-common.h"
>> +#ifdef COMPILING_PER_TARGET
>>   #include "exec/cpu-defs.h"
>> +#endif
> 
> Since there are no other uses of COMPILING_PER_TARGET in this
> header, this clearly mean "exec/cpu-defs.h" isn't required here
> at all but elsewhere:
> 
> -- >8 --
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index 657ff4ab20b..445d5a8a31d 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -25,7 +25,6 @@
>   #include "hw/core/registerfields.h"
>   #include "cpu-qom.h"
>   #include "exec/cpu-common.h"
> -#include "exec/cpu-defs.h"
>   #include "exec/cpu-interrupt.h"
>   #include "exec/gdbstub.h"
>   #include "exec/page-protection.h"
> diff --git a/include/exec/helper-head.h.inc b/include/exec/helper- 
> head.h.inc
> index 5b248fd7138..5603c9941a7 100644
> --- a/include/exec/helper-head.h.inc
> +++ b/include/exec/helper-head.h.inc
> @@ -46,6 +46,7 @@
>   #define dh_ctype(t) dh_ctype_##t
> 
>   #ifdef COMPILING_PER_TARGET
> +# include "exec/cpu-defs.h"
>   # ifdef TARGET_LONG_BITS
>   #  if TARGET_LONG_BITS == 32
>   #   define dh_alias_tl i32
> ---

I'll post patches for this.

Re: [PATCH 1/2] target/arm/cpu.h: restrict cpu-defs.h to target specific code
Posted by Philippe Mathieu-Daudé 1 week, 6 days ago
On 13/3/26 04:58, Philippe Mathieu-Daudé wrote:
> On 13/3/26 04:48, Philippe Mathieu-Daudé wrote:
>> On 12/3/26 23:47, Pierrick Bouvier wrote:
>>> Allow to use this header from common code, which we do in next commit.
>>>
>>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>> ---
>>>   target/arm/cpu.h | 2 ++
>>>   1 file changed, 2 insertions(+)
>>>
>>> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
>>> index 657ff4ab20b..b8042f65bb4 100644
>>> --- a/target/arm/cpu.h
>>> +++ b/target/arm/cpu.h
>>> @@ -25,7 +25,9 @@
>>>   #include "hw/core/registerfields.h"
>>>   #include "cpu-qom.h"
>>>   #include "exec/cpu-common.h"
>>> +#ifdef COMPILING_PER_TARGET
>>>   #include "exec/cpu-defs.h"
>>> +#endif
>>
>> Since there are no other uses of COMPILING_PER_TARGET in this
>> header, this clearly mean "exec/cpu-defs.h" isn't required here
>> at all but elsewhere:
>>
>> -- >8 --
>> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
>> index 657ff4ab20b..445d5a8a31d 100644
>> --- a/target/arm/cpu.h
>> +++ b/target/arm/cpu.h
>> @@ -25,7 +25,6 @@
>>   #include "hw/core/registerfields.h"
>>   #include "cpu-qom.h"
>>   #include "exec/cpu-common.h"
>> -#include "exec/cpu-defs.h"
>>   #include "exec/cpu-interrupt.h"
>>   #include "exec/gdbstub.h"
>>   #include "exec/page-protection.h"
>> diff --git a/include/exec/helper-head.h.inc b/include/exec/helper- 
>> head.h.inc
>> index 5b248fd7138..5603c9941a7 100644
>> --- a/include/exec/helper-head.h.inc
>> +++ b/include/exec/helper-head.h.inc
>> @@ -46,6 +46,7 @@
>>   #define dh_ctype(t) dh_ctype_##t
>>
>>   #ifdef COMPILING_PER_TARGET
>> +# include "exec/cpu-defs.h"
>>   # ifdef TARGET_LONG_BITS
>>   #  if TARGET_LONG_BITS == 32
>>   #   define dh_alias_tl i32
>> ---
> 
> I'll post patches for this.

Posted as series v2:
https://lore.kernel.org/qemu-devel/20260313062055.2188-1-philmd@linaro.org/