Subject: Re: changes for CP0 register names
To: None <simonb@wasabisystems.com>
From: None <cgd@broadcom.com>
List: port-mips
Date: 10/05/2001 09:24:59
simonb@wasabisystems.com ("Simon Burge") writes:
> Here's some changes to <mips/cpureg.h> so that the CP0 register names
> can be used in C code as well as assembler.

so, looks like you're doing this so you can say e.g. :

	#%0

with "i" operand specs in assembler, e.g. to quote from some code you
sent me privately in other mail 8-):

	...
        "mfc0   %0, $%1;"
	...
        : "=r"(ret)
        : "i"(MIPS_COP_0_STATUS),
 
Why is that not better expressed as something like:

	...
	"mfc0	%0, " MIPS_COP_0_STATUS ";"
	...
	: "=r"(ret)

?  I.e., let ANSI string concatenation do the heavy lifting, so that:

	(a) you can reduce the number of annoying % argument
	specifiers in the asms (they're IMO ... very annoying, because
	if you want to figure out which one applies you've gotta
	carefully count through them at the end of the asm), and

	(b) moves the use of the register much closer to the code,
	making it clearer.

Finally, if you want to make a consistent programming model for
e.g. some of the newer mips32 and mips64 cp0 regs, e.g. config1, some
of the cache-related registers, etc., you'd might want to be able to
say:

	mfc0	%0, MIPS_COP_0_CONFIG1

but in this case that would expand to "16, 1" rather than just 16.


So, anyway, I think i'd suggest stringifying them for use in C code,
instead.  8-)


cgd