Assembly or ....

David Collier-Brown dave at lethe.UUCP
Sat Dec 3 12:24:02 AEST 1988


In article <1032 at l.cc.purdue.edu> cik at 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 at winchester.mips.COM>, by mash at 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.



More information about the Comp.lang.c mailing list