new mul* patterns "U" constraint in rl78

Message ID
State New
Headers show

Commit Message

Kaushik Phatak June 10, 2013, 7:30 a.m.
Hi DJ,

> Uses a "U" constraint. What should that constraint do?  Could you post a 
> patch to add it?

The U constraint was part of a source tree we worked on previously. I have
provided the patch for it below.
I have also set the valloc attribute for the multiplication insns to 'umul'.
Would that be the correct setting as 'macax' is used for the other SI 
multiplication insns which seem to also include accumulation?

Please let me know if OK.

Thanks & Regards,

2013-06-10  Kaushik Phatak  <>
	* config/rl78/ (U): New constraint.
	* config/rl78/ (mulqi3_rl78,mulhi3_rl78,mulhi3_g13): Add
	valloc attribute.


DJ Delorie June 10, 2013, 6:49 p.m. | #1
"umul" is used when the insn takes two operands in A and X, and
computes a value into AX.  This is similar to "op2" which, in general,
does AX = AX op (other register or memory).  The devirtualizer will
arrange for the right values to be in real registers for these.

"macax" is used when the insn pattern itself reads from two virtual
registers and writes to a virtual register (i.e. V = V op V), but
clobbers AX anx BC in the process.  The devirutalizer does not need to
devirtualize these insns.


Index: gcc/config/rl78/
--- gcc/config/rl78/	(revision 199879)
+++ gcc/config/rl78/	(working copy)
@@ -256,6 +256,19 @@ 
        (match_test "!rl78_far_p (op) && rl78_as_legitimate_address (VOIDmode, XEXP (op, 0), true, ADDR_SPACE_GENERIC)"))
+(define_memory_constraint "U"
+  "memory references valid with mov to/from a/ax"
+  (and (match_code "mem")
+       (match_test "rl78_virt_insns_ok ()
+|| satisfies_constraint_Wab (op)
+|| satisfies_constraint_Wbc (op)
+|| satisfies_constraint_Wde (op)
+|| satisfies_constraint_Wd2 (op)
+|| satisfies_constraint_Whl (op)
+|| satisfies_constraint_Wh1 (op)
+|| satisfies_constraint_Whb (op)
+|| satisfies_constraint_Ws1 (op)
+|| satisfies_constraint_Wfr (op) ")))
 (define_memory_constraint "Qbi"
   "built-in compare types"
Index: gcc/config/rl78/
--- gcc/config/rl78/	(revision 199879)
+++ gcc/config/rl78/	(working copy)
@@ -276,6 +276,7 @@ 
 	mov    a, x
 	mov    %h0, a
 	; end of mulqi macro"
+  [(set_attr "valloc" "umul")]
 (define_insn "*mulhi3_rl78"
@@ -290,6 +291,7 @@ 
 	mulhu   ; bcax = bc * ax
 	movw    %h0, ax
 	; end of mulhi macro"
+  [(set_attr "valloc" "umul")]
 (define_insn "*mulhi3_g13"
@@ -309,6 +311,7 @@ 
 	movw    ax, 0xffff6     ; MDBL
 	movw    %h0, ax
         ; end of mulhi macro"
+  [(set_attr "valloc" "umul")]
 ;; 0xFFFF0 is MACR(L).  0xFFFF2 is MACR(H) but we don't care about it