From: Corey Ashford <yeroca@rocketmail.com>
Subject: Re: Question for the folks who designed Ada95
Date: 1999/04/29
Date: 1999-04-29T00:00:00+00:00 [thread overview]
Message-ID: <3727F0EA.F6E886D2@rocketmail.com> (raw)
In-Reply-To: 3727EC39.E460C803@rocketmail.com
Corey Ashford wrote:
>
> Robert Dewar wrote:
> >
> > In article <3726A2B1.5793E3BE@rocketmail.com>,
> > Corey Ashford <yeroca@rocketmail.com> wrote:
> > > I tried out this technique, by the way, on Apex. Works
> > > like a champ and inlines exactly as you said.
> >
> > Note that there is no requirement at all that this work,
> > but it is not surprising to find that it would work
> > (accidentally? is it documented, I am not sure that it
> > is properly documented for GNAT either come to think
> > about it) since it is an obvious way of implementing
> > things.
> >
> > All the more reason for the ARG to insist on it.
> >
> > There are issues of what types it can be applied to. Shift
> > operations applied for example to non-binary modular types
> > are quite a puzzle.
> >
> > In GNAT, we allow shifts to be applied to any signed or
> > binary unsigned integer type whose size is 8, 16, 32, or
> > 64 (i.e. natural machine sizes for which shifts make
> > sense).
> >
> > It would be interesting to know what restrictions other
> > compilers impose on this usage.
> >
> > -----------== Posted via Deja News, The Discussion Network ==----------
> > http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
> It seems to me that the way to handle it is the way
> "and", "or", etc, were dealt with on non power-of-two modular
> types. That is, do the operation, then do a mod operation
> afterward.
Here's the code I tried:
procedure Testnp2 is
type Foo is mod 15;
function Shift_Left (Value : Foo; Amount : Natural) return Foo;
pragma Import (Intrinsic, Shift_Left);
A : Foo := 7;
B : Foo;
begin
B := Shift_Left (A, 4);
end Testnp2;
**** DISASSEMBLER ****
disassembly for .Rational/Compilation/testnp2.2.o
section .text
_R_testnp2.ibov6gf6nmnlgv9i0i()
0: 84 10 20 07 mov 7, %g2
4: 91 28 b0 04 sllx %g2, 4, %o0
8: 82 0a 20 ff and %o0, 255, %g1
c: 81 c3 e0 08 retl
10: 01 00 00 00 nop
So it doesn't do a mod operation on it afterward... just ands with
a mask that's a multiple of a byte in length and at least as big as modulus-1.
(I confirmed this by trying some other oddball moduluses)
I guess that's reasonable enough.
- Corey
next prev parent reply other threads:[~1999-04-29 0:00 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-04-26 0:00 Question for the folks who designed Ada95 Corey Ashford
1999-04-27 0:00 ` Samuel Mize
1999-04-27 0:00 ` Samuel Mize
1999-04-27 0:00 ` Robert Dewar
1999-04-28 0:00 ` Corey Ashford
1999-04-28 0:00 ` Robert Dewar
1999-04-29 0:00 ` Corey Ashford
1999-04-29 0:00 ` Robert Dewar
1999-04-29 0:00 ` Fraser Wilson
1999-04-29 0:00 ` Marin David Condic
1999-04-29 0:00 ` Robert Dewar
1999-04-28 0:00 ` Samuel Mize
1999-04-28 0:00 ` Samuel Mize
1999-04-28 0:00 ` Corey Ashford
1999-04-28 0:00 ` Corey Ashford
1999-04-27 0:00 ` Robert Dewar
1999-04-27 0:00 ` Corey Ashford
1999-04-27 0:00 ` Tarjei Tj�stheim Jensen
1999-04-27 0:00 ` bill
1999-04-27 0:00 ` dennison
1999-04-27 0:00 ` Robert Dewar
1999-04-29 0:00 ` Robert A Duff
1999-04-27 0:00 ` Robert Dewar
1999-04-27 0:00 ` Al Christians
1999-04-27 0:00 ` Larry Kilgallen
1999-04-27 0:00 ` Al Christians
1999-04-28 0:00 ` Robert A Duff
1999-04-28 0:00 ` Robert Dewar
1999-04-29 0:00 ` Matthew Heaney
1999-04-29 0:00 ` Jean-Pierre Rosen
1999-04-29 0:00 ` Robert Dewar
1999-04-27 0:00 ` Robert Dewar
1999-04-28 0:00 ` Corey Ashford
1999-04-28 0:00 ` Robert Dewar
1999-04-28 0:00 ` Robert A Duff
1999-04-28 0:00 ` Robert Dewar
1999-04-29 0:00 ` Robert A Duff
1999-04-29 0:00 ` Corey Ashford
1999-04-29 0:00 ` Corey Ashford [this message]
1999-04-29 0:00 ` Robert Dewar
1999-04-29 0:00 ` Geert Bosch
1999-04-29 0:00 ` Fraser Wilson
1999-04-29 0:00 ` Marin David Condic
1999-04-29 0:00 ` Mark A Biggar
1999-04-30 0:00 ` Tucker Taft
1999-04-29 0:00 ` Tucker Taft
1999-04-30 0:00 ` David Brown
1999-04-27 0:00 ` David Starner
1999-04-27 0:00 ` Robert Dewar
1999-04-27 0:00 ` David Starner
1999-04-28 0:00 ` Samuel Mize
1999-04-28 0:00 ` Robert Dewar
1999-04-28 0:00 ` Tarjei Tj�stheim Jensen
1999-04-28 0:00 ` Robert A Duff
1999-04-28 0:00 ` dennison
1999-04-28 0:00 ` Robert Dewar
1999-04-28 0:00 ` Robert A Duff
1999-04-28 0:00 ` Brian Hanson
1999-04-28 0:00 ` bill
1999-04-29 0:00 ` Robert S. White
1999-04-29 0:00 ` Robert Dewar
1999-04-30 0:00 ` Robert S. White
1999-04-30 0:00 ` dennison
1999-04-29 0:00 ` Robert Dewar
1999-04-30 0:00 ` Robert S. White
1999-04-29 0:00 ` Robert Dewar
1999-04-28 0:00 ` Pat Rogers
1999-04-29 0:00 ` Robert Dewar
1999-04-29 0:00 ` dennison
1999-04-29 0:00 ` Pat Rogers
1999-04-30 0:00 ` Robert Dewar
1999-04-28 0:00 ` Robert Dewar
1999-04-28 0:00 ` Robert A Duff
1999-04-29 0:00 ` Bill Ghrist
1999-04-29 0:00 ` Tarjei Tj�stheim Jensen
1999-04-28 0:00 ` Larry Kilgallen
1999-04-29 0:00 ` Question for the folks who designed Ad David Kristola
1999-04-29 0:00 ` Paul Duquennoy
1999-04-27 0:00 ` Question for the folks who designed Ada95 Larry Kilgallen
1999-04-29 0:00 ` Aidan Skinner
1999-04-30 0:00 ` Matthew Heaney
1999-04-27 0:00 ` Matthew Heaney
1999-04-27 0:00 ` Corey Ashford
1999-04-28 0:00 ` Robert A Duff
1999-04-28 0:00 ` Keith Thompson
1999-04-29 0:00 ` Robert A Duff
1999-04-28 0:00 ` Marin David Condic
1999-04-27 0:00 ` Matthew Heaney
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox