comp.lang.ada
 help / color / mirror / Atom feed
* Elaboration code, aggregates
@ 2021-03-28 19:41 Simon Wright
  2021-03-29 15:24 ` Luke A. Guest
  2021-03-30  7:08 ` Simon Wright
  0 siblings, 2 replies; 8+ messages in thread
From: Simon Wright @ 2021-03-28 19:41 UTC (permalink / raw)


In June 2020, Luke A. Guest was having trouble with getting the compiler
to place constant data into the data section without elaboration code.
https://groups.google.com/g/comp.lang.ada/c/B2NA-qjCJuM/m/4ykywZWZAgAJ

During preliminary work for FSF GCC 11, I found that this ARM interrupt
vector (which used to compile happily without needing elaboration code)
no longer would:
https://github.com/simonjwright/cortex-gnat-rts/blob/master/stm32f4/adainclude/startup.adb#L231

   Vectors : array (-14 .. Ada.Interrupts.Names.FPU_IRQ) of Handler :=
     (-9 .. -6 | -4 .. -3 => null,                      -- reserved
      -14                 => Dummy_Handler'Access,      -- NMI
      -13                 => HardFault_Handler'Access,  -- HardFault
      -12                 => Dummy_Handler'Access,      -- MemManagement
      -11                 => Dummy_Handler'Access,      -- BusFault
      -10                 => Dummy_Handler'Access,      -- UsageFault
      -5                  => SVC_Handler'Access,        -- SVCall
      -2                  => PendSV_Handler'Access,     -- PendSV
      -1                  => SysTick_Handler'Access,    -- SysTick
      others              => IRQ_Handler'Access)
     with
       Export,
       Convention         => Ada,
       External_Name      => "isr_vector";
   pragma Linker_Section (Vectors, ".isr_vector");

and Arduino Due clock startup ddn't:
https://github.com/simonjwright/cortex-gnat-rts/blob/master/arduino-due/adainclude/startup-set_up_clock.adb#L48

   PMC_Periph.CKGR_MOR := (KEY      => 16#37#,
                           MOSCXTEN => 1,     -- main crystal oscillator enable
                           MOSCRCEN => 1,     -- main on-chip rc osc. enable
                           MOSCXTST => 8,     -- startup time
                           others   => <>);

On investigating, it turns out that FSF GCC 11 **AND** GNAT CE 2020 have
lost the ability to assign aggregates as a whole; instead, they assign
the record components one-by-one.

The reason for the Arduino Due failure is that the PMC hardware requires
that each write to the CKGR_MOR register contain that value of KEY! so
the sequence is

read the register (KEY is always returned as 0)
overwrite the KEY field
write the register back
read the register, KEY is 0
overwrite the MOSCXTEN field
write the register back, KEY is 0 so inoperative
etc (including the 'others => <>' components).

Bug report raised:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99802

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-30  7:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-28 19:41 Elaboration code, aggregates Simon Wright
2021-03-29 15:24 ` Luke A. Guest
2021-03-29 16:31   ` Niklas Holsti
2021-03-29 16:34     ` Luke A. Guest
2021-03-29 18:49     ` Andreas ZEURCHER
2021-03-29 19:03       ` Simon Wright
2021-03-29 19:15     ` Paul Rubin
2021-03-30  7:08 ` Simon Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox