Georg-Johann Lay schrieb:
This patch addresses several issues related to device flash size:

* cores avrxmega4/5 have ELPM* instruction

* flash sizes for xmega were wrong because atxmegaXX
  has some extra bootloader flash and thus a flash size
  of XX + epsilon.

* There are devices with different flash sizes, i.e. with
  different sets of reasonable address spaces within the same
  core architecture.  Thus, turn flash size from a core property
  to a device property

* No more try to fix silly (too big) address spaces by means
  of modulo computation. Just emit an error if a nonsensical
  address space is used

As this patch is mainly about the new xmega architecture support:

I updated the avrtest core simulator hosted in the WinAVR project at sourceforge. The avrtest simulator can now be used to reg-test avr-gcc testsuite against xmega core.

The regression tests on xmega revealed two typos in avr BE that are already fixed:

http://gcc.gnu.org/viewcvs?view=revision&revision=184522
http://gcc.gnu.org/viewcvs?view=revision&revision=184559

As target I used atxmega128a3 and the test results are exactly the same as for atmega128, except for some functions that use builtin return or instrument-functions that trigger builtin return.

This is because the testsuite was run with this patch applied and the flash size of atxmega128a3 is > 64Ki words then, thus a warning from avr.c

rtx
avr_return_addr_rtx (int count, rtx tem)
{
  ...

  if (AVR_3_BYTE_PC)
    {
      r = gen_rtx_SYMBOL_REF (Pmode, ".L__stack_usage+2");
      warning (0, "'builtin_return_address' contains only
               2 bytes of address");
    }

I did not try to use PSImode as potential fix; but even with PSImode there would be a warning from

static bool
avr_assemble_integer (rtx x, unsigned int size, int aligned_p)
{
  ...
  if (GET_MODE (x) == PSImode)
    {
      default_assemble_integer (avr_const_address_lo16 (x),
                                GET_MODE_SIZE (HImode), aligned_p);

      fputs ("\t.warning\t\"assembling 24-bit address needs binutils"
             " extension for hh8(", asm_out_file);
      output_addr_const (asm_out_file, x);
      fputs (")\"\n", asm_out_file);

      fputs ("\t.byte\t0\t" ASM_COMMENT_START " hh8(", asm_out_file);
      output_addr_const (asm_out_file, x);
      fputs (")\n", asm_out_file);

      return true;
    }

The simulator does not test I/O and the new operand modifier %i, of course, but I heard that guys using 4.7 snapshots could compile and run xmega programs without problems.

Johann


Passes without regression.

Ok for trunk?

Johann

        PR target/49868
        * doc/extend.texi (AVR Named Address Spaces): No more try to fix
        address spaces located outside of device flash.

        PR target/49868
        PR target/52261
        * config/avr/avr.h (base_arch_s): Remove field n_segments.
        (mcu_type_s): Add field n_flash.
        * config/avr/avr-devices.c (avr_arch_types): Remove .n_segments.
        Set .have_elpm and .have_elpmx to 1 for avrxmega4 and avrxmega5.
        (AVR_MCU): Add N_FLASH argument.
        * config/avr/avr-mcus.def (AVR_MCU): Add initializer for .n_flash.
        * config/avr/avr-c.c (avr_cpu_cpp_builtins): Only define built-in
        macro __FLASH<n> if that address space makes sense for the device.
        * config/avr/avr.c (avr_out_lpm): Don't try to fix address spaces
        outside of target flash.
        (avr_asm_named_section): Ditto.
        (avr_asm_select_section): Ditto.
        (avr_addr_space_convert): Ditto.
        (avr_emit_movmemhi): Ditto.
        (avr_nonconst_pointer_addrspace, avr_pgm_check_var_decl): Error if
        address space is outside of device flash.
        (avr_insert_attributes): Ditto.
        (avr_xload_libgcc_p): Use avr_current_device->n_flash instead of
        avr_current_arch->n_segments.

Reply via email to