return expr and Decus-C: let's stop talking about this

Guy Harris guy at rlgvax.UUCP
Thu May 17 10:24:46 AEST 1984


> For heaven's sake, isn't there something more interesting to talk
> about?

Hell, yes.  *Anything* would be more interesting to talk about than
religious arguments about the "right" place to put tokens on "paper".
I've seen a wide variety of styles, and most of them are readable.
Only those that aren't readable (i.e., crappy indentation) are deserving
of censure (or even discussion).

> How about ... runtime checking?  Or static checking?  Or
> radical optimization?  Has anyone made a compiler (or preprocessor)
> which will substitute an instruction (or asm statement) for a strcpy,
> say?

Well, you guys wrote a compiler that does the first and/or the second, so
the ball is in your court....  By "radical optimization", do you mean what
a "typical" optimizing compiler does, or something beyond that?  Yes, I
hear some of you out there complaining that you can't write device drivers
for an optimizing compiler.  Well, the problem is that some variables'
behavior can't be determined by dataflow analysis; variables shared between
processes (either in the kernel or in shared segments - as of S5, UNIX actually
has an official implementation of shared data!) have the same problem as
device registers, which are "variables" shared by the CPU and the device.
PL/I had a simple solution; declare the variable "abnormal".  This tells the
compiler that if the variable gets set to "77" in statement N, that the
variable may not have the value "77" in statement N+1.

As for the substitution of instructions for subroutine calls, this is done
more and more with the aid of "sed" scripts; both Bell and Berkeley's
recent distributions do it quite a bit.  They also do substitutions of "text"
for "data" in the assembly output, to move common read-only data like strings
to shared code space.  This crock, at least, may become obsolete soon with
a "const" or "readonly" storage class.  It would be nice if the "asm.sed"s
could also be made obsolete.  Two ways I can think of off the top of my head
are:

	1) tweaking the peephole/final optimizer (C2) to detect certain
	subroutine calls and to substitute assembly code sequences.  The
	simple-minded way is to leave the pushes of the operands there, and
	to have the instruction take its operands off the stack.  A fancier
	way might turn

	movl	#count,-(sp)
	movl	$to,-(sp)
	movl	$from,-(sp)
	calls	#3,_bcopy

	into

	movc3	from,to,#count	# or whatever the VAX-11 syntax is

	which would be trickier.

	2) having a way to specify to the code generator that certain
	"subroutines" are really builtins, and have it generate the
	appropriate instruction.  Of course, one would want to be able to
	shut this off, as you might have a routine called "bcopy" which
	*didn't* copy arg[3] bytes from arg[1] to arg[2] and not want all
	calls to that routine turned into block moves.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.lang.c mailing list