md description for intruction that modifies multiple operands

Fred Fish fnf@public.ninemoons.com
Sun May 25 02:34:00 GMT 2003


I'm working on a machine which has an instruction that modifies
multiple operands, with all the operands being both input and output
operands.  In addition, the operands have to be in sequential
registers.  The C interface is a builtin function call.

For the sake of discussion, assume that the instruction is called
"block4" and the C interface is used something like:

	int foo (int a, int b, int c, int d)
	{
	  __builtin_block4 (a, b, c, d);
	  __builtin_block4 (c, b, a, d);
	  return (a);
	}

The incomplete machine description entry for this instruction, which
is used when the compiler sees a call to __builtin_block, might look
something like:

	(define_insn "block4"
	  [(set (match_operand:SI 0 "register_operand" "=d")
	        (unspec:SI [(match_operand:SI 1 "register_operand" "d")
	                    (match_operand:SI 2 "register_operand" "d")
	                    (match_operand:SI 3 "register_operand" "d")] 123))]
	  "TARGET_FOO"
	  "block4\\t%0 # %0,%1,%2,%3")

There are a couple problems with this entry, and any advice on the
best way to fix them would be appreciated.

(1) The above entry only tells the compiler that the first operand is an output
operand, so I tried changing it to something like:

	(define_insn "block4"
	  [(set (match_operand:SI 0 "register_operand" "+d")
	        (unspec:SI [(match_operand:SI 1 "register_operand" "+d")
	                    (match_operand:SI 2 "register_operand" "+d")
	                    (match_operand:SI 3 "register_operand" "+d")] 123))]
	  "TARGET_FOO"
	  "block4\\t%0 # %0,%1,%2,%3")

to let it know that all operands are both read/write.  I'm not
entirely sure this is the correct approach.

(2) There doesn't appear to be any obvious way to tell the compiler
that the registers allocated to the operands have to be sequential.

Even harder though, there is another instruction where the registers
have to be "every fourth register", I.E. something like R(N), R(N+4),
R(N+8), R(N+12).  I'm pretty sure that satisfying this requirement is
something that is going to take a little work.  :-)

Thanks for any advice.

-Fred




More information about the Gcc mailing list