Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!uhccux!munnari.oz.au!murtoa.cs.mu.oz.au!ditmela!yarra!melba!gnb From: gnb@melba.bby.oz (Gregory N. Bond) Newsgroups: comp.lang.c Subject: Re: Source-to-source transformation/optimization in C. Message-ID: <151@melba.oz> Date: 25 Aug 89 03:59:37 GMT References: <3276@yunexus.UUCP> Organization: Burdett, Buckeridge & Young Ltd, Melbourne Lines: 46 Reply-To: In article <3276@yunexus.UUCP> oz@yunexus.UUCP (Ozan Yigit) writes: >Does anyone know of any attempts to do source-to-source transformation >for the purposes of code simplification/optimization on C ?? James Gosling, he of emacs fame and now at Sun working on NeWS, presented a paper at the Australian Unix systems Users Group conference (AUUG 89) last month, titled "Ace: a syntax-driven C preprocessor". I include the abstract: "This document presents the ace preprocessor for C programs. Unlike cpp, which operates on characters, ace operates on syntax trees. The user specifies syntax trees which are used as templates against which program fragments are matched. Positive matches cause trees to be rewritten. Ace can be used as a special-purpose optimizer and can be controlled by the programmer." The driving force behind this was to make graphics blatting routines partameterizable, so the actual loop need only be written once. The ace macros then expand the code for each combination of pixel depth, line orientation, edge clipping, raster ops etc. Constant cases in if() & while() are recognised and rewritten. Boolean tests are simplified. Reduntant code is deleted. The result is a function expanded from 1 page to 20 pages, which is infinitly easier to maintain, but has all the performance advantages of the explicit case. Ace also has a tradeoff operator that will select one of two code sequences depending on estimated time and code size, and user specified levels of optimizing (e.g. space unless it's 30% faster). There are facilities for telling ace how likely an expression is to be true (for branch prediction) and how many times a loop will be run to make these decisions more accurate. In all, a facinating program, and VERY useful in these and similar circumstances. Gosling was fairly emphatic that the program was internal and not a releaseable product. Pity. Unfortunately I know of no other publication (there are no references), and the conference proceedings (AUUGN, Vol 10, no 4) probably aren't available in the US. You might try contacting Gosling direct at Sun for a copy of the paper. Greg. -- Gregory Bond, Burdett Buckeridge & Young Ltd, Melbourne, Australia Internet: gnb@melba.bby.oz.au non-MX: gnb%melba.bby.oz@uunet.uu.net Uucp: {uunet,pyramid,ubc-cs,ukc,mcvax,prlb2,nttlab...}!munnari!melba.bby.oz!gnb