Patchwork [MIPS] Support microMIPS HI/QI moves

login
register
mail settings
Submitter Moore, Catherine
Date April 1, 2013, 2:21 p.m.
Message ID <FD3DCEAC5B03E9408544A1E416F11242987BFA71@NA-MBX-01.mgc.mentorg.com>
Download mbox | patch
Permalink /patch/232740/
State New
Headers show

Comments

Moore, Catherine - April 1, 2013, 2:21 p.m.
2013-04-01  Catherine Moore  <clm@codesourcery.com>

        * config/mips/mips.md (*movhi_internal, *movqi_internal): New
        operands.  Record compression.
Richard Sandiford - April 22, 2013, 8:57 p.m.
"Moore, Catherine" <Catherine_Moore@mentor.com> writes:
> 2013-04-01  Catherine Moore  <clm@codesourcery.com>
>
>         * config/mips/mips.md (*movhi_internal, *movqi_internal): New
>         operands.  Record compression.

OK, thanks.

Note that LBU and LHU also appear in *zero_extend<SHORT:mode><GPR:mode>2,
*zero_extendqihi2 and *and<mode>3.

Richard
Maciej W. Rozycki - April 22, 2013, 9:08 p.m.
On Mon, 1 Apr 2013, Moore, Catherine wrote:

>  (define_insn "*movhi_internal"
> -  [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,m,*a,*d")
> -       (match_operand:HI 1 "move_operand"         "d,I,m,dJ,*d*J,*a"))]
> +  [(set (match_operand:HI 0 "nonimmediate_operand" "=d,!u,d,!u,d,ZU,m,*a,*d")
> +       (match_operand:HI 1 "move_operand"         "d,J,I,ZU,m,!u,dJ,*d*J,*a"))]
>    "!TARGET_MIPS16
>     && (register_operand (operands[0], HImode)
>         || reg_or_0_operand (operands[1], HImode))"
>    { return mips_output_move (operands[0], operands[1]); }
> -  [(set_attr "move_type" "move,const,load,store,mtlo,mflo")
> +  [(set_attr "move_type" "move,const,const,load,load,store,store,mtlo,mflo")
> +   (set_attr "compression" "all,micromips,*,micromips,*,micromips,*,*,*")
>     (set_attr "mode" "HI")])

 Dumb question: what's the difference between "all" and "*" in the 
compression attribute?

  Maciej
Moore, Catherine - April 22, 2013, 9:39 p.m.
> -----Original Message-----
> From: Maciej W. Rozycki [mailto:macro@codesourcery.com]
> Sent: Monday, April 22, 2013 5:09 PM
> To: Moore, Catherine
> Cc: rdsandiford@googlemail.com; gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH] [MIPS] Support microMIPS HI/QI moves
> 
> On Mon, 1 Apr 2013, Moore, Catherine wrote:
> 
> >  (define_insn "*movhi_internal"
> > -  [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,m,*a,*d")
> > -       (match_operand:HI 1 "move_operand"         "d,I,m,dJ,*d*J,*a"))]
> > +  [(set (match_operand:HI 0 "nonimmediate_operand"
> "=d,!u,d,!u,d,ZU,m,*a,*d")
> > +       (match_operand:HI 1 "move_operand"
> "d,J,I,ZU,m,!u,dJ,*d*J,*a"))]
> >    "!TARGET_MIPS16
> >     && (register_operand (operands[0], HImode)
> >         || reg_or_0_operand (operands[1], HImode))"
> >    { return mips_output_move (operands[0], operands[1]); }
> > -  [(set_attr "move_type" "move,const,load,store,mtlo,mflo")
> > +  [(set_attr "move_type"
> "move,const,const,load,load,store,store,mtlo,mflo")
> > +   (set_attr "compression"
> > + "all,micromips,*,micromips,*,micromips,*,*,*")
> >     (set_attr "mode" "HI")])
> 
>  Dumb question: what's the difference between "all" and "*" in the
> compression attribute?
> 
Hi Maciej, 

