Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!sri-spam!ames!ucbcad!ucbvax!decvax!tektronix!uw-beaver!cornell!rochester!pt.cs.cmu.edu!vlsi.cs.cmu.edu!gwu From: gwu@vlsi.cs.cmu.edu.UUCP Newsgroups: comp.arch Subject: Re: subroutine frequency Message-ID: <1031@vlsi.cs.cmu.edu> Date: Fri, 30-Jan-87 18:57:13 EST Article-I.D.: vlsi.1031 Posted: Fri Jan 30 18:57:13 1987 Date-Received: Sat, 31-Jan-87 19:39:41 EST References: <1881@homxc.UUCP> <898@moscom.UUCP> Organization: Carnegie-Mellon University, CS/RI Lines: 25 Keywords: register stack frame variable > I agree that the frequency shouldn't matter. The real question would > be if any compiler is smart enough to ignore a register declaration if > the resulting code would run slower (eg. if a parameter is only accessed > once, outside of a loop, the compiler would probably be better off to > ignore a register declaration). Such an intelligent compiler would need to know the number of times that a given subroutine is called. The number of times that a routine will be called, if at all, is often determinable at run-time only, not compile-time. > a) save all registers > b) have the caller save only the registers it is using > c) have the callee save only the registers it will use > pdp-11's use "a" since they only have 3 register variables anyway. Most > 68k compilers use "c" since you get about 12 register variables. I don't > know of anyone who uses "b" but it should be about as efficient as "c". In the case of the callee saving the registers it is planning to use, the compiler won't know whether or not called subroutines use any registers, and therefore will be unable to figure out whether it is more efficient to use register variables in the main routine. Of course, there is always the possibility of combining the compiler and linker. . . . George