This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 1/3] S/390: New `enabled' insn attribute


Hello,

when enhancing a back end with new instructions it is often necessary
to copy complex insn definitions just to add a single instruction.

A good example in the S/390 back end is the movdi 64bit pattern.
Different architecture levels have added new instructions and in order
to give reload the full selection we had to copy the whole pattern
definition, provide it under a new name and use TARGET_CPU macros in
order to enable just the most general for the respective architecture.

So we have a "*movdi_64" for the first 64bit machine, a
"*movdi_64extimm" for a later version which is capable of dealing with
bigger immdediate values and a "*movdi_64dfp" for the last generation
which provides instructions to copy floating point values between fprs
and gprs.

With this and the following two patches I want to propose the
introduction of an `enabled' insn attribute which is checked whenever
the insn constraints are evaluated.  An insn alternative wherefor the
`enabled' attribute is false is never considered matching by reload
and recog.

It is up to the back end to define the attribute.  The attached patch
shows an implemenation for the S/390 back end defining the attribute
based on the enabled architecture level. The patch also merges the
most obvious patterns using the new attribute but there are several
more patterns which could be merged.

Bootstrapped with the two follow on patches on s390 and s390x.

Ok for mainline?

Bye,

-Andreas-


2007-08-28  Andreas Krebbel  <krebbel1@de.ibm.com>

	* config/s390/s390.md ("cpu_facility", "enabled"): Attribute
	definitions added.
	("*movdi_64dfp", "*movdi_64extimm", "*movdi_64"): Merged into
	"*movdi_64".
	("*anddi3_extimm", "*anddi3"): Merged into "*anddi3".
	("*iordi3_extimm", "*iordi3"): Merged into "*iordi3".
	("*xordi3_extimm", "*xordi3"): Merged into "*xordi3".


Index: gcc/config/s390/s390.md
===================================================================
*** gcc/config/s390/s390.md.orig	2007-08-27 16:06:24.000000000 +0200
--- gcc/config/s390/s390.md	2007-08-27 16:07:02.000000000 +0200
***************
*** 231,236 ****
--- 231,264 ----
  (define_attr "cpu" "g5,g6,z900,z990,z9_109"
    (const (symbol_ref "s390_tune")))
  
+ (define_attr "cpu_facility" "standard,ieee,zarch,longdisp,extimm,dfp"
+   (const_string "standard"))
+ 
+ (define_attr "enabled" ""
+   (cond [(eq_attr "cpu_facility" "standard")
+ 	 (const_int 1)
+ 
+          (and (eq_attr "cpu_facility" "ieee")
+ 	      (ne (symbol_ref "TARGET_CPU_IEEE_FLOAT") (const_int 0)))
+ 	 (const_int 1)
+ 
+ 	 (and (eq_attr "cpu_facility" "zarch")
+ 	      (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0)))
+ 	 (const_int 1)
+ 
+ 	 (and (eq_attr "cpu_facility" "longdisp")
+ 	      (ne (symbol_ref "TARGET_CPU_LONG_DISPLACEMENT") (const_int 0)))
+ 	 (const_int 1)
+ 
+          (and (eq_attr "cpu_facility" "extimm")
+ 	      (ne (symbol_ref "TARGET_CPU_EXTIMM") (const_int 0)))
+ 	 (const_int 1)
+ 
+          (and (eq_attr "cpu_facility" "dfp")
+ 	      (ne (symbol_ref "TARGET_CPU_DFP") (const_int 0)))
+ 	 (const_int 1)]
+ 	(const_int 0)))
+ 
  ;; Pipeline description for z900.  For lack of anything better,
  ;; this description is also used for the g5 and g6.
  (include "2064.md")
***************
*** 980,993 ****
     [(set_attr "op_type" "RIL")
      (set_attr "type"    "larl")])
  
! (define_insn "*movdi_64dfp"
    [(set (match_operand:DI 0 "nonimmediate_operand"
                              "=d,d,d,d,d,d,d,d,f,d,d,d,d,
                               m,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
          (match_operand:DI 1 "general_operand"
                              "K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,L,d,m,
                               d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
!   "TARGET_64BIT && TARGET_DFP"
    "@
     lghi\t%0,%h1
     llihh\t%0,%i1
--- 1008,1021 ----
     [(set_attr "op_type" "RIL")
      (set_attr "type"    "larl")])
  
! (define_insn "*movdi_64"
    [(set (match_operand:DI 0 "nonimmediate_operand"
                              "=d,d,d,d,d,d,d,d,f,d,d,d,d,
                               m,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
          (match_operand:DI 1 "general_operand"
                              "K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,L,d,m,
                               d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
!   "TARGET_64BIT"
    "@
     lghi\t%0,%h1
     llihh\t%0,%i1
***************
*** 1016,1087 ****
    [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RXY,RRE,RXY,RXY,
                          RR,RX,RXY,RX,RXY,*,*,RS,RS,SS")
     (set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,la,lr,load,store,
!                      floaddf,floaddf,floaddf,fstoredf,fstoredf,*,*,*,*,*")])
! 
! (define_insn "*movdi_64extimm"
!   [(set (match_operand:DI 0 "nonimmediate_operand"
!                             "=d,d,d,d,d,d,d,d,d,d,d,m,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
!         (match_operand:DI 1 "general_operand"
!                             "K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,L,d,m,d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
!   "TARGET_64BIT && TARGET_EXTIMM"
!   "@
!    lghi\t%0,%h1
!    llihh\t%0,%i1
!    llihl\t%0,%i1
!    llilh\t%0,%i1
!    llill\t%0,%i1
!    lgfi\t%0,%1
!    llihf\t%0,%k1
!    llilf\t%0,%k1
!    lay\t%0,%a1
!    lgr\t%0,%1
!    lg\t%0,%1
!    stg\t%1,%0
!    ldr\t%0,%1
!    ld\t%0,%1
!    ldy\t%0,%1
!    std\t%1,%0
!    stdy\t%1,%0
!    #
!    #
!    stam\t%1,%N1,%S0
!    lam\t%0,%N0,%S1
!    #"
!   [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RXY,RRE,RXY,RXY,
!                         RR,RX,RXY,RX,RXY,*,*,RS,RS,SS")
!    (set_attr "type" "*,*,*,*,*,*,*,*,la,lr,load,store,
!                      floaddf,floaddf,floaddf,fstoredf,fstoredf,*,*,*,*,*")])
! 
! (define_insn "*movdi_64"
!   [(set (match_operand:DI 0 "nonimmediate_operand"
!                             "=d,d,d,d,d,d,d,d,m,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
!         (match_operand:DI 1 "general_operand"
!                             "K,N0HD0,N1HD0,N2HD0,N3HD0,L,d,m,d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
!   "TARGET_64BIT && !TARGET_EXTIMM"
!   "@
!    lghi\t%0,%h1
!    llihh\t%0,%i1
!    llihl\t%0,%i1
!    llilh\t%0,%i1
!    llill\t%0,%i1
!    lay\t%0,%a1
!    lgr\t%0,%1
!    lg\t%0,%1
!    stg\t%1,%0
!    ldr\t%0,%1
!    ld\t%0,%1
!    ldy\t%0,%1
!    std\t%1,%0
!    stdy\t%1,%0
!    #
!    #
!    stam\t%1,%N1,%S0
!    lam\t%0,%N0,%S1
!    #"
!   [(set_attr "op_type" "RI,RI,RI,RI,RI,RXY,RRE,RXY,RXY,
!                         RR,RX,RXY,RX,RXY,*,*,RS,RS,SS")
!    (set_attr "type" "*,*,*,*,*,la,lr,load,store,
!                      floaddf,floaddf,floaddf,fstoredf,fstoredf,*,*,*,*,*")])
  
  (define_split
    [(set (match_operand:DI 0 "register_operand" "")
--- 1044,1052 ----
    [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RXY,RRE,RXY,RXY,
                          RR,RX,RXY,RX,RXY,*,*,RS,RS,SS")
     (set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,la,lr,load,store,
!                      floaddf,floaddf,floaddf,fstoredf,fstoredf,*,*,*,*,*")
!    (set_attr "cpu_facility" "*,*,*,*,*,extimm,extimm,extimm,dfp,dfp,longdisp,
!                              *,*,*,*,*,longdisp,*,longdisp,*,*,*,*,*")])
  
  (define_split
    [(set (match_operand:DI 0 "register_operand" "")
***************
*** 5058,5071 ****
     ng\t%0,%2"
    [(set_attr "op_type"  "RRE,RXY")])
  
! (define_insn "*anddi3_extimm"
    [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,d,d,AQ,Q")
          (and:DI (match_operand:DI 1 "nonimmediate_operand"
                                      "%d,o,0,0,0,0,0,0,0,0,0,0")
                  (match_operand:DI 2 "general_operand"
                                      "M,M,N0HDF,N1HDF,N2HDF,N3HDF,N0SDF,N1SDF,d,m,NxQDF,Q")))
     (clobber (reg:CC CC_REGNUM))]
!   "TARGET_64BIT && TARGET_EXTIMM && s390_logical_operator_ok_p (operands)"
    "@
     #
     #
--- 5023,5036 ----
     ng\t%0,%2"
    [(set_attr "op_type"  "RRE,RXY")])
  
! (define_insn "*anddi3"
    [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,d,d,AQ,Q")
          (and:DI (match_operand:DI 1 "nonimmediate_operand"
                                      "%d,o,0,0,0,0,0,0,0,0,0,0")
                  (match_operand:DI 2 "general_operand"
                                      "M,M,N0HDF,N1HDF,N2HDF,N3HDF,N0SDF,N1SDF,d,m,NxQDF,Q")))
     (clobber (reg:CC CC_REGNUM))]
!   "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
    "@
     #
     #
***************
*** 5079,5106 ****
     ng\t%0,%2
     #
     #"
!   [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RIL,RIL,RRE,RXY,SI,SS")])
! 
! (define_insn "*anddi3"
!   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,AQ,Q")
!         (and:DI (match_operand:DI 1 "nonimmediate_operand"
!                                     "%d,o,0,0,0,0,0,0,0,0")
!                 (match_operand:DI 2 "general_operand"
!                                     "M,M,N0HDF,N1HDF,N2HDF,N3HDF,d,m,NxQDF,Q")))
!    (clobber (reg:CC CC_REGNUM))]
!   "TARGET_64BIT && !TARGET_EXTIMM && s390_logical_operator_ok_p (operands)"
!   "@
!    #
!    #
!    nihh\t%0,%j2
!    nihl\t%0,%j2
!    nilh\t%0,%j2
!    nill\t%0,%j2
!    ngr\t%0,%2
!    ng\t%0,%2
!    #
!    #"
!   [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RRE,RXY,SI,SS")])
  
  (define_split
    [(set (match_operand:DI 0 "s_operand" "")
--- 5044,5051 ----
     ng\t%0,%2
     #
     #"
!   [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RIL,RIL,RRE,RXY,SI,SS")
!    (set_attr "cpu_facility" "*,*,*,*,*,*,extimm,extimm,*,*,*,*")])
  
  (define_split
    [(set (match_operand:DI 0 "s_operand" "")
***************
*** 5361,5373 ****
     og\t%0,%2"
    [(set_attr "op_type"  "RRE,RXY")])
  
! (define_insn "*iordi3_extimm"
    [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,AQ,Q")
          (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0,0,0,0,0")
                  (match_operand:DI 2 "general_operand"
                                      "N0HD0,N1HD0,N2HD0,N3HD0,N0SD0,N1SD0,d,m,NxQD0,Q")))
     (clobber (reg:CC CC_REGNUM))]
!   "TARGET_64BIT && TARGET_EXTIMM && s390_logical_operator_ok_p (operands)"
    "@
     oihh\t%0,%i2
     oihl\t%0,%i2
--- 5306,5318 ----
     og\t%0,%2"
    [(set_attr "op_type"  "RRE,RXY")])
  
! (define_insn "*iordi3"
    [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,AQ,Q")
          (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0,0,0,0,0")
                  (match_operand:DI 2 "general_operand"
                                      "N0HD0,N1HD0,N2HD0,N3HD0,N0SD0,N1SD0,d,m,NxQD0,Q")))
     (clobber (reg:CC CC_REGNUM))]
!   "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
    "@
     oihh\t%0,%i2
     oihl\t%0,%i2
***************
*** 5379,5403 ****
     og\t%0,%2
     #
     #"
!   [(set_attr "op_type"  "RI,RI,RI,RI,RIL,RIL,RRE,RXY,SI,SS")])
! 
! (define_insn "*iordi3"
!   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,AQ,Q")
!         (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0,0,0")
!                 (match_operand:DI 2 "general_operand"
!                                     "N0HD0,N1HD0,N2HD0,N3HD0,d,m,NxQD0,Q")))
!    (clobber (reg:CC CC_REGNUM))]
!   "TARGET_64BIT && !TARGET_EXTIMM && s390_logical_operator_ok_p (operands)"
!   "@
!    oihh\t%0,%i2
!    oihl\t%0,%i2
!    oilh\t%0,%i2
!    oill\t%0,%i2
!    ogr\t%0,%2
!    og\t%0,%2
!    #
!    #"
!   [(set_attr "op_type"  "RI,RI,RI,RI,RRE,RXY,SI,SS")])
  
  (define_split
    [(set (match_operand:DI 0 "s_operand" "")
--- 5324,5331 ----
     og\t%0,%2
     #
     #"
!   [(set_attr "op_type"  "RI,RI,RI,RI,RIL,RIL,RRE,RXY,SI,SS")
!    (set_attr "cpu_facility" "*,*,*,*,extimm,extimm,*,*,*,*")])
  
  (define_split
    [(set (match_operand:DI 0 "s_operand" "")
***************
*** 5651,5662 ****
     xr\t%0,%2"
    [(set_attr "op_type"  "RRE,RXY")])
  
! (define_insn "*xordi3_extimm"
    [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,AQ,Q")
          (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0")
                  (match_operand:DI 2 "general_operand" "N0SD0,N1SD0,d,m,NxQD0,Q")))
     (clobber (reg:CC CC_REGNUM))]
!   "TARGET_64BIT && TARGET_EXTIMM && s390_logical_operator_ok_p (operands)"
    "@
     xihf\t%0,%k2
     xilf\t%0,%k2
--- 5579,5590 ----
     xr\t%0,%2"
    [(set_attr "op_type"  "RRE,RXY")])
  
! (define_insn "*xordi3"
    [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,AQ,Q")
          (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0")
                  (match_operand:DI 2 "general_operand" "N0SD0,N1SD0,d,m,NxQD0,Q")))
     (clobber (reg:CC CC_REGNUM))]
!   "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
    "@
     xihf\t%0,%k2
     xilf\t%0,%k2
***************
*** 5664,5683 ****
     xg\t%0,%2
     #
     #"
!   [(set_attr "op_type"  "RIL,RIL,RRE,RXY,SI,SS")])
! 
! (define_insn "*xordi3"
!   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,AQ,Q")
!         (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0")
!                 (match_operand:DI 2 "general_operand" "d,m,NxQD0,Q")))
!    (clobber (reg:CC CC_REGNUM))]
!   "TARGET_64BIT && !TARGET_EXTIMM && s390_logical_operator_ok_p (operands)"
!   "@
!    xgr\t%0,%2
!    xg\t%0,%2
!    #
!    #"
!   [(set_attr "op_type"  "RRE,RXY,SI,SS")])
  
  (define_split
    [(set (match_operand:DI 0 "s_operand" "")
--- 5592,5599 ----
     xg\t%0,%2
     #
     #"
!   [(set_attr "op_type"  "RIL,RIL,RRE,RXY,SI,SS")
!    (set_attr "cpu_facility" "extimm,extimm,*,*,*,*")])
  
  (define_split
    [(set (match_operand:DI 0 "s_operand" "")


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]