The port defines the compression and enabled attributes like this:

(define_attr "compression" "none,all,micromips"
  (const_string "none")) 

(define_attr "enabled" "no,yes"
  (if_then_else (ior (eq_attr "compression" "all,none")
                     (and (eq_attr "compression" "micromips")
                          (match_test "TARGET_MICROMIPS")))
                (const_string "yes")
                (const_string "no")))

The "all" setting is used for register-to-register moves where the alternative is compressed if compiling for micromips code or uncompressed otherwise.  
The default ("*") is none meaning this particular alternative will never be compressed.
Catherine
Maciej W. Rozycki - May 1, 2013, 4:13 p.m.
On Mon, 22 Apr 2013, Moore, Catherine wrote:

> >  Dumb question: what's the difference between "all" and "*" in the
> > compression attribute?
> 
> The port defines the compression and enabled attributes like this:
> 
> (define_attr "compression" "none,all,micromips"
>   (const_string "none")) 
> 
> (define_attr "enabled" "no,yes"
>   (if_then_else (ior (eq_attr "compression" "all,none")
>                      (and (eq_attr "compression" "micromips")
>                           (match_test "TARGET_MICROMIPS")))
>                 (const_string "yes")
>                 (const_string "no")))
> 
> The "all" setting is used for register-to-register moves where the 
> alternative is compressed if compiling for micromips code or 
> uncompressed otherwise.
> 
> The default ("*") is none meaning this particular alternative will never 
> be compressed.

 Fair enough, thanks.  I find it a bit backwards with "*" being the usual 
glob character and therefore intuitively interpreted as "all", but I can 
recognise the space saving this solution gives a benefit of.

  Maciej

Patch

Index: mips.md
===================================================================
--- mips.md     (revision 197114)
+++ mips.md     (working copy)
@@ -4538,13 +4538,14 @@ 
 })

 (define_insn "*movhi_internal"
-  [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,m,*a,*d")
-       (match_operand:HI 1 "move_operand"         "d,I,m,dJ,*d*J,*a"))]
+  [(set (match_operand:HI 0 "nonimmediate_operand" "=d,!u,d,!u,d,ZU,m,*a,*d")
+       (match_operand:HI 1 "move_operand"         "d,J,I,ZU,m,!u,dJ,*d*J,*a"))]
   "!TARGET_MIPS16
    && (register_operand (operands[0], HImode)
        || reg_or_0_operand (operands[1], HImode))"
   { return mips_output_move (operands[0], operands[1]); }
-  [(set_attr "move_type" "move,const,load,store,mtlo,mflo")
+  [(set_attr "move_type" "move,const,const,load,load,store,store,mtlo,mflo")
+   (set_attr "compression" "all,micromips,*,micromips,*,micromips,*,*,*")
    (set_attr "mode" "HI")])

 (define_insn "*movhi_mips16"
@@ -4613,13 +4614,14 @@ 
 })

 (define_insn "*movqi_internal"
-  [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,m,*a,*d")
-       (match_operand:QI 1 "move_operand"         "d,I,m,dJ,*d*J,*a"))]
+  [(set (match_operand:QI 0 "nonimmediate_operand" "=d,!u,d,!u,d,ZV,m,*a,*d")
+       (match_operand:QI 1 "move_operand"         "d,J,I,ZW,m,!u,dJ,*d*J,*a"))]
   "!TARGET_MIPS16
    && (register_operand (operands[0], QImode)
        || reg_or_0_operand (operands[1], QImode))"
   { return mips_output_move (operands[0], operands[1]); }
-  [(set_attr "move_type" "move,const,load,store,mtlo,mflo")
+  [(set_attr "move_type" "move,const,const,load,load,store,store,mtlo,mflo")
+   (set_attr "compression" "all,micromips,*,micromips,*,micromips,*,*,*")
    (set_attr "mode" "QI")])

 (define_insn "*movqi_mips16"