barmar@think.COM (Barry Margolin) (04/24/89)
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). 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. Barry Margolin Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar
cik@l.cc.purdue.edu (Herman Rubin) (04/25/89)
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)
barmar@think.COM (Barry Margolin) (04/25/89)
In article <1260@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: }In article <39670@think.UUCP>, I write: }> 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. Since we ARE obviously talking about different things, I'm getting out of the discussion. My posting was about open coding, and you seem to be asking about user-defined inline procedures and escapes to assembler. I don't have a good answer to your question. Barry Margolin Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar