Xref: utzoo comp.lang.c++:2172 comp.lang.c:14471 comp.lang.forth:710 comp.lang.fortran:1577 comp.lang.misc:2262 comp.arch:7419 Path: utzoo!yunexus!geac!geaclib!lethe!dave From: dave@lethe.UUCP (David Collier-Brown) Newsgroups: comp.lang.c++,comp.lang.c,comp.lang.forth,comp.lang.fortran,comp.lang.misc,comp.arch Subject: Re: Assembly or .... Message-ID: <3459@geaclib.UUCP> Date: 3 Dec 88 02:24:02 GMT Article-I.D.: geaclib.3459 References: <8938@winchester.mips.COM>, <1988Nov28.195846.921@utzoo.uucp> Sender: daveb@geaclib.UUCP Reply-To: geaclib!lethe!dave Organization: Interleaf Canada Inc. (News courtesy of Geac) Lines: 47 In article <1032@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: | Another effect of the HLL tyranny is that the operations which are beyond | the ken of th HLL designers are disappearing from the machines. From article <8938@winchester.mips.COM>, by mash@mips.COM (John Mashey): | Although I don't necessarily subscribe to Herman's opinions, R2000 divides | actually do this (leave both results in registers). Although I shouldn't | have been, I was surprised to find that the following C code, compiled | unoptimized (optimized, it essentially disappears, of course): | main() { | register i,j,k; | i = j / 7; | k = j % 7; | } | generates one divide instruction to get both of the results. Actually its isn't too surprising: one of the primitives I want at code-generator-generation time is an n-tuple consisting of: instruction name input register(s) and content constraints (aka types) output register(s) ditto pattern to generate instruction size time (or other figure of merit) If I have these, I claim I can write a code generator that will do a "good" job [see note below]. If I preserve these, however, I also get the ability to do usefull, if simple, improvements in the code generated to do setup/teardown before and after the operation. If I plan on doing so, I get the ability to take a new instruction, specified by the programmer, and provide the same kind of results. The simple case is old hat [press n if you've seen this one before] Define a system call in Ada by defining the representation of a trap word, provide the types of input and output by declaring it in functional/procedural form and the register constraints by pragmas. Then look at the code generated (about 3 years ago on a small honeybun) and note that no redundant register-register moves were generated on either call or return. --dave (this also answers the question of rarely-used instructions being skimped on) c-b note: No, I **can't** write you a code-generator-generator. I'm not a good enough academic. But I've met people who have... I can only write code-generators themselves.