diff mbox series

[avr,applied] Minor fixes in device-specs generation

Message ID 5b9af5ae-b89c-4970-a2e4-8d119f3a4515@gjlay.de
State New
Headers show
Series [avr,applied] Minor fixes in device-specs generation | expand

Commit Message

Georg-Johann Lay Jan. 18, 2024, 9:16 a.m. UTC
This fixes a typo in the diagnose of a spec.
Also re-uses a spec for a simpler specs file.

Johann

--

AVR: Fix typo in device-specs generation.  Reuse -m[no-]rodata-in-ram 
checker.

gcc/
	* config/avr/gen-avr-mmcu-specs.cc (diagnose_rodata_in_ram): Fix typo
	in the diagnostic, and capitalize the device name.
	(print_mcu): Generate specs such that:
	<*check_rodata_in_ram>: New.
	<*cc1_misc>: Use check_rodata_in_ram instead of cc1_rodata_in_ram.
	<*link_misc>: Use check_rodata_in_ram instead of link_rodata_in_ram.
	<*cc1_rodata_in_ram, *link_rodata_in_ram>: Remove.
diff mbox series

Patch

diff --git a/gcc/config/avr/gen-avr-mmcu-specs.cc b/gcc/config/avr/gen-avr-mmcu-specs.cc
index eb9ab8854d8..72841b1bb42 100644
--- a/gcc/config/avr/gen-avr-mmcu-specs.cc
+++ b/gcc/config/avr/gen-avr-mmcu-specs.cc
@@ -143,22 +143,28 @@  diagnose_mrodata_in_ram (FILE *f, const char *spec, const avr_mcu_t *mcu)
   const bool rodata_in_flash = (arch_id == ARCH_AVRTINY
 				|| (arch_id == ARCH_AVRXMEGA3
 				    && have_avrxmega3_rodata_in_flash));
+  // Device name as used by the vendor, extracted from "__AVR_<Name>__".
+  char mcu_Name[50] = { 0 };
+  if (! is_arch)
+    snprintf (mcu_Name, 1 + strlen (mcu->macro) - strlen ("__AVR___"),
+	      "%s", mcu->macro + strlen ("__AVR_"));
+
   fprintf (f, "%s:\n", spec);
   if (rodata_in_flash && is_arch)
-    fprintf (f, "\t%%{mrodata-in-ram: %%e-mrodata-in-ram not supported"
+    fprintf (f, "\t%%{mrodata-in-ram: %%e-mrodata-in-ram is not supported"
 	     " for %s}", mcu->name);
   else if (rodata_in_flash)
-    fprintf (f, "\t%%{mrodata-in-ram: %%e-mrodata-in-ram not supported"
-	     " for %s (arch=%s)}", mcu->name, arch->name);
+    fprintf (f, "\t%%{mrodata-in-ram: %%e-mrodata-in-ram is not supported"
+	     " for %s (arch=%s)}", mcu_Name, arch->name);
   else if (is_arch)
     {
       if (! have_flmap2 && ! have_flmap4)
-	fprintf (f, "\t%%{mno-rodata-in-ram: %%e-mno-rodata-in-ram not"
+	fprintf (f, "\t%%{mno-rodata-in-ram: %%e-mno-rodata-in-ram is not"
 		 " supported for %s}", mcu->name);
     }
   else if (! have_flmap)
-    fprintf (f, "\t%%{mno-rodata-in-ram: %%e-mno-rodata-in-ram not supported"
-	     " for %s (arch=%s)}", mcu->name, arch->name);
+    fprintf (f, "\t%%{mno-rodata-in-ram: %%e-mno-rodata-in-ram is not supported"
+	     " for %s (arch=%s)}", mcu_Name, arch->name);
   fprintf (f, "\n\n");
 }
 
@@ -265,6 +271,9 @@  print_mcu (const avr_mcu_t *mcu)
     }
 #endif  // WITH_AVRLIBC
 
+  // Diagnose usage of -m[no-]rodata-in-ram.
+  diagnose_mrodata_in_ram (f, "*check_rodata_in_ram", mcu);
+
   // avr-gcc specific specs for the compilation / the compiler proper.
 
   int n_flash = 1 + (mcu->flash_size - 1) / 0x10000;
@@ -285,9 +294,7 @@  print_mcu (const avr_mcu_t *mcu)
            : "\t%{mabsdata}");
 
   // -m[no-]rodata-in-ram basically affects linking, but sanity-check early.
-  diagnose_mrodata_in_ram (f, "*cc1_rodata_in_ram", mcu);
-
-  fprintf (f, "*cc1_misc:\n\t%%(cc1_rodata_in_ram)\n\n");
+  fprintf (f, "*cc1_misc:\n\t%%(check_rodata_in_ram)\n\n");
 
   // avr-gcc specific specs for assembling / the assembler.
 
@@ -332,9 +339,6 @@  print_mcu (const avr_mcu_t *mcu)
 
   fprintf (f, "*link_relax:\n\t%s\n\n", LINK_RELAX_SPEC);
 
-  // -m[no-]rodata-in-ram affects linking.  Sanity check its usage.
-  diagnose_mrodata_in_ram (f, "*link_rodata_in_ram", mcu);
-
   fprintf (f, "*link_arch:\n\t%s", link_arch_spec);
   if (is_device
       && flash_pm_offset)
@@ -356,7 +360,8 @@  print_mcu (const avr_mcu_t *mcu)
       fprintf (f, "\n\n");
     }
 
-  fprintf (f, "*link_misc:\n\t%%(link_rodata_in_ram)\n\n");
+  // -m[no-]rodata-in-ram affects linking.  Sanity check its usage.
+  fprintf (f, "*link_misc:\n\t%%(check_rodata_in_ram)\n\n");
 
   // Specs known to GCC.