comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Drummond <brian@shapes.demon.co.uk>
Subject: Re: Forcing GNAT to use 32-bit load/store instructions on ARM?
Date: Tue, 08 Jul 2014 08:50:59 GMT
Date: 2014-07-08T08:50:59+00:00	[thread overview]
Message-ID: <ThOuv.21692$Yi3.18634@fx06.fr7> (raw)
In-Reply-To: lpf7hv$am9$1@loke.gir.dk

On Mon, 07 Jul 2014 17:38:54 -0500, Randy Brukardt wrote:

> "MatthiasR" <MatthiasR@invalid.invalid> wrote in message
> news:lpcck1$vtv$1@dont-email.me...

>> That is not really elegant, because records with representation
>> clauses, directly mapped onto hardware registers, look like the most
>> natural way to access these registers.
> 
> That *is* the most natural way to access those registers. But you can
> never access a *part* of a register, you always have to read or write
> the entire register at a time. Ada makes you make that explicit in your
> code, thus a temporary is required (pending new syntax).

There are exceptions to this. Some embedded CPUs (and even the old Z80) 
have atomic "bit test, set, clear" instructions. Where a register is 
represented in Ada as a packed array of booleans, setting one component 
of the array does actually compile down to a single "bit set" 
instruction. (I do not have a worked example with a record of packed 
booleans, but would expect the same).

(Except for bit 7 on the MSP430 gcc4.9 back end where you get a shift 
instead, which expands to about 30 instructions! Must report that one...)

But the bit access exception doesn't fundamentally change the argument : 
there are no access levels between the bit and the byte (or 32-bit word 
on some architectures) so there are no general hardware means for 
atomically accessing arbitrary sizes or alignments of record components. 

And thus, I see no way to coherently offer such facility in Ada with a 
guarantee of atomicity. 

One of Ada's strengths is that, however abstract the syntax and semantics 
may be, it is always close to the hardware in terms of the underlying 
operations it offers.

- Brian


  parent reply	other threads:[~2014-07-08  8:50 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-30 22:11 Forcing GNAT to use 32-bit load/store instructions on ARM? daniel.dmk
2014-06-30 23:41 ` Jeffrey Carter
2014-07-01 12:06   ` Simon Clubley
2014-07-01 15:44     ` Niklas Holsti
2014-07-01 17:26       ` Simon Clubley
2014-07-01 17:18     ` Simon Wright
2014-07-01 19:43       ` Simon Wright
2014-07-01 17:28     ` Jeffrey Carter
2014-07-01  0:55 ` anon
2014-07-01  4:30 ` Niklas Holsti
2014-07-01  8:11 ` Dmitry A. Kazakov
2014-07-01 12:09   ` Simon Clubley
2014-07-01 12:20     ` Dmitry A. Kazakov
2014-07-01 17:00       ` Simon Clubley
2014-07-01 19:36         ` Dmitry A. Kazakov
2014-07-01 20:08           ` Simon Clubley
2014-07-02 22:24             ` Randy Brukardt
2014-07-06 20:40               ` MatthiasR
2014-07-07  0:25                 ` Simon Clubley
2014-07-07 22:38                 ` Randy Brukardt
2014-07-08  6:51                   ` Simon Wright
2014-07-10 11:47                     ` Simon Wright
2014-07-10 13:06                       ` Simon Clubley
2014-07-11 18:05                         ` Simon Wright
2014-07-11 20:22                           ` Simon Clubley
2014-07-08  8:50                   ` Brian Drummond [this message]
2014-07-08 12:12                   ` Simon Clubley
2014-07-08 13:26                     ` G.B.
2014-07-08 17:13                       ` Simon Clubley
2014-07-08 15:36                     ` Adam Beneschan
2014-07-08 15:40                       ` Adam Beneschan
2014-07-08 20:34                     ` Randy Brukardt
2014-07-09  7:31                       ` Dmitry A. Kazakov
2014-07-10  0:11                         ` Simon Clubley
2014-07-20 11:35                   ` MatthiasR
2014-07-20 15:49                     ` Simon Clubley
2014-07-26 11:05                       ` MatthiasR
2014-08-10 11:20                         ` MatthiasR
2014-07-01 12:03 ` Simon Clubley
2014-07-01 19:52   ` daniel.dmk
2014-07-01 20:40     ` Simon Clubley
2014-07-01 20:55       ` Simon Clubley
2014-07-01 21:01       ` Niklas Holsti
2014-07-01 21:20         ` Simon Clubley
2014-07-01 22:38           ` Niklas Holsti
2014-07-02 16:49             ` Simon Clubley
2014-07-01 21:55         ` daniel.dmk
2014-07-02  7:30     ` Simon Wright
2014-07-02 18:52       ` daniel.dmk
2014-07-04 23:51       ` Niklas Holsti
2014-07-05  0:18         ` Niklas Holsti
replies disabled

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