Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!sri-spam!ames!ucbcad!ucbvax!sdcsvax!celerity!jjw From: jjw@celerity.UUCP Newsgroups: comp.lang.c Subject: Re: Available No. of Registers Message-ID: <873@celerity.UUCP> Date: Thu, 12-Feb-87 12:12:13 EST Article-I.D.: celerity.873 Posted: Thu Feb 12 12:12:13 1987 Date-Received: Fri, 13-Feb-87 22:49:16 EST References: <3950004@nucsrl.UUCP> <83@ucdavis.UUCP> <2250@jade.BERKELEY.EDU> <805@celerity.UUCP> <12982@sun.uucp> Reply-To: jjw@celerity.UUCP (Jim (JJ) Whelan) Organization: Celerity Computing, San Diego, Ca. Lines: 49 In response to my claim that compilers which conform to K&R should allocate "registers" starting with the first declaration guy@sun.UUCP (Guy Harris) indicates: >Fortunately, the ANSI C standard does not promise which declarations >will be effective. I believe this is unfortunate. If I have a program which can effectively use differing numbers of registers how can I indicate which variables should go into registers in a machine/compiler independent manner? For example, postulate a function which has more than 6 variables 6 of which have the following characteristics: a -- Is extremely frequently used. It is critical to performance that it be in a register. b, c -- Are used very frequently. They should be in registers to obtain optimal performance. d, e, f -- Are used frequently. If possible, they should be in registers. The remaining variables are only used infrequently and should never be in registers in preference to those listed. The question is -- How do I declare these variables so that I get the best performance on machines with 1, 3, 6, 8 ... registers available for register variables? I am trying to code in a machine and compiler independent manner. I do not want to reshuffle the declarations nor to have to re-define a "REGISTER" macro. In fact I don't even want to care about how many register variables the compiler allocates. K&R's suggestion that the register variables are assigned to registers in order of appearance solves my problem -- I just put the variables in order of importance and let the compilers handle it from there. The reason for my original posting was because of this. I think the K&R statement, "Only the first few such declarations are effective," is insightful and aids in producing machine independent code. Therefore I am saddened to see it ignored or forgotten. As Guy says: >It's probably a Good Idea to process declarations in the Ritchie >compiler/PCC fashion if you don't use any other information to decide >which variables to put into registers, but it's probably a Good Idea >to offer the programmer the option of using other information, since >they may not know how many and what kind registers the machine the >code is currently being compiled for has. Except that I would replace his "but" with "because". Also, I don't understand what he means by "using other information." I assume the register declarations are the result of considering whatever information the programmer has about the operation of the program.