diff mbox

[avr] Make pmem-wrap-around option as default

Message ID b996c125-73b4-3605-2db8-968c73cafb2b@microchip.com
State New
Headers show

Commit Message

Pitchumani Sivanupandi Nov. 3, 2016, 7:58 a.m. UTC
Most of the AVR's 8k memorydevices have only rjmp instruction, not jmp. 
So, it
is important to wrap around jump destination to check if it can reach 
backwards.

Currently link specs passes --pmem-wrap-around=xxK when mrelax and
mpmem-wrap-around options are enabled. Attached patch changes the specs 
so that
option --pmem-wrap-around=8K is passed for 8k memory devices if
-mno-pmem-wrap-around is not enabled.

If OK, could someone commit please?

Note: Currently 8k devices are identified based on name prefix. We are 
working
on alternative method to incorporate flash memory size.

Regards,
Pitchumani

gcc/ChangeLog

2016-11-03  Pitchumani Sivanupandi  <pitchumani.s@atmel.com>

     * config/avr/gen-avr-mmcu-specs.c (print_mcu): Update 
link_pmem_wrap spec
     string to add linker option --pmem-wrap-around=8k.
     * config/avr/specs.h: Add link_pmem_wrap to linker specs (LINK_SPEC).

Comments

Georg-Johann Lay Nov. 3, 2016, 12:49 p.m. UTC | #1
On 03.11.2016 08:58, Pitchumani Sivanupandi wrote:
> Most of the AVR's 8k memorydevices have only rjmp instruction, not jmp. So, it

> is important to wrap around jump destination to check if it can reach backwards.

>

> Currently link specs passes --pmem-wrap-around=xxK when mrelax and

> mpmem-wrap-around options are enabled. Attached patch changes the specs so that

> option --pmem-wrap-around=8K is passed for 8k memory devices if

> -mno-pmem-wrap-around is not enabled.

>

> If OK, could someone commit please?

>

> Note: Currently 8k devices are identified based on name prefix. We are working

> on alternative method to incorporate flash memory size.


Currently, "at90usb8" this the only prefix that results in wrap_k = 8, so 
without adding knowledge about flash sizes to the compiler, the change makes 
not much sense... (but does not do harm either).

The right place for flash size info would be avr-mcus.def together with a new 
command option to specify the flash size and draw conclusions from it.  When I 
asked Atmel about a mapping of Device to flash size, the support told me to 
check the data sheets -- not really practical for ~300 devices in avr-mcus.def 
:-)  Atmel *must* have information about this...

The new option would render -mn-flash superfluous, but we should keep it for 
backward compatibility.

Johann

>

> Regards,

> Pitchumani

>

> gcc/ChangeLog

>

> 2016-11-03  Pitchumani Sivanupandi  <pitchumani.s@atmel.com>

>

>     * config/avr/gen-avr-mmcu-specs.c (print_mcu): Update link_pmem_wrap spec

>     string to add linker option --pmem-wrap-around=8k.

>     * config/avr/specs.h: Add link_pmem_wrap to linker specs (LINK_SPEC).



> diff --git a/gcc/config/avr/specs.h b/gcc/config/avr/specs.h

> index 52763cc..fbf0ce6 100644

> --- a/gcc/config/avr/specs.h

> +++ b/gcc/config/avr/specs.h

> @@ -65,6 +65,7 @@ along with GCC; see the file COPYING3.  If not see

>    "%(link_data_start) "                         \

>    "%(link_text_start) "                         \

>    "%(link_relax) "                              \

> +  "%(link_pmem_wrap) "                          \

>    "%{shared:%eshared is not supported} "

>

>  #undef  LIB_SPEC


Shouldn't link_pmem_wrap then be removed from link_relax, i.e. from 
LINK_RELAX_SPEC?  And what happens if relaxation is off?

Johann
diff mbox

Patch

diff --git a/gcc/config/avr/gen-avr-mmcu-specs.c b/gcc/config/avr/gen-avr-mmcu-specs.c
index 7fca756..41dbd80 100644
--- a/gcc/config/avr/gen-avr-mmcu-specs.c
+++ b/gcc/config/avr/gen-avr-mmcu-specs.c
@@ -220,7 +220,9 @@  print_mcu (const avr_mcu_t *mcu)
     : 0;
 
   fprintf (f, "*link_pmem_wrap:\n");
-  if (wrap_k)
+  if (wrap_k == 8)
+    fprintf (f, "\t%%{!mno-pmem-wrap-around: --pmem-wrap-around=8k}");
+  else if (wrap_k > 8)
     fprintf (f, "\t%%{mpmem-wrap-around: --pmem-wrap-around=%dk}", wrap_k);
   fprintf (f, "\n\n");
 
diff --git a/gcc/config/avr/specs.h b/gcc/config/avr/specs.h
index 52763cc..fbf0ce6 100644
--- a/gcc/config/avr/specs.h
+++ b/gcc/config/avr/specs.h
@@ -65,6 +65,7 @@  along with GCC; see the file COPYING3.  If not see
   "%(link_data_start) "                         \
   "%(link_text_start) "                         \
   "%(link_relax) "                              \
+  "%(link_pmem_wrap) "                          \
   "%{shared:%eshared is not supported} "
 
 #undef  LIB_SPEC