Article View: comp.arch
Article #20889Re: Open coding (was Re: Complex Instructions)
From: Herman Rubin
Date: Tue, 25 Apr 1989 12:42
Date: Tue, 25 Apr 1989 12:42
57 lines
3193 bytes
3193 bytes
In article <39670@think.UUCP>, barmar@think.COM (Barry Margolin) writes:
> In article <1257@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes:
> >It is not true that all languages provide procedures for open coding.
> ^^^ I said "most", not "all".
> >Most provide some procedures for attempting to open-code, but most
> >implementations I have seen discourage this.
>
> Are you talking about LANGUAGES or IMPLEMENTATIONS? What languages
> don't permit built-in operations to be open-coded? What does it mean
> for an implementation to "discourage this"? Either a compiler
> open-codes a particular operation or it doesn't. Maybe we're talking
> about different things (it sounds like you're talking about
> user-defined inline functions).
I know of no provision for this in Fortran, Pascal, Algol, or APL. Every
implementation of C which I have used does not even have a sensible assembler
procedure. I would like to see user-defined inline OPERATIONS as part of
any general-purpose language.
> Remember, my posting also mentioned hiding these things away in
> subroutine libraries. If the operations are sufficiently expensive
> (such as multiple-precision integer arithmetic), the expense of a
> subroutine call should not be a problem, and you probably wouldn't
> want the routines expanded inline all over the place, either.
If the machine has enough registers, quadruple precision integer or
floating point should probably be inlined. The power operator with
integer exponent should probably be inlined. Even in non-inline
situations, subroutine jumps rather than subroutine calls should
frequently be used. I do not know a language which has this; it
should be standard. Do we have a language which allows for goto's
or the equivalent which specifies which register designations are to
be preserved?
How would you handle the following? This is not a made-up example.
if(--n == 0){
if(a++ == b){
REFILL;
a = ASTOR;
a++;}
bts = *a;
n = 64;}
bts <<<= 1;
if (overflow) goto ......;
<<< means a 64-bit shift. It is obviously important that n and bts be
in registers. Also, the type of *a and bts is long long, not double, if
there are illegal doubles or there are automatic overflow or underflow
hardware procedures. This may not be optimal on your machine, but
the algorithm is clear, and is easily modified. If longer shifts are
available, them. And make the appropriate modifications if overflow
indication does not exist.
--
Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907
Phone: (317)494-6054
hrubin@l.cc.purdue.edu (Internet, bitnet, UUCP)
Technical Details
Message-ID:
<1260@l.cc.purdue.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!mentor.cc.purdue.edu!l.cc.purdue.edu!cikReferences:
<57252@yale-celray.yale.UUCP> <4101@tolerant.UUCP> <134@dg.dg.com> <39670@think.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!mentor.cc.purdue.edu!l.cc.purdue.edu!cik From: cik@l.cc.purdue.edu (Herman Rubin) Newsgroups: comp.arch Subject: Re: Open coding (was Re: Complex Instructions) Summary: Which languages customarily allow it? Message-ID: <1260@l.cc.purdue.edu> Date: 25 Apr 89 12:42:54 GMT References: <57252@yale-celray.yale.UUCP> <4101@tolerant.UUCP> <134@dg.dg.com> <39670@think.UUCP> Organization: Purdue University Statistics Department Lines: 57