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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c9629eba26884d78 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-08-09 01:34:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: signature like constructions Date: 09 Aug 2003 09:32:36 +0100 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: References: <3F2BA9C8.9030700@noplace.com> <3F337798.2030008@attbi.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1060418043 17529 62.49.19.209 (9 Aug 2003 08:34:03 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sat, 9 Aug 2003 08:34:03 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: archiver1.google.com comp.lang.ada:41270 Date: 2003-08-09T09:32:36+01:00 List-Id: "Robert I. Eachus" writes: > My favorite example involved the LALR parser generator on Multics. > Pat Prange was about to go through the gory effort to allow an array > of Boolean data to span multiple segments. I asked why he didn't > use a packed representation, and he answered at length. But once we > got all the requirements written down, it turned out that the major > operation on the array was a search in a particular row for the > first set bit. After another half hour of discussion Pat ran off to > implement the new version. To make a long story short, it used the > translate and test instruction in the character string processing > unit. The single instruction generated used a 512-element table to > look up the first non-zero (9-bit) byte detected, and of course the > values in the table were the index of the first set bit. Six lines > of PL/I carefully written so the code generator would emit a single > instruction! > > The net result was to decrease the running time for the tool by over > 90%, from just over 20 minutes to generate an optimized LALR1 parser > for Ada, to just under two minutes. But the point to take away is > not that PL/I was great for this purpose, or Multics. I could write > the same code in COBOL for an IBM mainframe, or C for an x86 or > 680x0 chip. (Or in Ada, or just about any language that let you get > close to the metal when necessary.) The expertise required is in > first figuring out the actual machine code you want generated, then > knowing the compiler internals well enough to make it happen. At some point you need (a) a machine-independent solution to the problem, (b) a machine-dependent optimisation. Clearly it's good if the machine-independent solution is also efficient, but it seems to me like overkill to write 6 very clever lines in the hope that the compiler (and future revisions) will always emit one machine code instruction. Why not use an assembler insert?