Re: [patch, avr, ping #3] PR target/112944: Support .rodata in RAM for AVR64* and AVR128* devices

2024-01-14 Thread Jeff Law




On 1/14/24 06:05, Georg-Johann Lay wrote:

Ping #3

RFA: https://gcc.gnu.org/pipermail/gcc-patches/2023-December/640140.html
Ping #1 https://gcc.gnu.org/pipermail/gcc-patches/2023-December/640981.html
Ping #2 https://gcc.gnu.org/pipermail/gcc-patches/2024-January/641912.html

This is a patch that locates .rodata in flash for some AVR
devices that can support it.  All new functionality depends
on Binutils PR31124 and is switched on by configure checks
for the new emulations.

https://sourceware.org/PR31124 is already upstream.

For explanation of the gcc part see commit message below.

Most of the patch is adjusting device-specs generation.

When there are no objections, I would apply this in the
next week or so, so that it is part of v14.


Johann


--

AVR: Support .rodata in Flash for AVR64* and AVR128* Devices.

These devices see a 32 KiB block of their program memory (flash) in
the RAM address space.  This can be used to support .rodata in flash
provided Binutils support PR31124 (Add new emulations which locate
.rodata in flash).  This patch does the following:

* configure checks availability of Binutils PR31124.

* Add new command line options -mrodata-in-ram and -flmap.
While -flmap is for internal usage (communicate hardware properties
from device-specs to the compiler proper), -mrodata-in-ram is a user
space option that allows to return to the current rodata-in-ram layout.

* Adjust gen-avr-mmcu-specs.cc so that device-specs are generated
that sanity check options, and that translate -m[no-]rodata-in-ram
to its emulation.

* Objects in .rodata don't drag __do_copy_data.

* Document new options and built-in macros.

 PR target/112944

gcc/
 * configure.ac [target=avr]: Check availability of emulations
 avrxmega2_flmap and avrxmega4_flmap, resulting in new config vars
 HAVE_LD_AVR_AVRXMEGA2_FLMAP and HAVE_LD_AVR_AVRXMEGA4_FLMAP.
 * configure: Regenerate.
 * config.in: Regenerate.
 * doc/invoke.texi (AVR Options): Document -mflmap, -mrodata-in-ram,
 __AVR_HAVE_FLMAP__, __AVR_RODATA_IN_RAM__.
 * doc/avr-mmcu.texi: Regenerate.

 * gcc/config/avr/avr.opt (-mflmap, -mrodata-in-ram): New options.
 * config/avr/avr-arch.h (enum avr_device_specific_features):
 Add AVR_ISA_FLMAP.
 * config/avr/avr-mcus.def (AVR_MCU) [avr64*, avr128*]: Set isa flag
 AVR_ISA_FLMAP.
 * gcc/config/avr/avr.cc (avr_arch_index, avr_has_rodata_p): New vars.
 (avr_set_core_architecture): Set avr_arch_index.
 (have_avrxmega2_flmap, have_avrxmega4_flmap)
 (have_avrxmega3_rodata_in_flash): Set new static const bool according
 to configure results.
 (avr_rodata_in_flash_p): New function using them.
 (avr_asm_init_sections): Let readonly_data_section->unnamed.callback
 track avr_need_copy_data_p only if not avr_rodata_in_flash_p().
 (avr_asm_named_section): Track avr_has_rodata_p.
 (avr_file_end): Emit __do_copy_data also when avr_has_rodata_p
 and not avr_rodata_in_flash_p ().
 * config/avr/specs.h (CC1_SPEC): Add %(cc1_rodata_in_ram).
 (LINK_SPEC): Add %(link_rodata_in_ram).
 (LINK_ARCH_SPEC): Remove.
 * gcc/config/avr/gen-avr-mmcu-specs.cc 
(have_avrxmega3_rodata_in_flash)

 (have_avrxmega2_flmap, have_avrxmega4_flmap): Set new static
 const bool according to configure results.
 (diagnose_mrodata_in_ram): New function.
 (print_mcu): Generate specs with the following changes:
 <*cc1_misc, *asm_misc, *link_misc>: New specs so that we don't
 need to extend avr/specs.h each time we add a new bell or whistle.
 <*cc1_rodata_in_ram, *link_rodata_in_ram>: New specs to diagnose
 -m[no-]rodata-in-ram.
 <*cpp_rodata_in_ram>: New. Does -D__AVR_RODATA_IN_RAM__=0/1.
 <*cpp_mcu>: Add -D__AVR_AVR_FLMAP__ if it applies.
 <*cpp>: Add %(cpp_rodata_in_ram).
 <*link_arch>: Use emulation avrxmega2_flmap, avrxmega4_flmap as
 requested.
 <*self_spec>: Add -mflmap or %I think you should go ahead and move forward with this patch.  As you 
know Denis isn't active anymore and you probably know the port better 
than anyone at this point.


I spot checked the patch and didn't see anything obviously wrong. The 
path appears to self configure based on binutils features, so there's no 
concerns in that space.  As you indicated, most of the changes are 
adjusting the specs.


jeff


[patch,avr,ping #3] PR target/112944: Support .rodata in RAM for AVR64* and AVR128* devices

2024-01-14 Thread Georg-Johann Lay

Ping #3

RFA: https://gcc.gnu.org/pipermail/gcc-patches/2023-December/640140.html
Ping #1 https://gcc.gnu.org/pipermail/gcc-patches/2023-December/640981.html
Ping #2 https://gcc.gnu.org/pipermail/gcc-patches/2024-January/641912.html

This is a patch that locates .rodata in flash for some AVR
devices that can support it.  All new functionality depends
on Binutils PR31124 and is switched on by configure checks
for the new emulations.

https://sourceware.org/PR31124 is already upstream.

For explanation of the gcc part see commit message below.

Most of the patch is adjusting device-specs generation.

When there are no objections, I would apply this in the
next week or so, so that it is part of v14.


Johann


--

AVR: Support .rodata in Flash for AVR64* and AVR128* Devices.

These devices see a 32 KiB block of their program memory (flash) in
the RAM address space.  This can be used to support .rodata in flash
provided Binutils support PR31124 (Add new emulations which locate
.rodata in flash).  This patch does the following:

* configure checks availability of Binutils PR31124.

* Add new command line options -mrodata-in-ram and -flmap.
While -flmap is for internal usage (communicate hardware properties
from device-specs to the compiler proper), -mrodata-in-ram is a user
space option that allows to return to the current rodata-in-ram layout.

* Adjust gen-avr-mmcu-specs.cc so that device-specs are generated
that sanity check options, and that translate -m[no-]rodata-in-ram
to its emulation.

* Objects in .rodata don't drag __do_copy_data.

* Document new options and built-in macros.

PR target/112944

gcc/
* configure.ac [target=avr]: Check availability of emulations
avrxmega2_flmap and avrxmega4_flmap, resulting in new config vars
HAVE_LD_AVR_AVRXMEGA2_FLMAP and HAVE_LD_AVR_AVRXMEGA4_FLMAP.
* configure: Regenerate.
* config.in: Regenerate.
* doc/invoke.texi (AVR Options): Document -mflmap, -mrodata-in-ram,
__AVR_HAVE_FLMAP__, __AVR_RODATA_IN_RAM__.
* doc/avr-mmcu.texi: Regenerate.

* gcc/config/avr/avr.opt (-mflmap, -mrodata-in-ram): New options.
* config/avr/avr-arch.h (enum avr_device_specific_features):
Add AVR_ISA_FLMAP.
* config/avr/avr-mcus.def (AVR_MCU) [avr64*, avr128*]: Set isa flag
AVR_ISA_FLMAP.
* gcc/config/avr/avr.cc (avr_arch_index, avr_has_rodata_p): New vars.
(avr_set_core_architecture): Set avr_arch_index.
(have_avrxmega2_flmap, have_avrxmega4_flmap)
(have_avrxmega3_rodata_in_flash): Set new static const bool according
to configure results.
(avr_rodata_in_flash_p): New function using them.
(avr_asm_init_sections): Let readonly_data_section->unnamed.callback
track avr_need_copy_data_p only if not avr_rodata_in_flash_p().
(avr_asm_named_section): Track avr_has_rodata_p.
(avr_file_end): Emit __do_copy_data also when avr_has_rodata_p
and not avr_rodata_in_flash_p ().
* config/avr/specs.h (CC1_SPEC): Add %(cc1_rodata_in_ram).
(LINK_SPEC): Add %(link_rodata_in_ram).
(LINK_ARCH_SPEC): Remove.
* gcc/config/avr/gen-avr-mmcu-specs.cc (have_avrxmega3_rodata_in_flash)
(have_avrxmega2_flmap, have_avrxmega4_flmap): Set new static
const bool according to configure results.
(diagnose_mrodata_in_ram): New function.
(print_mcu): Generate specs with the following changes:
<*cc1_misc, *asm_misc, *link_misc>: New specs so that we don't
need to extend avr/specs.h each time we add a new bell or whistle.
<*cc1_rodata_in_ram, *link_rodata_in_ram>: New specs to diagnose
-m[no-]rodata-in-ram.
<*cpp_rodata_in_ram>: New. Does -D__AVR_RODATA_IN_RAM__=0/1.
<*cpp_mcu>: Add -D__AVR_AVR_FLMAP__ if it applies.
<*cpp>: Add %(cpp_rodata_in_ram).
<*link_arch>: Use emulation avrxmega2_flmap, avrxmega4_flmap as
requested.
<*self_spec>: Add -mflmap or %diff --git a/gcc/config.in b/gcc/config.in
index b499bbfdda7..99fd2d89fe3 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -1679,6 +1679,12 @@
 #endif
 
 
+/* Define if your linker supports emulation avrxmega2_flmap. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_LD_AVR_AVRXMEGA2_FLMAP
+#endif
+
+
 /* Define if your default avr linker script for avrxmega3 leaves .rodata in
flash. */
 #ifndef USED_FOR_TARGET
@@ -1686,6 +1692,12 @@
 #endif
 
 
+/* Define if your linker supports emulation avrxmega4_flmap. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_LD_AVR_AVRXMEGA4_FLMAP
+#endif
+
+
 /* Define if your linker supports -z bndplt */
 #ifndef USED_FOR_TARGET
 #undef HAVE_LD_BNDPLT_SUPPORT
diff --git a/gcc/config/avr/avr-arch.h b/gcc/config/avr/avr-arch.h
index 03b3263d529..d0a297d81e4 100644
--- a/gcc/config/avr/avr-arch.h
+++ b/gcc/config/avr/avr-arch.h
@@ -166,7 +166,35 @@ AVR_ISA_RCALL
   assume these instructions are not available and we set the