operand order and mnemonic issues

Jan Beulich jbeulich@novell.com
Mon Dec 15 09:13:00 GMT 2008


Utilizing the SSE5 and AVX additions in 2.19 to use real opcodes (rather than
macros or direct byte encoding) I encountered two things I thought would
deserve some additional consideration:

1) AT&T operand order with three and more operand instructions doesn't
seem to be handled well - the order (source) operands need to be specified
is completely counterintuitive. Just as an example, look at

	fmsubps	%xmm0, %xmm1, %xmm2, %xmm0
	vfmsubps %ymm0, %ymm1, %ymm2, %ymm3

The opcodes say "multiply and subtract", yet the operand order is mixed up,
meaning respectively

	xmm0 = xmm2 * xmm1 - xmm0
	ymm3 = ymm2 * ymm1 - ymm0

I strongly believe (based on the fact how opcodes with only input operands
are handled) that the original intention of AT&T mode was to only has the
destination operand (there only ever is at most one explicit destination) last,
but not to have the source operands also re-ordered. With the i286/i386
additions of the first three operand opcodes (imul-with-immediate and shld/
shrd) this got broken already, but didn't matter much because the operand
types made clear their meaning in the operation to be carried out.

2a) SSE5 floating point comparison mnemonics seem to be at least partially
wrong: comungeXX, comungtXX, comunleXX, and comunltXX seem to all be
improper aliases of (respectively) comltXX, comleXX, comgtXX, and comgeXX,
and comuneXX and comuneqXX appear to generate encodings for ordered
not-equal comparisons (and should hence be named comoneXX and
comoneqXX - I would actually question the "ne" variants' existence anyway,
as all other non-equal vector comparisons use "neq").

2b) Given the (intended) existence of comueqXX and comoneqXX for SSE5,
I wonder whether it wouldn't make sense to be consistent with these
suffixes and allow respective AVX menmonics (vcmpueqXX and vcmponeqXX
as shorthand for respectively vcmpeq_uqXX and vcmpneq_oqXX), too.

Thanks, Jan



More information about the Binutils mailing list