public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch,avr,applied] Minor fixes in device-specs generation
@ 2024-01-18  9:16 Georg-Johann Lay
  0 siblings, 0 replies; only message in thread
From: Georg-Johann Lay @ 2024-01-18  9:16 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 572 bytes --]

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.

[-- Attachment #2: specs.diff --]
[-- Type: text/x-patch, Size: 3182 bytes --]

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.
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-18  9:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-18  9:16 [patch,avr,applied] Minor fixes in device-specs generation Georg-Johann Lay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).