From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2e6723b897ab47fb X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.180.106.199 with SMTP id gw7mr218733wib.0.1344434748995; Wed, 08 Aug 2012 07:05:48 -0700 (PDT) Path: n2ni27466099win.0!nntp.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!news.musoftware.de!wum.musoftware.de!newsfeed.straub-nv.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Wed, 08 Aug 2012 16:05:54 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada.Locales pseudo-string types References: <78707b6e-88a3-453a-a37c-840f7a62e703@googlegroups.com> <7303f906-0f6a-4d97-ae15-36b4056ede6c@googlegroups.com> <257b4f44-b6c6-4c79-8c6e-dec947a3ce25@googlegroups.com> In-Reply-To: Message-ID: <5022723b$0$6579$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 08 Aug 2012 16:05:47 CEST NNTP-Posting-Host: 3004efec.newsspool3.arcor-online.net X-Trace: DXC=UC3h`OKO]LCQ@0g`McF=Q^Z^V3h4Fo<]lROoRa8kFjeYMIEonc\616M64>jLh>_cHTX3jmBXCKi=WmANa X-Complaints-To: usenet-abuse@arcor.de Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Date: 2012-08-08T16:05:47+02:00 List-Id: On 08.08.12 13:35, Niklas Holsti wrote: > In my professional area (worst-case execution-time analysis), > compiler-generated implicit loops are often a problem, especially in Ada > programs. A restriction identifier to forbid such loops (at least when > the number of iterations is dynamic) could be useful here, and would let > programmers choose between a restrictive or a permissive coding style. Controlling the translation of array operations seems to be a tricky business, with, apparently, many of the properties of an Ada implementation being considered in addition to the array itself. Maybe the pragmas would have to be rather detailed? In the following example, I get a plain loop for array assignment only for a very specific array length, with an 8 bits component type, even at very low optimization settings. The compiler seems to have a rich repertoire from which to choose what to emit for assignments. The assignment of array X to array Y has been isolated in procedure Assign. package Types is pragma Pure (Types); Does_Not_Unroll : constant := 129; -- Values below 129 will generate unrolled array assignment, -- four components at a time; -- Values 129 and above yield rep; movsq on Intel; -- Values 8193 and above will call _memcpy. type Idx is range 1 .. Does_Not_Unroll; type Vlu is mod 256; type Ary is array (Idx) of Vlu; end Types; with Ada.Numerics.Discrete_Random; with Types; package Bitmaker is new Ada.Numerics.Discrete_Random (Types.Vlu); with Bitmaker; with Types; use Types; procedure Hidden (Result : out Vlu) is G : Bitmaker.Generator; X, Y : Ary; procedure Assign is begin Y := X; end Assign; begin for K in X'Range loop X (K) := Bitmaker.Random (G); end loop; Assign; declare Pick : constant Vlu := X (X'First); Position : constant Idx := Idx'First + Idx'Min (Idx'Last - 1, Vlu'Pos (Pick)); begin Result := Y (Position); end; end Hidden;