comp.lang.ada
 help / color / mirror / Atom feed
From: "Peter C. Chapin" <chapinp@acm.org>
Subject: Re: Question about package Interfaces.
Date: Mon, 13 Sep 2010 09:47:22 -0400
Date: 2010-09-13T09:47:22-04:00	[thread overview]
Message-ID: <4c8e2be0$0$2414$4d3efbfe@news.sover.net> (raw)
In-Reply-To: <wcc4odui9hm.fsf@shell01.TheWorld.com>

On 2010-09-12 23:54, Robert A Duff wrote:

> Unsigned_8'Size = 8.  But that does not mean that all objects
> of subtype Unsigned_8 are 8 bits, nor that X'Size = 8
> (where "X: Unsigned_8;").  For example, an object could
> be stored in a 64-bit register.
> 
> A packed array A of Unsigned_8 will have A'Component_Size = 8,
> and A(I)'Size = 8 for all I.

So I have to explicitly ask for a packed array in order to get this
guarantee? Is that true even if I declare a component type with an
explicit representation clause requesting an 8 bit size? I guess probably.

>> The reference manual does say, "For shifting, zero bits are shifted
>> in..." However, it has recently come to my attention that some
>> processors, such as Intel architecture machines, have shift instructions
>> that mask the shift count. For example, shifting a 32 bit operand by 32
>> bits results in an actual shift of 0 bits. Does that mean
>> implementations for such a system can't compile Interfaces.Shift_Left
>> into a single instruction but instead have to force "unlimited" shift
>> semantics on top of a hardware facility that doesn't do it that way?
> 
> Yes, in general.  However, if the compiler knows that
> the shift count is in a certain range it could optimize
> to a single machine instruction, even on when the hardware
> does something silly (as x86 does).

Okay, good to know. It's another argument in favor of sensible user
defined subtypes.

Thanks

Peter



  reply	other threads:[~2010-09-13 13:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-13  1:10 Question about package Interfaces Peter C. Chapin
2010-09-13  3:54 ` Robert A Duff
2010-09-13 13:47   ` Peter C. Chapin [this message]
2010-09-13 14:15     ` Robert A Duff
2010-09-13 18:31       ` Peter C. Chapin
2010-09-13 22:47         ` Robert A Duff
2010-09-14  6:33     ` J-P. Rosen
2010-09-14 16:36       ` Jeffrey Carter
2010-09-14 17:01         ` J-P. Rosen
replies disabled

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