Subject: -mregparm=X (for X > 0)
To: None <port-i386@NetBSD.ORG>
From: Craig M. Chase <chase@pine.ece.utexas.edu>
List: port-i386
Date: 07/05/1995 14:18:45
While poking through the info pages of gcc-2.7.0, I discovered the
flag -mregparm=X for the i386.

With this flag you can tell gcc to pass parameters in registers.
Without the flag, all parameters are passed on the stack.  Since the
386 is woefully short on registers, at most 3 parameters can be passed
in registers.  They appear to be passed as follows:

(with -mregparm=3)
parameter 1: eax
parameter 2: edx
parameter 3: ecx
parameter 4: mem[ebp+8]
parameter 5: mem[ebp+12]
etc.

Obviously, the calling conventions for parameters passing must be a
standard across the entire port.  You can't just start compiling
hello_world with -mregparm=3 and expect it to work (you'd have to
recompile all the libraries first).

Has anyone thought of doing this?
Any idea what kinda performance improvement we might see?

Craig

-- 
"They [La Prensa] accused us of suppressing freedom of
 expression.  This was a lie and we could not let them
 publish it."
 - Nelba Blandon, Interior Ministry Director of Censorship, quoted in
   The New York Times, 1984