From patchwork Wed Jun 27 18:31:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 935663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480572-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="cBrFMY0y"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41GBMX63QPz9s31 for ; Thu, 28 Jun 2018 04:31:51 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=uZimw/g5S4/zqzRKese8TImmA/UHrix6abJNcuFDoaTcWIKVQabFG pyhpdVhq0+tBpZioQsniRPX5ykW3+yyT0xG3c2U5jBny9t//uCzRmMDJJa7GNIad JaKsUnQG1RgN7W0MBLB3oxCjPH/oeGwj5sn2/eMeSxvzGG1vKLK+SI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; s= default; bh=X7uE8mCQOVJXsmqjn2jbqCiDsUA=; b=cBrFMY0ygQ9JIDIcxQub qXD75Cu2l/7GJQRrZcr5hp/B1IUugJC+D9Dn0uxpzpMzaiXK+Hx7LPHj52p3lbZM 2ObXLvH+ULrDu44dZnZpYEJySPNg0YUtb7+YUTOc1fxQ34rrphoEJC618Cex4Cfd vxPnypJ4mTbmbQ5CxzNu8mE= Received: (qmail 67959 invoked by alias); 27 Jun 2018 18:31:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 67855 invoked by uid 89); 27 Jun 2018 18:31:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=vc, rig, sr, attr X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Jun 2018 18:31:28 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D53480F94 for ; Wed, 27 Jun 2018 18:31:27 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-5.rdu2.redhat.com [10.10.112.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C28360498 for ; Wed, 27 Jun 2018 18:31:26 +0000 (UTC) From: Jeff Law Subject: [committed] [1/3] Converting the v850 port away from cc0 -- removing most of cc0 handling Openpgp: preference=signencrypt To: gcc-patches Message-ID: <5793e39c-169c-b602-af42-81b1925abecd@redhat.com> Date: Wed, 27 Jun 2018 12:31:24 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 X-IsSubscribed: yes This is a fairly mechanical change -- it removes a large amount of the cc0 machinery, but not all of it. It's not really meant to stand independently of the subsequent changes. I've broken it out merely to aid anyone who perhaps wants to see the more significant changes in subsequent patches without the noise of all the mechanical stuff. This also fixes a number of trivial style nits in v850.md. While I have built gcc, libgcc and newlib with this change, again, it's not really meant to be used independently. Jeff * config/v850/v850-modes.def (CCZ, CCNZ): Add new modes. * config/v850/v850.c (notice_update_cc): Remove. * config/v850/v850.h (CC_OVERFLOW_UNUSABLE): Remove (CC_NO_CARRY): Likewise. (NOTICE_UPDATE_CC): Define to nothing. * config/v850/v850.md: Remove block comment on cc0 handling Remove "cc" attribute from all patterns. Remove cc_status handling from all patterns. Minor formatting fixes. diff --git a/gcc/config/v850/v850-modes.def b/gcc/config/v850/v850-modes.def index ed37c79..5503d6a 100644 --- a/gcc/config/v850/v850-modes.def +++ b/gcc/config/v850/v850-modes.def @@ -18,6 +18,8 @@ along with GCC; see the file COPYING3. If not see . */ +CC_MODE (CCZ); +CC_MODE (CCNZ); CC_MODE (CC_FPU_LT); CC_MODE (CC_FPU_LE); CC_MODE (CC_FPU_GT); diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c index 720cce8..e184718 100644 --- a/gcc/config/v850/v850.c +++ b/gcc/config/v850/v850.c @@ -1985,55 +1985,6 @@ expand_epilogue (void) v850_interrupt_p = FALSE; } -/* Update the condition code from the insn. */ -void -notice_update_cc (rtx body, rtx_insn *insn) -{ - switch (get_attr_cc (insn)) - { - case CC_NONE: - /* Insn does not affect CC at all. */ - break; - - case CC_NONE_0HIT: - /* Insn does not change CC, but the 0'th operand has been changed. */ - if (cc_status.value1 != 0 - && reg_overlap_mentioned_p (recog_data.operand[0], cc_status.value1)) - cc_status.value1 = 0; - break; - - case CC_SET_ZN: - /* Insn sets the Z,N flags of CC to recog_data.operand[0]. - V,C is in an unusable state. */ - CC_STATUS_INIT; - cc_status.flags |= CC_OVERFLOW_UNUSABLE | CC_NO_CARRY; - cc_status.value1 = recog_data.operand[0]; - break; - - case CC_SET_ZNV: - /* Insn sets the Z,N,V flags of CC to recog_data.operand[0]. - C is in an unusable state. */ - CC_STATUS_INIT; - cc_status.flags |= CC_NO_CARRY; - cc_status.value1 = recog_data.operand[0]; - break; - - case CC_COMPARE: - /* The insn is a compare instruction. */ - CC_STATUS_INIT; - cc_status.value1 = SET_SRC (body); - break; - - case CC_CLOBBER: - /* Insn doesn't leave CC in a usable state. */ - CC_STATUS_INIT; - break; - - default: - break; - } -} - /* Retrieve the data area that has been chosen for the given decl. */ v850_data_area diff --git a/gcc/config/v850/v850.h b/gcc/config/v850/v850.h index 2e737a8..96bddc2 100644 --- a/gcc/config/v850/v850.h +++ b/gcc/config/v850/v850.h @@ -567,19 +567,7 @@ struct cum_arg { int nbytes; }; #define SELECT_CC_MODE(OP, X, Y) v850_select_cc_mode (OP, X, Y) -/* Tell final.c how to eliminate redundant test instructions. */ - -/* Here we define machine-dependent flags and fields in cc_status - (see `conditions.h'). No extra ones are needed for the VAX. */ - -/* Store in cc_status the expressions - that the condition codes will describe - after execution of an instruction whose pattern is EXP. - Do not alter them if the instruction would not alter the cc's. */ - -#define CC_OVERFLOW_UNUSABLE 0x200 -#define CC_NO_CARRY CC_NO_OVERFLOW -#define NOTICE_UPDATE_CC(EXP, INSN) notice_update_cc(EXP, INSN) +#define NOTICE_UPDATE_CC(EXP, INSN) /* Nonzero if access to memory by bytes or half words is no faster than accessing full words. */ diff --git a/gcc/config/v850/v850.md b/gcc/config/v850/v850.md index 67d9063..0fad9ea 100644 --- a/gcc/config/v850/v850.md +++ b/gcc/config/v850/v850.md @@ -81,17 +81,6 @@ (const_string "v850e3v5")] (const_string "none"))) -;; Condition code settings. -;; none - insn does not affect cc -;; none_0hit - insn does not affect cc but it does modify operand 0 -;; This attribute is used to keep track of when operand 0 changes. -;; See the description of NOTICE_UPDATE_CC for more info. -;; set_znv - sets z,n,v to usable values; c is unknown. -;; set_zn - sets z,n to usable values; v,c is unknown. -;; compare - compare instruction -;; clobber - value of cc is unknown -(define_attr "cc" "none,none_0hit,set_z,set_zn,set_znv,compare,clobber" - (const_string "clobber")) ;; Function units for the V850. As best as I can tell, there's ;; a traditional memory load/use stall as well as a stall if @@ -120,8 +109,7 @@ (match_operand 2 "disp23_operand" "W")))))] "TARGET_V850E2V3_UP" "ld.b %2[%1],%0" - [(set_attr "length" "4") - (set_attr "cc" "none_0hit")]) + [(set_attr "length" "4")]) (define_insn "unsign23byte_load" [(set (match_operand:SI 0 "register_operand" "=r") @@ -130,8 +118,7 @@ (match_operand 2 "disp23_operand" "W")))))] "TARGET_V850E2V3_UP" "ld.bu %2[%1],%0" - [(set_attr "length" "4") - (set_attr "cc" "none_0hit")]) + [(set_attr "length" "4")]) (define_insn "sign23hword_load" [(set (match_operand:SI 0 "register_operand" "=r") @@ -140,8 +127,7 @@ (match_operand 2 "disp23_operand" "W")))))] "TARGET_V850E2V3_UP" "ld.h %2[%1],%0" - [(set_attr "length" "4") - (set_attr "cc" "none_0hit")]) + [(set_attr "length" "4")]) (define_insn "unsign23hword_load" [(set (match_operand:SI 0 "register_operand" "=r") @@ -150,8 +136,7 @@ (match_operand 2 "disp23_operand" "W")))))] "TARGET_V850E2V3_UP" "ld.hu %2[%1],%0" - [(set_attr "length" "4") - (set_attr "cc" "none_0hit")]) + [(set_attr "length" "4")]) (define_insn "23word_load" [(set (match_operand:SI 0 "register_operand" "=r") @@ -159,8 +144,7 @@ (match_operand 2 "disp23_operand" "W"))))] "TARGET_V850E2V3_UP" "ld.w %2[%1],%0" - [(set_attr "length" "4") - (set_attr "cc" "none_0hit")]) + [(set_attr "length" "4")]) (define_insn "23byte_store" [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "r") @@ -168,8 +152,7 @@ (match_operand:QI 2 "register_operand" "r"))] "TARGET_V850E2V3_UP" "st.b %2,%1[%0]" - [(set_attr "length" "4") - (set_attr "cc" "none_0hit")]) + [(set_attr "length" "4")]) (define_insn "23hword_store" [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "r") @@ -177,8 +160,7 @@ (match_operand:HI 2 "register_operand" "r"))] "TARGET_V850E2V3_UP" "st.h %2,%1[%0]" - [(set_attr "length" "4") - (set_attr "cc" "none_0hit")]) + [(set_attr "length" "4")]) (define_insn "23word_store" [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "r") @@ -186,8 +168,7 @@ (match_operand:SI 2 "register_operand" "r"))] "TARGET_V850E2V3_UP" "st.w %2,%1[%0]" - [(set_attr "length" "4") - (set_attr "cc" "none_0hit")]) + [(set_attr "length" "4")]) ;; movdi @@ -221,9 +202,7 @@ || (register_operand (operands[0], DImode) && register_operand (operands[1], DImode))" { return v850_gen_movdi (operands); } [(set_attr "length" "4,12,12") - (set_attr "cc" "none_0hit") - (set_attr "type" "other,load,store")] -) + (set_attr "type" "other,load,store")]) ;; movqi @@ -247,7 +226,6 @@ return output_move_single (operands); } [(set_attr "length" "2,4,2,2,4,4,4") - (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit") (set_attr "type" "other,other,load,other,load,store,store")]) ;; movhi @@ -272,7 +250,6 @@ return output_move_single (operands); } [(set_attr "length" "2,4,2,2,4,4,4") - (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit") (set_attr "type" "other,other,load,other,load,store,store")]) ;; movsi and helpers @@ -283,7 +260,6 @@ "" "movhi hi(%1),%.,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "other")]) (define_insn "*movsi_lo" @@ -293,7 +269,6 @@ "" "movea lo(%2),%1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "other")]) (define_expand "movsi" @@ -348,7 +323,6 @@ return output_move_single (operands); } [(set_attr "length" "2,4,4,2,2,4,4,4,4,6") - (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit") (set_attr "type" "other,other,other,load,other,load,other,store,store,other")]) (define_insn "*movsi_internal" @@ -360,7 +334,6 @@ return output_move_single (operands); } [(set_attr "length" "2,4,4,2,2,4,4,4,4") - (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit") (set_attr "type" "other,other,other,load,other,load,store,store,other")]) (define_insn "*movsf_internal" @@ -372,7 +345,6 @@ return output_move_single (operands); } [(set_attr "length" "2,4,4,8,2,2,4,4,4,8") - (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit") (set_attr "type" "other,other,other,other,load,other,load,store,store,other")]) ;; ---------------------------------------------------------------------- @@ -387,8 +359,7 @@ (const_int 0)))] "" "tst1 %1,%0" - [(set_attr "length" "4") - (set_attr "cc" "clobber")]) + [(set_attr "length" "4")]) ;; This replaces ld.b;sar;andi with tst1;setf nz. @@ -445,8 +416,7 @@ "@ cmp %1,%0 cmp %1,%0" - [(set_attr "length" "2,2") - (set_attr "cc" "compare")]) + [(set_attr "length" "2,2")]) (define_expand "cbranchsf4" [(set (pc) @@ -499,8 +469,7 @@ gcc_unreachable (); } [(set_attr "length" "12") - (set_attr "type" "fpu")] -) + (set_attr "type" "fpu")]) (define_expand "cbranchdf4" [(set (pc) @@ -553,8 +522,7 @@ gcc_unreachable (); } [(set_attr "length" "12") - (set_attr "type" "fpu")] -) + (set_attr "type" "fpu")]) (define_expand "cmpsf" [(set (reg:CC CC_REGNUM) @@ -593,8 +561,7 @@ add %2,%0 addi %2,%1,%0 addi %O2(%P2),%1,%0" - [(set_attr "length" "2,4,4") - (set_attr "cc" "set_zn,set_zn,set_zn")]) + [(set_attr "length" "2,4,4")]) ;; ---------------------------------------------------------------------- ;; SUBTRACT INSTRUCTIONS @@ -609,8 +576,7 @@ "@ sub %2,%0 subr %1,%0" - [(set_attr "length" "2,2") - (set_attr "cc" "set_zn,set_zn")]) + [(set_attr "length" "2,2")]) (define_insn "negsi2" [(set (match_operand:SI 0 "register_operand" "=r") @@ -618,8 +584,7 @@ (clobber (reg:CC CC_REGNUM))] "" "subr %.,%0" - [(set_attr "length" "2") - (set_attr "cc" "set_zn")]) + [(set_attr "length" "2")]) ;; ---------------------------------------------------------------------- ;; MULTIPLY INSTRUCTIONS @@ -647,7 +612,6 @@ "" "mulh %2,%0" [(set_attr "length" "2") - (set_attr "cc" "none_0hit") (set_attr "type" "mult")]) (define_insn "mulhisi3_internal2" @@ -660,7 +624,6 @@ mulh %2,%0 mulhi %2,%1,%0" [(set_attr "length" "2,4") - (set_attr "cc" "none_0hit,none_0hit") (set_attr "type" "mult")]) ;; ??? The scheduling info is probably wrong. @@ -680,7 +643,6 @@ "(TARGET_V850E_UP)" "mul %2,%1,%." [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "mult")]) ;; ---------------------------------------------------------------------- @@ -709,7 +671,6 @@ return "div %2,%0,%3"; } [(set_attr "length" "4") - (set_attr "cc" "clobber") (set_attr "type" "div")]) (define_insn "udivmodsi4" @@ -728,7 +689,6 @@ return "divu %2,%0,%3"; } [(set_attr "length" "4") - (set_attr "cc" "clobber") (set_attr "type" "div")]) ;; ??? There is a 2 byte instruction for generating only the quotient. @@ -745,7 +705,6 @@ "TARGET_V850E_UP" "sxh %0\n\tdivh %2,%0,%3" [(set_attr "length" "6") - (set_attr "cc" "clobber") (set_attr "type" "div")]) ;; The half word needs to be zero/sign extended to 32 bits before doing @@ -762,7 +721,6 @@ "TARGET_V850E_UP" "zxh %0\n\tdivhu %2,%0,%3" [(set_attr "length" "6") - (set_attr "cc" "clobber") (set_attr "type" "div")]) ;; ---------------------------------------------------------------------- @@ -784,7 +742,6 @@ return ""; } [(set_attr "length" "4") - (set_attr "cc" "clobber") (set_attr "type" "bit1")]) (define_insn "*v850_clr1_2" @@ -806,7 +763,6 @@ return ""; } [(set_attr "length" "4") - (set_attr "cc" "clobber") (set_attr "type" "bit1")]) (define_insn "*v850_clr1_3" @@ -827,7 +783,6 @@ return ""; } [(set_attr "length" "4") - (set_attr "cc" "clobber") (set_attr "type" "bit1")]) (define_insn "andsi3" @@ -840,8 +795,7 @@ and %2,%0 and %.,%0 andi %2,%1,%0" - [(set_attr "length" "2,2,4") - (set_attr "cc" "set_zn")]) + [(set_attr "length" "2,2,4")]) ;; ---------------------------------------------------------------------- ;; OR INSTRUCTIONS @@ -855,7 +809,6 @@ "" "set1 %M1,%0" [(set_attr "length" "4") - (set_attr "cc" "clobber") (set_attr "type" "bit1")]) (define_insn "*v850_set1_2" @@ -880,7 +833,6 @@ return ""; } [(set_attr "length" "4") - (set_attr "cc" "clobber") (set_attr "type" "bit1")]) (define_insn "*v850_set1_3" @@ -906,7 +858,6 @@ return ""; } [(set_attr "length" "4") - (set_attr "cc" "clobber") (set_attr "type" "bit1")]) (define_insn "iorsi3" @@ -919,8 +870,7 @@ or %2,%0 or %.,%0 ori %2,%1,%0" - [(set_attr "length" "2,2,4") - (set_attr "cc" "set_zn")]) + [(set_attr "length" "2,2,4")]) ;; ---------------------------------------------------------------------- ;; XOR INSTRUCTIONS @@ -934,7 +884,6 @@ "" "not1 %M1,%0" [(set_attr "length" "4") - (set_attr "cc" "clobber") (set_attr "type" "bit1")]) (define_insn "*v850_not1_2" @@ -959,7 +908,6 @@ return ""; } [(set_attr "length" "4") - (set_attr "cc" "clobber") (set_attr "type" "bit1")]) (define_insn "*v850_not1_3" @@ -985,7 +933,6 @@ return ""; } [(set_attr "length" "4") - (set_attr "cc" "clobber") (set_attr "type" "bit1")]) (define_insn "xorsi3" @@ -998,8 +945,7 @@ xor %2,%0 xor %.,%0 xori %2,%1,%0" - [(set_attr "length" "2,2,4") - (set_attr "cc" "set_zn")]) + [(set_attr "length" "2,2,4")]) ;; ---------------------------------------------------------------------- ;; NOT INSTRUCTIONS @@ -1011,8 +957,7 @@ (clobber (reg:CC CC_REGNUM))] "" "not %1,%0" - [(set_attr "length" "2") - (set_attr "cc" "set_zn")]) + [(set_attr "length" "2")]) ;; ----------------------------------------------------------------- ;; BIT FIELDS @@ -1035,9 +980,7 @@ (match_operand:SI 3 "register_operand" "r"))] "TARGET_V850E3V5_UP" "bins %3, %2, %1, %0" - [(set_attr "length" "4") - (set_attr "cc" "set_zn")] -) + [(set_attr "length" "4")]) ;; ----------------------------------------------------------------- ;; Scc INSTRUCTIONS @@ -1048,18 +991,8 @@ (match_operator:SI 1 "comparison_operator" [(cc0) (const_int 0)]))] "" -{ - if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0 - && (GET_CODE (operands[1]) == GT - || GET_CODE (operands[1]) == GE - || GET_CODE (operands[1]) == LE - || GET_CODE (operands[1]) == LT)) - return 0; - - return "setf %c1,%0"; -} - [(set_attr "length" "4") - (set_attr "cc" "none_0hit")]) + "setf %c1,%0" + [(set_attr "length" "4")]) (define_insn "setf_insn" [(set (match_operand:SI 0 "register_operand" "=r") @@ -1067,24 +1000,21 @@ [(reg:CC CC_REGNUM) (const_int 0)]))] "" "setf %b1,%0" - [(set_attr "length" "4") - (set_attr "cc" "none_0hit")]) + [(set_attr "length" "4")]) (define_insn "set_z_insn" [(set (match_operand:SI 0 "register_operand" "=r") (match_operand 1 "v850_float_z_comparison_operator" ""))] "TARGET_V850E2V3_UP" "setf z,%0" - [(set_attr "length" "4") - (set_attr "cc" "none_0hit")]) + [(set_attr "length" "4")]) (define_insn "set_nz_insn" [(set (match_operand:SI 0 "register_operand" "=r") (match_operand 1 "v850_float_nz_comparison_operator" ""))] "TARGET_V850E2V3_UP" "setf nz,%0" - [(set_attr "length" "4") - (set_attr "cc" "none_0hit")]) + [(set_attr "length" "4")]) ;; ---------------------------------------------------------------------- ;; CONDITIONAL MOVE INSTRUCTIONS @@ -1150,8 +1080,7 @@ (match_operand:SI 3 "reg_or_0_operand" "rI")))] "(TARGET_V850E_UP)" "cmov %c1,%2,%z3,%0"; - [(set_attr "length" "6") - (set_attr "cc" "compare")]) + [(set_attr "length" "6")]) (define_insn "movsicc_reversed_cc" [(set (match_operand:SI 0 "register_operand" "=r") @@ -1162,8 +1091,7 @@ (match_operand:SI 3 "reg_or_int5_operand" "rJ")))] "(TARGET_V850E_UP)" "cmov %C1,%3,%z2,%0" - [(set_attr "length" "6") - (set_attr "cc" "compare")]) + [(set_attr "length" "6")]) (define_insn "*movsicc_normal" [(set (match_operand:SI 0 "register_operand" "=r") @@ -1175,8 +1103,7 @@ (match_operand:SI 3 "reg_or_0_operand" "rI")))] "(TARGET_V850E_UP)" "cmp %5,%4 ; cmov %c1,%2,%z3,%0" - [(set_attr "length" "6") - (set_attr "cc" "clobber")]) + [(set_attr "length" "6")]) (define_insn "*movsicc_reversed" [(set (match_operand:SI 0 "register_operand" "=r") @@ -1188,8 +1115,7 @@ (match_operand:SI 3 "reg_or_int5_operand" "rJ")))] "(TARGET_V850E_UP)" "cmp %5,%4 ; cmov %C1,%3,%z2,%0" - [(set_attr "length" "6") - (set_attr "cc" "clobber")]) + [(set_attr "length" "6")]) (define_insn "*movsicc_tst1" [(set (match_operand:SI 0 "register_operand" "=r") @@ -1204,8 +1130,7 @@ (match_operand:SI 5 "reg_or_0_operand" "rI")))] "(TARGET_V850E_UP)" "tst1 %3,%2 ; cmov %c1,%4,%z5,%0" - [(set_attr "length" "8") - (set_attr "cc" "clobber")]) + [(set_attr "length" "8")]) (define_insn "*movsicc_tst1_reversed" [(set (match_operand:SI 0 "register_operand" "=r") @@ -1220,8 +1145,7 @@ (match_operand:SI 5 "reg_or_int5_operand" "rJ")))] "(TARGET_V850E_UP)" "tst1 %3,%2 ; cmov %C1,%5,%z4,%0" - [(set_attr "length" "8") - (set_attr "cc" "clobber")]) + [(set_attr "length" "8")]) ;; Matching for sasf requires combining 4 instructions, so we provide a ;; dummy pattern to match the first 3, which will always be turned into the @@ -1239,8 +1163,7 @@ (clobber (reg:CC CC_REGNUM))] "(TARGET_V850E_UP)" "cmp %4,%3 ; sasf %c1,%0" - [(set_attr "length" "6") - (set_attr "cc" "clobber")]) + [(set_attr "length" "6")]) (define_split [(set (match_operand:SI 0 "register_operand" "") @@ -1293,8 +1216,7 @@ (clobber (reg:CC CC_REGNUM))] "(TARGET_V850E_UP)" "bsh %1,%0" - [(set_attr "length" "4") - (set_attr "cc" "clobber")]) + [(set_attr "length" "4")]) (define_expand "rotlsi3" [(parallel [(set (match_operand:SI 0 "register_operand" "") @@ -1316,9 +1238,7 @@ (match_operand:SI 3 "const_int_operand" "n"))]))] "TARGET_V850E3V5_UP && (INTVAL (operands[2]) + INTVAL (operands[3]) == 32)" "rotl %2, %1, %0" - [(set_attr "length" "4") - (set_attr "cc" "set_zn")] -) + [(set_attr "length" "4")]) (define_insn "rotlsi3_b" [(set (match_operand:SI 0 "register_operand" "=r") @@ -1329,9 +1249,7 @@ (match_operand:SI 2 "const_int_operand" "n"))]))] "TARGET_V850E3V5_UP && (INTVAL (operands[2]) + INTVAL (operands[3]) == 32)" "rotl %2, %1, %0" - [(set_attr "length" "4") - (set_attr "cc" "set_zn")] -) + [(set_attr "length" "4")]) (define_insn "rotlsi3_v850e3v5" [(set (match_operand:SI 0 "register_operand" "=r") @@ -1340,9 +1258,7 @@ (clobber (reg:CC CC_REGNUM))] "TARGET_V850E3V5_UP" "rotl %2, %1, %0" - [(set_attr "length" "4") - (set_attr "cc" "set_zn")] -) + [(set_attr "length" "4")]) (define_insn "*rotlsi3_16" [(set (match_operand:SI 0 "register_operand" "=r") @@ -1351,8 +1267,7 @@ (clobber (reg:CC CC_REGNUM))] "(TARGET_V850E_UP)" "hsw %1,%0" - [(set_attr "length" "4") - (set_attr "cc" "clobber")]) + [(set_attr "length" "4")]) ;; ---------------------------------------------------------------------- ;; JUMP INSTRUCTIONS @@ -1384,9 +1299,7 @@ default: gcc_unreachable (); } } - [(set_attr "length" "2,6") - (set_attr "cc" "none")] -) + [(set_attr "length" "2,6")]) (define_expand "doloop_end" [(use (match_operand 0 "" "")) ; loop pseudo @@ -1432,8 +1345,7 @@ (if_then_else (lt (abs (minus (match_dup 0) (pc))) (const_int 65534)) (const_int 4) - (const_int 14))) - (set_attr "cc" "none")]) + (const_int 14)))]) ;; Conditional jump instructions @@ -1445,13 +1357,6 @@ (pc)))] "" { - if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0 - && (GET_CODE (operands[1]) == GT - || GET_CODE (operands[1]) == GE - || GET_CODE (operands[1]) == LE - || GET_CODE (operands[1]) == LT)) - return 0; - if (get_attr_length (insn) == 2) return "b%b1 %l0"; if (TARGET_V850E3V5_UP && get_attr_length (insn) == 4) @@ -1465,8 +1370,7 @@ (if_then_else (lt (abs (minus (match_dup 0) (pc))) (const_int 65536)) (const_int 4) - (const_int 6)))) - (set_attr "cc" "none")]) + (const_int 6))))]) (define_insn "*branch_invert" [(set (pc) @@ -1476,13 +1380,6 @@ (label_ref (match_operand 0 "" ""))))] "" { - if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0 - && (GET_CODE (operands[1]) == GT - || GET_CODE (operands[1]) == GE - || GET_CODE (operands[1]) == LE - || GET_CODE (operands[1]) == LT)) - return NULL; - if (get_attr_length (insn) == 2) return "b%B1 %l0"; @@ -1498,8 +1395,7 @@ (if_then_else (lt (abs (minus (match_dup 0) (pc))) (const_int 65536)) (const_int 4) - (const_int 6)))) - (set_attr "cc" "none")]) + (const_int 6))))]) (define_insn "branch_z_normal" [(set (pc) @@ -1523,8 +1419,7 @@ (if_then_else (lt (abs (minus (match_dup 0) (pc))) (const_int 65536)) (const_int 4) - (const_int 6)))) - (set_attr "cc" "none")]) + (const_int 6))))]) (define_insn "*branch_z_invert" [(set (pc) @@ -1548,8 +1443,7 @@ (if_then_else (lt (abs (minus (match_dup 0) (pc))) (const_int 65536)) (const_int 4) - (const_int 6)))) - (set_attr "cc" "none")]) + (const_int 6))))]) (define_insn "branch_nz_normal" [(set (pc) @@ -1573,8 +1467,7 @@ (if_then_else (lt (abs (minus (match_dup 0) (pc))) (const_int 65536)) (const_int 4) - (const_int 6)))) - (set_attr "cc" "none")]) + (const_int 6))))]) (define_insn "*branch_nz_invert" [(set (pc) @@ -1598,8 +1491,7 @@ (if_then_else (lt (abs (minus (match_dup 0) (pc))) (const_int 65536)) (const_int 4) - (const_int 6)))) - (set_attr "cc" "none")]) + (const_int 6))))]) ;; Unconditional and other jump instructions. @@ -1617,23 +1509,20 @@ (if_then_else (lt (abs (minus (match_dup 0) (pc))) (const_int 256)) (const_int 2) - (const_int 4))) - (set_attr "cc" "none")]) + (const_int 4)))]) (define_insn "indirect_jump" [(set (pc) (match_operand:SI 0 "register_operand" "r"))] "" "jmp %0" - [(set_attr "length" "2") - (set_attr "cc" "none")]) + [(set_attr "length" "2")]) (define_insn "tablejump" [(set (pc) (match_operand:SI 0 "register_operand" "r")) (use (label_ref (match_operand 1 "" "")))] "" "jmp %0" - [(set_attr "length" "2") - (set_attr "cc" "none")]) + [(set_attr "length" "2")]) (define_insn "switch" [(set (pc) @@ -1646,8 +1535,7 @@ (label_ref (match_dup 1))))] "(TARGET_V850E_UP)" "switch %0" - [(set_attr "length" "2") - (set_attr "cc" "none")]) + [(set_attr "length" "2")]) (define_expand "casesi" [(match_operand:SI 0 "register_operand" "") @@ -1727,9 +1615,7 @@ return "jarl %0, r31"; } - [(set_attr "length" "4,8") - (set_attr "cc" "clobber,clobber")] -) + [(set_attr "length" "4,8")]) (define_insn "call_internal_long" [(call (mem:QI (match_operand:SI 0 "call_address_operand" "S,r")) @@ -1753,9 +1639,7 @@ return "jarl .+4,r31 ; add 4,r31 ; jmp %0"; } - [(set_attr "length" "16,8") - (set_attr "cc" "clobber,clobber")] -) + [(set_attr "length" "16,8")]) ;; Call subroutine, returning value in operand 0 ;; (which must be a hard register). @@ -1797,9 +1681,7 @@ return "jarl %1, r31"; } - [(set_attr "length" "4,8") - (set_attr "cc" "clobber,clobber")] -) + [(set_attr "length" "4,8")]) (define_insn "call_value_internal_long" [(set (match_operand 0 "" "=r,r") @@ -1825,16 +1707,13 @@ return "jarl .+4, r31 ; add 4, r31 ; jmp %1"; } - [(set_attr "length" "16,8") - (set_attr "cc" "clobber,clobber")] -) + [(set_attr "length" "16,8")]) (define_insn "nop" [(const_int 0)] "" "nop" - [(set_attr "length" "2") - (set_attr "cc" "none")]) + [(set_attr "length" "2")]) ;; ---------------------------------------------------------------------- ;; EXTEND INSTRUCTIONS @@ -1851,8 +1730,7 @@ andi 65535,%1,%0 sld.hu %1,%0 ld.hu %1,%0" - [(set_attr "length" "2,4,2,4") - (set_attr "cc" "none_0hit,set_zn,none_0hit,none_0hit")]) + [(set_attr "length" "2,4,2,4")]) (define_insn "*zero_extendhisi2_v850" [(set (match_operand:SI 0 "register_operand" "=r") @@ -1861,8 +1739,7 @@ (clobber (reg:CC CC_REGNUM))] ;; A lie, but we have to match the expander "" "andi 65535,%1,%0" - [(set_attr "length" "4") - (set_attr "cc" "set_zn")]) + [(set_attr "length" "4")]) (define_expand "zero_extendhisi2" [(parallel [(set (match_operand:SI 0 "register_operand") @@ -1886,8 +1763,7 @@ andi 255,%1,%0 sld.bu %1,%0 ld.bu %1,%0" - [(set_attr "length" "2,4,2,4") - (set_attr "cc" "none_0hit,set_zn,none_0hit,none_0hit")]) + [(set_attr "length" "2,4,2,4")]) (define_insn "*zero_extendqisi2_v850" [(set (match_operand:SI 0 "register_operand" "=r") @@ -1896,8 +1772,7 @@ (clobber (reg:CC CC_REGNUM))] ;; A lie, but we have to match the expander "" "andi 255,%1,%0" - [(set_attr "length" "4") - (set_attr "cc" "set_zn")]) + [(set_attr "length" "4")]) (define_expand "zero_extendqisi2" [(parallel [(set (match_operand:SI 0 "register_operand") @@ -1923,8 +1798,7 @@ sxh %0 sld.h %1,%0 ld.h %1,%0" - [(set_attr "length" "2,2,4") - (set_attr "cc" "none_0hit,none_0hit,none_0hit")]) + [(set_attr "length" "2,2,4")]) ;; ??? This is missing a sign extend from memory pattern to match the ld.h ;; instruction. @@ -1955,8 +1829,7 @@ sxb %0 sld.b %1,%0 ld.b %1,%0" - [(set_attr "length" "2,2,4") - (set_attr "cc" "none_0hit,none_0hit,none_0hit")]) + [(set_attr "length" "2,2,4")]) ;; ??? This is missing a sign extend from memory pattern to match the ld.b ;; instruction. @@ -1990,8 +1863,7 @@ "@ shl %2,%0 shl %2,%0" - [(set_attr "length" "4,2") - (set_attr "cc" "set_zn")]) + [(set_attr "length" "4,2")]) (define_insn "ashlsi3_v850e2" [(set (match_operand:SI 0 "register_operand" "=r") @@ -2001,8 +1873,7 @@ (clobber (reg:CC CC_REGNUM))] "TARGET_V850E2_UP" "shl %2,%1,%0" - [(set_attr "length" "4") - (set_attr "cc" "set_znv")]) + [(set_attr "length" "4")]) (define_insn "lshrsi3" [(set (match_operand:SI 0 "register_operand" "=r,r") @@ -2014,8 +1885,7 @@ "@ shr %2,%0 shr %2,%0" - [(set_attr "length" "4,2") - (set_attr "cc" "set_zn")]) + [(set_attr "length" "4,2")]) (define_insn "lshrsi3_v850e2" [(set (match_operand:SI 0 "register_operand" "=r") @@ -2025,8 +1895,7 @@ (clobber (reg:CC CC_REGNUM))] "TARGET_V850E2_UP" "shr %2,%1,%0" - [(set_attr "length" "4") - (set_attr "cc" "set_zn")]) + [(set_attr "length" "4")]) (define_insn "ashrsi3" [(set (match_operand:SI 0 "register_operand" "=r,r") @@ -2038,8 +1907,7 @@ "@ sar %2,%0 sar %2,%0" - [(set_attr "length" "4,2") - (set_attr "cc" "set_zn, set_zn")]) + [(set_attr "length" "4,2")]) (define_insn "ashrsi3_v850e2" [(set (match_operand:SI 0 "register_operand" "=r") @@ -2049,8 +1917,7 @@ (clobber (reg:CC CC_REGNUM))] "TARGET_V850E2_UP" "sar %2,%1,%0" - [(set_attr "length" "4") - (set_attr "cc" "set_zn")]) + [(set_attr "length" "4")]) ;; ---------------------------------------------------------------------- ;; FIND FIRST BIT INSTRUCTION @@ -2062,8 +1929,7 @@ (clobber (reg:CC CC_REGNUM))] "TARGET_V850E2_UP" "sch1r %1,%0" - [(set_attr "length" "4") - (set_attr "cc" "clobber")]) + [(set_attr "length" "4")]) ;; ---------------------------------------------------------------------- ;; PROLOGUE/EPILOGUE @@ -2088,16 +1954,14 @@ [(return)] "reload_completed" "jmp [r31]" - [(set_attr "length" "2") - (set_attr "cc" "none")]) + [(set_attr "length" "2")]) (define_insn "return_internal" [(return) (use (reg:SI 31))] "" "jmp [r31]" - [(set_attr "length" "2") - (set_attr "cc" "none")]) + [(set_attr "length" "2")]) ;; ---------------------------------------------------------------------- ;; v850e2V3 floating-point hardware support @@ -2111,7 +1975,6 @@ "TARGET_USE_FPU" "addf.s %1,%2,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "adddf3" @@ -2121,7 +1984,6 @@ "TARGET_USE_FPU" "addf.d %1,%2,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "subsf3" @@ -2131,7 +1993,6 @@ "TARGET_USE_FPU" "subf.s %2,%1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "subdf3" @@ -2141,7 +2002,6 @@ "TARGET_USE_FPU" "subf.d %2,%1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "mulsf3" @@ -2151,7 +2011,6 @@ "TARGET_USE_FPU" "mulf.s %1,%2,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "muldf3" @@ -2161,7 +2020,6 @@ "TARGET_USE_FPU" "mulf.d %1,%2,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "divsf3" @@ -2171,7 +2029,6 @@ "TARGET_USE_FPU" "divf.s %2,%1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "divdf3" @@ -2181,7 +2038,6 @@ "TARGET_USE_FPU" "divf.d %2,%1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "minsf3" @@ -2191,7 +2047,6 @@ "TARGET_USE_FPU" "minf.s %z1,%z2,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "mindf3" @@ -2201,7 +2056,6 @@ "TARGET_USE_FPU" "minf.d %1,%2,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "maxsf3" @@ -2211,7 +2065,6 @@ "TARGET_USE_FPU" "maxf.s %z1,%z2,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "maxdf3" @@ -2221,7 +2074,6 @@ "TARGET_USE_FPU" "maxf.d %1,%2,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "abssf2" @@ -2230,7 +2082,6 @@ "TARGET_USE_FPU" "absf.s %1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "absdf2" @@ -2239,7 +2090,6 @@ "TARGET_USE_FPU" "absf.d %1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "negsf2" @@ -2248,7 +2098,6 @@ "TARGET_USE_FPU" "negf.s %1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "negdf2" @@ -2257,7 +2106,6 @@ "TARGET_USE_FPU" "negf.d %1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) ;; square-root @@ -2267,7 +2115,6 @@ "TARGET_USE_FPU" "sqrtf.s %1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "sqrtdf2" @@ -2276,7 +2123,6 @@ "TARGET_USE_FPU" "sqrtf.d %1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) ;; float -> int @@ -2286,7 +2132,6 @@ "TARGET_USE_FPU" "trncf.sw %1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "fixuns_truncsfsi2" @@ -2295,9 +2140,7 @@ "TARGET_USE_FPU" "trncf.suw %1, %0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") - (set_attr "type" "fpu")] -) + (set_attr "type" "fpu")]) (define_insn "fix_truncdfsi2" [(set (match_operand:SI 0 "register_operand" "=r") @@ -2305,7 +2148,6 @@ "TARGET_USE_FPU" "trncf.dw %1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "fixuns_truncdfsi2" @@ -2314,9 +2156,7 @@ "TARGET_USE_FPU" "trncf.duw %1, %0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") - (set_attr "type" "fpu")] -) + (set_attr "type" "fpu")]) (define_insn "fix_truncsfdi2" [(set (match_operand:DI 0 "register_operand" "=r") @@ -2324,7 +2164,6 @@ "TARGET_USE_FPU" "trncf.sl %1, %0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "fixuns_truncsfdi2" @@ -2333,9 +2172,7 @@ "TARGET_USE_FPU" "trncf.sul %1, %0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") - (set_attr "type" "fpu")] -) + (set_attr "type" "fpu")]) (define_insn "fix_truncdfdi2" [(set (match_operand:DI 0 "register_operand" "=r") @@ -2343,7 +2180,6 @@ "TARGET_USE_FPU" "trncf.dl %1, %0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "fixuns_truncdfdi2" @@ -2352,9 +2188,7 @@ "TARGET_USE_FPU" "trncf.dul %1, %0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") - (set_attr "type" "fpu")] -) + (set_attr "type" "fpu")]) ;; int -> float (define_insn "floatsisf2" @@ -2363,7 +2197,6 @@ "TARGET_USE_FPU" "cvtf.ws %z1, %0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "unsfloatsisf2" @@ -2372,7 +2205,6 @@ "TARGET_USE_FPU" "cvtf.uws %z1, %0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "floatsidf2" @@ -2381,7 +2213,6 @@ "TARGET_USE_FPU" "cvtf.wd %z1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "unsfloatsidf2" @@ -2390,7 +2221,6 @@ "TARGET_USE_FPU" "cvtf.uwd %z1, %0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "floatdisf2" @@ -2399,7 +2229,6 @@ "TARGET_USE_FPU" "cvtf.ls %z1, %0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "unsfloatdisf2" @@ -2408,7 +2237,6 @@ "TARGET_USE_FPU" "cvtf.uls %z1, %0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "floatdidf2" @@ -2417,7 +2245,6 @@ "TARGET_USE_FPU" "cvtf.ld %z1, %0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "unsfloatdidf2" @@ -2426,7 +2253,6 @@ "TARGET_USE_FPU" "cvtf.uld %z1, %0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) ;; single-float -> double-float @@ -2437,7 +2263,6 @@ "TARGET_USE_FPU" "cvtf.sd %z1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) ;; double-float -> single-float @@ -2448,7 +2273,6 @@ "TARGET_USE_FPU" "cvtf.ds %1,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) ;; @@ -2477,7 +2301,6 @@ "TARGET_USE_FPU" "recipf.s %2,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_expand "recipdf2" @@ -2497,7 +2320,6 @@ "TARGET_USE_FPU" "recipf.d %2,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) ;;; reciprocal of square-root @@ -2518,7 +2340,6 @@ "TARGET_USE_FPU" "rsqrtf.s %2,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_expand "rsqrtdf2" @@ -2538,7 +2359,6 @@ "TARGET_USE_FPU" "rsqrtf.d %2,%0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) ;; Note: The FPU-2.0 (ie pre e3v5) versions of these routines do not actually @@ -2554,7 +2374,6 @@ "TARGET_USE_FPU" { return TARGET_V850E3V5_UP ? "fmaf.s %1, %2, %0" : "maddf.s %2, %1, %3, %0"; } [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) ;;; multiply-subtract @@ -2566,7 +2385,6 @@ "TARGET_USE_FPU" { return TARGET_V850E3V5_UP ? "fmsf.s %1, %2, %0" : "msubf.s %2, %1, %3, %0"; } [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) ;;; negative-multiply-add @@ -2578,7 +2396,6 @@ "TARGET_USE_FPU" { return TARGET_V850E3V5_UP ? "fnmaf.s %1, %2, %0" : "nmaddf.s %2, %1, %3, %0"; } [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) ;; negative-multiply-subtract @@ -2590,7 +2407,6 @@ "TARGET_USE_FPU" { return TARGET_V850E3V5_UP ? "fnmsf.s %1, %2, %0" : "nmsubf.s %2, %1, %3, %0"; } [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) ; ; ---------------- comparison/conditionals @@ -2604,7 +2420,6 @@ "TARGET_USE_FPU" "cmpf.s le, %z0, %z1" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "cmpsf_lt_insn" @@ -2614,7 +2429,6 @@ "TARGET_USE_FPU" "cmpf.s lt, %z0, %z1" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "cmpsf_ge_insn" @@ -2624,7 +2438,6 @@ "TARGET_USE_FPU" "cmpf.s le, %z1, %z0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "cmpsf_gt_insn" @@ -2634,7 +2447,6 @@ "TARGET_USE_FPU" "cmpf.s lt, %z1, %z0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "cmpsf_eq_insn" @@ -2644,7 +2456,6 @@ "TARGET_USE_FPU" "cmpf.s eq, %z0, %z1" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) ; DF @@ -2656,7 +2467,6 @@ "TARGET_USE_FPU" "cmpf.d le, %z0, %z1" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "cmpdf_lt_insn" @@ -2666,7 +2476,6 @@ "TARGET_USE_FPU" "cmpf.d lt, %z0, %z1" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "cmpdf_ge_insn" @@ -2676,7 +2485,6 @@ "TARGET_USE_FPU" "cmpf.d le, %z1, %z0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "cmpdf_gt_insn" @@ -2686,7 +2494,6 @@ "TARGET_USE_FPU" "cmpf.d lt, %z1, %z0" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) (define_insn "cmpdf_eq_insn" @@ -2696,7 +2503,6 @@ "TARGET_USE_FPU" "cmpf.d eq, %z0, %z1" [(set_attr "length" "4") - (set_attr "cc" "none_0hit") (set_attr "type" "fpu")]) ;; @@ -2718,7 +2524,6 @@ || GET_MODE(operands[0]) == CC_FPU_NEmode)" "trfsr" [(set_attr "length" "4") - (set_attr "cc" "set_z") (set_attr "type" "fpu")]) ;; @@ -2734,8 +2539,7 @@ (match_operand:SF 1 "reg_or_0_operand" "rIG") (match_operand:SF 2 "reg_or_0_operand" "rIG")))] "TARGET_USE_FPU" - "cmovf.s 0,%z1,%z2,%0" - [(set_attr "cc" "clobber")]) ;; ??? or none_0hit + "cmovf.s 0,%z1,%z2,%0") (define_insn "movsfcc_nz_insn" [(set (match_operand:SF 0 "register_operand" "=r") @@ -2744,8 +2548,7 @@ (match_operand:SF 1 "reg_or_0_operand" "rIG") (match_operand:SF 2 "reg_or_0_operand" "rIG")))] "TARGET_USE_FPU" - "cmovf.s 0,%z2,%z1,%0" - [(set_attr "cc" "clobber")]) ;; ??? or none_0hit + "cmovf.s 0,%z2,%z1,%0") (define_insn "movdfcc_z_insn" [(set (match_operand:DF 0 "even_reg_operand" "=r") @@ -2754,8 +2557,7 @@ (match_operand:DF 1 "even_reg_operand" "r") (match_operand:DF 2 "even_reg_operand" "r")))] "TARGET_USE_FPU" - "cmovf.d 0,%z1,%z2,%0" - [(set_attr "cc" "clobber")]) ;; ??? or none_0hit + "cmovf.d 0,%z1,%z2,%0") (define_insn "movdfcc_nz_insn" [(set (match_operand:DF 0 "even_reg_operand" "=r") @@ -2764,8 +2566,7 @@ (match_operand:DF 1 "even_reg_operand" "r") (match_operand:DF 2 "even_reg_operand" "r")))] "TARGET_USE_FPU" - "cmovf.d 0,%z2,%z1,%0" - [(set_attr "cc" "clobber")]) ;; ??? or none_0hit + "cmovf.d 0,%z2,%z1,%0") (define_insn "movedfcc_z_zero" [(set (match_operand:DF 0 "register_operand" "=r") @@ -2775,8 +2576,7 @@ (match_operand:DF 2 "reg_or_0_operand" "rIG")))] "TARGET_USE_FPU" "cmovf.s 0,%z1,%z2,%0 ; cmovf.s 0,%Z1,%Z2,%R0" - [(set_attr "length" "8") - (set_attr "cc" "clobber")]) ;; ??? or none_0hit + [(set_attr "length" "8")]) (define_insn "movedfcc_nz_zero" [(set (match_operand:DF 0 "register_operand" "=r") @@ -2786,8 +2586,7 @@ (match_operand:DF 2 "reg_or_0_operand" "rIG")))] "TARGET_USE_FPU" "cmovf.s 0,%z2,%z1,%0 ; cmovf.s 0,%Z2,%Z1,%R0" - [(set_attr "length" "8") - (set_attr "cc" "clobber")]) ;; ??? or none_0hit + [(set_attr "length" "8")]) ;; ---------------------------------------------------------------------- @@ -2813,8 +2612,7 @@ { return construct_prepare_instruction (operands[0]); } - [(set_attr "length" "4") - (set_attr "cc" "clobber")]) + [(set_attr "length" "4")]) (define_insn "" [(match_parallel 0 "pattern_is_ok_for_prologue" @@ -2829,8 +2627,7 @@ } [(set (attr "length") (if_then_else (eq_attr "long_calls" "yes") (const_string "16") - (const_string "4"))) - (set_attr "cc" "clobber")]) + (const_string "4")))]) ;; ;; Actually, turn the RTXs into a DISPOSE instruction. @@ -2847,8 +2644,7 @@ { return construct_dispose_instruction (operands[0]); } - [(set_attr "length" "4") - (set_attr "cc" "clobber")]) + [(set_attr "length" "4")]) ;; This pattern will match a return RTX followed by any number of pop RTXs ;; and possible a stack adjustment as well. These RTXs will be turned into @@ -2868,8 +2664,7 @@ } [(set (attr "length") (if_then_else (eq_attr "long_calls" "yes") (const_string "12") - (const_string "4"))) - (set_attr "cc" "clobber")]) + (const_string "4")))]) ;; Initialize an interrupt function. Do not depend on TARGET_PROLOG_FUNCTION. (define_insn "callt_save_interrupt" @@ -2891,15 +2686,13 @@ output_asm_insn ("callt ctoff(__callt_save_interrupt)", operands); return ""; } - [(set_attr "length" "26") - (set_attr "cc" "clobber")]) + [(set_attr "length" "26")]) (define_insn "callt_return_interrupt" [(unspec_volatile [(const_int 0)] 3)] "(TARGET_V850E_UP) && !TARGET_DISABLE_CALLT" "callt ctoff(__callt_return_interrupt)" - [(set_attr "length" "2") - (set_attr "cc" "clobber")]) + [(set_attr "length" "2")]) (define_insn "save_interrupt" [(set (reg:SI 3) (plus:SI (reg:SI 3) (const_int -20))) @@ -2930,8 +2723,7 @@ [(set (attr "length") (if_then_else (match_test "TARGET_LONG_CALLS") (const_int 10) - (const_int 34))) - (set_attr "cc" "clobber")]) + (const_int 34)))]) ;; Restore r1, r4, r10, and return from the interrupt (define_insn "return_interrupt" @@ -2961,8 +2753,7 @@ [(set (attr "length") (if_then_else (match_test "TARGET_LONG_CALLS") (const_int 4) - (const_int 24))) - (set_attr "cc" "clobber")]) + (const_int 24)))]) ;; Save all registers except for the registers saved in save_interrupt when ;; an interrupt function makes a call. @@ -2975,8 +2766,7 @@ [(unspec_volatile [(const_int 0)] 0)] "(TARGET_V850E_UP) && !TARGET_DISABLE_CALLT" "callt ctoff(__callt_save_all_interrupt)" - [(set_attr "length" "2") - (set_attr "cc" "none")]) + [(set_attr "length" "2")]) (define_insn "save_all_interrupt" [(unspec_volatile [(const_int 0)] 0)] @@ -3054,16 +2844,13 @@ [(set (attr "length") (if_then_else (match_test "TARGET_LONG_CALLS") (const_int 4) - (const_int 62) - )) - (set_attr "cc" "clobber")]) + (const_int 62)))]) (define_insn "_save_all_interrupt" [(unspec_volatile [(const_int 0)] 0)] "TARGET_V850 && ! TARGET_LONG_CALLS" "jarl __save_all_interrupt,r10" - [(set_attr "length" "4") - (set_attr "cc" "clobber")]) + [(set_attr "length" "4")]) ;; Restore all registers saved when an interrupt function makes a call. ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and @@ -3075,8 +2862,7 @@ [(unspec_volatile [(const_int 0)] 1)] "(TARGET_V850E_UP) && !TARGET_DISABLE_CALLT" "callt ctoff(__callt_restore_all_interrupt)" - [(set_attr "length" "2") - (set_attr "cc" "none")]) + [(set_attr "length" "2")]) (define_insn "restore_all_interrupt" [(unspec_volatile [(const_int 0)] 1)] @@ -3153,12 +2939,10 @@ (if_then_else (match_test "TARGET_LONG_CALLS") (const_int 4) (const_int 62) - )) - (set_attr "cc" "clobber")]) + ))]) (define_insn "_restore_all_interrupt" [(unspec_volatile [(const_int 0)] 1)] "TARGET_V850 && ! TARGET_LONG_CALLS" "jarl __restore_all_interrupt,r10" - [(set_attr "length" "4") - (set_attr "cc" "clobber")]) + [(set_attr "length" "4")]) From patchwork Wed Jun 27 18:32:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 935665 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480573-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="xYOGW56U"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41GBNN0GNvz9s2g for ; Thu, 28 Jun 2018 04:32:35 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=UivNq0cfvhfsuRSm/LuhmSi93NXJKjX0KCXTMffX6hEX6TVIzQemN CtWfyAhGQf2QTXxZLnL+wUXA+uRaNBMp4GJPh77W9mcuf0jZRul0pXpX0u6VPP7p YFjeudO3fti+LWBNiNlAwr9OlJ5Gc0e4dsncnf2p9qrqcQKGT0VtKA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; s= default; bh=/ApqXs9vplfLZVBKlCLZxZg7GMo=; b=xYOGW56UPxEEFAEPkksd 0t+PZEJStHbUdA9drXpuMb5ItwfXLIqLlFd4cuFA1oqYVv0A+KHvpSGwumzmKzD8 tl3cwNweTEPxVOnzzJVUSJoT82L4rVIe2wcYIphGYNfJ8N9uplUQEu6f4UmJtURp WXzSoFrfkIq2kbO1gNK1l3s= Received: (qmail 70629 invoked by alias); 27 Jun 2018 18:32:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 70553 invoked by uid 89); 27 Jun 2018 18:32:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=FCC, fcc, movement, 0r X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Jun 2018 18:32:16 +0000 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A5BD308A968 for ; Wed, 27 Jun 2018 18:32:15 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-5.rdu2.redhat.com [10.10.112.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17AAB903D1 for ; Wed, 27 Jun 2018 18:32:13 +0000 (UTC) From: Jeff Law Subject: [committed] [2/3] Converting the v850 port away from cc0 -- basic support for new scheme Openpgp: preference=signencrypt To: gcc-patches Message-ID: <90e9cdf4-9ddd-a3fd-6d5d-75bec16b9ab5@redhat.com> Date: Wed, 27 Jun 2018 12:32:13 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 X-IsSubscribed: yes This is the bulk of the changes. With this change in installed the v850 port should be using the new mechanism for condition code handling consistently, though without optimizing well. This is a fairly large change which hits a great many patterns. It's largely what one would expect. THe comparison/branch are kept together as a unit prior to reload, but split post-reload. Similarly for things like conditional moves and tst insns. Clobbers get added to several patterns that were missing them. One of the interesting v8 tidbits is that it was already using the new style for its floating point comparisons & branches. We actually get to simplify that a bit because we no longer need special branching patterns (FP comparison initially are stored in FCC, then get copied into the Z bit of CC_REG, then we use standard bz/bnz insns). This commit should work independently of #3 as #3 strictly adds flags setting variants of arithmetic, logicals and other patterns. But I haven't tested that extensively. Jeff * config/v850/v850-protos.h (notice_update_cc): Remove. * config/v850/v850.c (v850_compare_op0, v850_compare_op1): Remove. (v850_print_operand): Handle 'D' and "d". (v850_select_cc_mode): Remove ATTRIBUTE_UNUSED for last argument. Add handling of arithmetic/logical operations compared against zero. (v850_gen_float_compare): Remove ATTRIBUTE_UNUSED for last argument. Do not look at v850_compare_op, instead get mode from last argument. (v850_gen_compare): Remove (increment_stack): Use addsi3_clobber_flags to avoid splitting failure after reload for prologue insns. (expand_prologue): Account for CLOBBER of CC_REGNUM in various patterns. (construct_save_jarl): Likewise. (TARGET_FLAGS_REGNUM): Define. * config/v850/v850.h (v850_compare_op0, v850_compare_op1): Remove. (NOTICE_UPDATE_CC): Remove. * config/v850/v850.md (v850_tst1): Use (reg:CCZ CC_REGNUM) rather than cc0. Conditionalize on reload_completed. (cmpsi_insn, setfcc_insn): Likewise. (tst1 splitter): Turn into define_and_split which sets the flags after reload. (cstoresi4, cbranchsf4, cbranchdf4, cbranchsi4_insn): Likewise. (cbranchsi4, branch_normal, branch_invert): Do not expose cc0 here. (cstoresf4, cstoredf4): Clobber the flags. (cmpsi, cmpsf, cmpdf): Remove expanders. (setf_insn): Remove pattern. (addsi3): Turn into define_and_split which clobbers the flags after reload and a suitable pattern (addsi3_clobber_flags) for use after reload. (subsi3, negsi2, andsi3, iorsi3, xorsi3, one_cmplsi2) Likewise. (ashlsi3, ashlsi3_v850e2, lshrsi3, lsh4si3_v850e2): Likewise. (ashrsi3, ashrsi3_v850e2): Likewise. (bins): Clobber the flags. (movsicc_normal_cc, movsicc_normal, movsicc_tst1): Likewise. (movsicc_tst1_revesed, sasf, swap and rotate patterns): Likewise. (fix_loop_counter, call_internal_short, call_internal_long): Likewise. (call_value_internal_short, call_value_internal_long): Likewise. (callt_save_interrupt, callt_return_interrupt): Likewise. (save_interrupt, return_interrupt): Likewise. (callt_save_all_interrupt, save_all_interrupt): Likewise. (_save_all_interrupt, callt_restore_all_interrupt): Likewise. (restore_all_interrupt, _restore_all_interrupt): Likewise. (All FP comparisons): Only allow after reload has completed. (trfsr): Likewise. (divh, divhu): Tweak output template. (branch_z_normal, branch_z_invert): Remove (branch_nz_normal, branch_nz_invert): Likewise. (extendhisi_insn, extendqisi_insn): Do not clobber flags. diff --git a/gcc/config/v850/v850-protos.h b/gcc/config/v850/v850-protos.h index e8ff280..ca99703 100644 --- a/gcc/config/v850/v850-protos.h +++ b/gcc/config/v850/v850-protos.h @@ -32,7 +32,6 @@ extern void v850_init_expanders (void); #ifdef RTX_CODE extern rtx v850_return_addr (int); extern const char *output_move_single (rtx *); -extern void notice_update_cc (rtx, rtx_insn *); extern char * construct_save_jarl (rtx); extern char * construct_restore_jr (rtx); #ifdef HAVE_MACHINE_MODES diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c index e184718..cb2debf 100644 --- a/gcc/config/v850/v850.c +++ b/gcc/config/v850/v850.c @@ -68,8 +68,6 @@ data_area_stack_element * data_area_stack = NULL; function is an interrupt handler. */ static int v850_interrupt_cache_p = FALSE; -rtx v850_compare_op0, v850_compare_op1; - /* Whether current function is an interrupt handler. */ static int v850_interrupt_p = FALSE; @@ -418,7 +416,9 @@ v850_print_operand (FILE * file, rtx x, int code) case 'b': case 'B': case 'C': - switch ((code == 'B' || code == 'C') + case 'd': + case 'D': + switch ((code == 'B' || code == 'C' || code == 'D') ? reverse_condition (GET_CODE (x)) : GET_CODE (x)) { case NE: @@ -434,7 +434,10 @@ v850_print_operand (FILE * file, rtx x, int code) fprintf (file, "e"); break; case GE: - fprintf (file, "ge"); + if (code == 'D' || code == 'd') + fprintf (file, "p"); + else + fprintf (file, "ge"); break; case GT: fprintf (file, "gt"); @@ -443,7 +446,10 @@ v850_print_operand (FILE * file, rtx x, int code) fprintf (file, "le"); break; case LT: - fprintf (file, "lt"); + if (code == 'D' || code == 'd') + fprintf (file, "n"); + else + fprintf (file, "lt"); break; case GEU: fprintf (file, "nl"); @@ -905,7 +911,7 @@ output_move_single (rtx * operands) } machine_mode -v850_select_cc_mode (enum rtx_code cond, rtx op0, rtx op1 ATTRIBUTE_UNUSED) +v850_select_cc_mode (enum rtx_code cond, rtx op0, rtx op1) { if (GET_MODE_CLASS (GET_MODE (op0)) == MODE_FLOAT) { @@ -927,11 +933,20 @@ v850_select_cc_mode (enum rtx_code cond, rtx op0, rtx op1 ATTRIBUTE_UNUSED) gcc_unreachable (); } } + + if (op1 == const0_rtx + && (cond == EQ || cond == NE || cond == LT || cond == GE) + && (GET_CODE (op0) == PLUS || GET_CODE (op0) == MINUS + || GET_CODE (op0) == NEG || GET_CODE (op0) == AND + || GET_CODE (op0) == IOR || GET_CODE (op0) == XOR + || GET_CODE (op0) == NOT || GET_CODE (op0) == ASHIFT)) + return CCNZmode; + return CCmode; } machine_mode -v850_gen_float_compare (enum rtx_code cond, machine_mode mode ATTRIBUTE_UNUSED, rtx op0, rtx op1) +v850_gen_float_compare (enum rtx_code cond, machine_mode mode, rtx op0, rtx op1) { if (GET_MODE (op0) == DFmode) { @@ -960,7 +975,7 @@ v850_gen_float_compare (enum rtx_code cond, machine_mode mode ATTRIBUTE_UNUSED, gcc_unreachable (); } } - else if (GET_MODE (v850_compare_op0) == SFmode) + else if (mode == SFmode) { switch (cond) { @@ -993,25 +1008,6 @@ v850_gen_float_compare (enum rtx_code cond, machine_mode mode ATTRIBUTE_UNUSED, return v850_select_cc_mode (cond, op0, op1); } -rtx -v850_gen_compare (enum rtx_code cond, machine_mode mode, rtx op0, rtx op1) -{ - if (GET_MODE_CLASS(GET_MODE (op0)) != MODE_FLOAT) - { - emit_insn (gen_cmpsi_insn (op0, op1)); - return gen_rtx_fmt_ee (cond, mode, gen_rtx_REG(CCmode, CC_REGNUM), const0_rtx); - } - else - { - rtx cc_reg; - mode = v850_gen_float_compare (cond, mode, op0, op1); - cc_reg = gen_rtx_REG (mode, CC_REGNUM); - emit_insn (gen_rtx_SET (cc_reg, gen_rtx_REG (mode, FCC_REGNUM))); - - return gen_rtx_fmt_ee (cond, mode, cc_reg, const0_rtx); - } -} - /* Return maximum offset supported for a short EP memory reference of mode MODE and signedness UNSIGNEDP. */ @@ -1635,7 +1631,7 @@ increment_stack (signed int amount, bool in_prologue) inc = reg; } - inc = emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, inc)); + inc = emit_insn (gen_addsi3_clobber_flags (stack_pointer_rtx, stack_pointer_rtx, inc)); if (in_prologue) F (inc); } @@ -1712,7 +1708,7 @@ expand_prologue (void) save_all = gen_rtx_PARALLEL (VOIDmode, - rtvec_alloc (num_save + 1 + rtvec_alloc (num_save + 2 + (TARGET_DISABLE_CALLT ? (TARGET_LONG_CALLS ? 2 : 1) : 0))); XVECEXP (save_all, 0, 0) @@ -1731,13 +1727,16 @@ expand_prologue (void) save_regs[i]); } + XVECEXP (save_all, 0, num_save + 1) + = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, CC_REGNUM)); + if (TARGET_DISABLE_CALLT) { - XVECEXP (save_all, 0, num_save + 1) + XVECEXP (save_all, 0, num_save + 2) = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, 10)); if (TARGET_LONG_CALLS) - XVECEXP (save_all, 0, num_save + 2) + XVECEXP (save_all, 0, num_save + 3) = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, 11)); } @@ -2330,7 +2329,7 @@ construct_save_jarl (rtx op) stack_bytes = INTVAL (XEXP (SET_SRC (XVECEXP (op, 0, 0)), 1)); /* Each push will put 4 bytes from the stack.... */ - stack_bytes += (count - (TARGET_LONG_CALLS ? 3 : 2)) * 4; + stack_bytes += (count - (TARGET_LONG_CALLS ? 4 : 3)) * 4; /* Make sure that the amount we are popping either 0 or 16 bytes. */ if (stack_bytes != 0) @@ -2341,7 +2340,7 @@ construct_save_jarl (rtx op) /* Now compute the bit mask of registers to push. */ mask = 0; - for (i = 1; i < count - (TARGET_LONG_CALLS ? 2 : 1); i++) + for (i = 1; i < count - (TARGET_LONG_CALLS ? 3 : 2); i++) { rtx vector_element = XVECEXP (op, 0, i); @@ -3325,6 +3324,9 @@ v850_modes_tieable_p (machine_mode mode1, machine_mode mode2) #undef TARGET_MODES_TIEABLE_P #define TARGET_MODES_TIEABLE_P v850_modes_tieable_p +#undef TARGET_FLAGS_REGNUM +#define TARGET_FLAGS_REGNUM 32 + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-v850.h" diff --git a/gcc/config/v850/v850.h b/gcc/config/v850/v850.h index 96bddc2..04d226a 100644 --- a/gcc/config/v850/v850.h +++ b/gcc/config/v850/v850.h @@ -26,9 +26,6 @@ #ifndef GCC_V850_H #define GCC_V850_H -extern GTY(()) rtx v850_compare_op0; -extern GTY(()) rtx v850_compare_op1; - #undef LIB_SPEC #define LIB_SPEC "%{!shared:%{!symbolic:--start-group -lc -lgcc --end-group}}" @@ -567,8 +564,6 @@ struct cum_arg { int nbytes; }; #define SELECT_CC_MODE(OP, X, Y) v850_select_cc_mode (OP, X, Y) -#define NOTICE_UPDATE_CC(EXP, INSN) - /* Nonzero if access to memory by bytes or half words is no faster than accessing full words. */ #define SLOW_BYTE_ACCESS 1 diff --git a/gcc/config/v850/v850.md b/gcc/config/v850/v850.md index 0fad9ea..3cfec74 100644 --- a/gcc/config/v850/v850.md +++ b/gcc/config/v850/v850.md @@ -28,6 +28,42 @@ ;; ;; One day we'll probably need to handle calls to targets more than 4M ;; away. +;; + +;; Condition codes +;; +;; Data movement (load, store, register copy) does not modify condition +;; codes. But there is no way to add two registers together without +;; modifying the condition codes. +;; +;; So we do not expose the condition codes until after reload. The +;; general approach is to have a define_insn_and_split for the basic +;; operation with no condition codes in the pattern (to give the +;; optimizers maximal freedom). The splitter adds a clobber of the +;; condition codes after reload. There is a distinct pattern which +;; sets the condition codes. +;; +;; As noted, data movement does not affect condition codes. +;; +;; Arithmetic generally set the codes in the expected ways, with mul +;; instructions being a notable outlier. div instructions generally +;; do the right thing, except when the output registers are the same +;; when the flags do not get set. We just assume they're clobbered +;; for div instructions to avoid MD bloat with marginal benefit +;; +;; The bit manipulation instructions (clr1, not1, set1) set condition +;; codes, but not in a useful way (they're set to the prior status of +;; the bit). So we just model those as clobbers. tst1 does set the +;; condition codes in a useful way. We could perhaps do better with +;; these by noting they only modify the Z flag, it doesn't seem worth +;; the effort. +;; +;; Byte swaps seem to change the condition codes, but I haven't tried +;; to describe how. +;; +;; I have no documentation on the rotate instructions. They likely +;; set the condition codes, but I've left them as clobbers for now. + ;; The size of instructions in bytes. @@ -352,110 +388,90 @@ ;; ---------------------------------------------------------------------- (define_insn "*v850_tst1" - [(set (cc0) + [(set (reg:CCZ CC_REGNUM) (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "m") (const_int 1) (match_operand:QI 1 "const_int_operand" "n")) (const_int 0)))] - "" + "reload_completed" "tst1 %1,%0" [(set_attr "length" "4")]) ;; This replaces ld.b;sar;andi with tst1;setf nz. +;; Should there be variants for HI or SI modes? -(define_split +(define_insn_and_split "" [(set (match_operand:SI 0 "register_operand" "") (compare (zero_extract:SI (match_operand:QI 1 "memory_operand" "") (const_int 1) (match_operand 2 "const_int_operand" "")) (const_int 0)))] "" - [(set (cc0) (compare (zero_extract:SI (match_dup 1) - (const_int 1) - (match_dup 2)) - (const_int 0))) - (set (match_dup 0) (ne:SI (cc0) (const_int 0)))]) + "#" + "reload_completed" + [(set (reg:CCZ CC_REGNUM) (compare (zero_extract:SI (match_dup 1) + (const_int 1) + (match_dup 2)) + (const_int 0))) + (set (match_dup 0) (ne:SI (reg:CCZ CC_REGNUM) (const_int 0)))]) (define_expand "cbranchsi4" - [(set (cc0) - (compare (match_operand:SI 1 "register_operand" "") - (match_operand:SI 2 "reg_or_int5_operand" ""))) - (set (pc) + [(set (pc) (if_then_else - (match_operator 0 "ordered_comparison_operator" [(cc0) - (const_int 0)]) + (match_operator 0 "comparison_operator" + [(match_operand:SI 1 "register_operand") + (match_operand:SI 2 "reg_or_int5_operand")]) (label_ref (match_operand 3 "" "")) (pc)))] "") -(define_expand "cstoresi4" - [(set (cc0) - (compare (match_operand:SI 2 "register_operand" "") - (match_operand:SI 3 "reg_or_int5_operand" ""))) - (set (match_operand:SI 0 "register_operand") - (match_operator:SI 1 "ordered_comparison_operator" [(cc0) - (const_int 0)]))] - "") - -(define_expand "cmpsi" - [(set (cc0) - (compare (match_operand:SI 0 "register_operand" "r,r") - (match_operand:SI 1 "reg_or_int5_operand" "r,J")))] - "" - { - v850_compare_op0 = operands[0]; - v850_compare_op1 = operands[1]; - DONE; - }) - (define_insn "cmpsi_insn" - [(set (cc0) + [(set (reg:CC CC_REGNUM) (compare (match_operand:SI 0 "register_operand" "r,r") (match_operand:SI 1 "reg_or_int5_operand" "r,J")))] - "" - "@ - cmp %1,%0 - cmp %1,%0" + "reload_completed" + "cmp %1,%0" [(set_attr "length" "2,2")]) -(define_expand "cbranchsf4" +(define_insn_and_split "cbranchsf4" [(set (pc) (if_then_else (match_operator 0 "ordered_comparison_operator" - [(match_operand:SF 1 "register_operand") - (match_operand:SF 2 "register_operand")]) + [(match_operand:SF 1 "register_operand" "r") + (match_operand:SF 2 "register_operand" "r")]) (label_ref (match_operand 3 "")) - (pc))) - (clobber (cc0))] + (pc)))] "TARGET_USE_FPU" -{ - enum rtx_code cond = GET_CODE (operands[0]); - machine_mode mode; - rtx fcc_reg; - rtx cc_reg; - rtx tmp; - - v850_compare_op0 = operands[1]; - v850_compare_op1 = operands[2]; - - if (GET_MODE_CLASS (GET_MODE (v850_compare_op0)) != MODE_FLOAT) - FAIL; - - mode = v850_gen_float_compare (cond, VOIDmode, v850_compare_op0, v850_compare_op1); - fcc_reg = gen_rtx_REG (mode, FCC_REGNUM); - cc_reg = gen_rtx_REG (mode, CC_REGNUM); - emit_insn (gen_rtx_SET (cc_reg, fcc_reg)); - tmp = gen_rtx_fmt_ee (cond, mode, cc_reg, const0_rtx); - tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp, - gen_rtx_LABEL_REF (VOIDmode, operands[3]), pc_rtx); - emit_jump_insn (gen_rtx_SET (pc_rtx, tmp)); - DONE; -}) + "#" + "reload_completed" + [(set (match_dup 4) (match_dup 5)) + (set (pc) + (if_then_else (match_dup 6) + (label_ref (match_dup 3)) + (pc)))] + "{ + /* This will generate the comparison insn at the start of + the sequence and get us the right mode to use for our + condition code registers. */ + enum machine_mode mode + = v850_gen_float_compare (GET_CODE (operands[0]), + GET_MODE (operands[1]), + operands[1], operands[2]); + /* We want operands referring to CC_REGNUM and FCC_REGNUM + in mode MODE. */ + operands[4] = gen_rtx_REG (mode, CC_REGNUM); + operands[5] = gen_rtx_REG (mode, FCC_REGNUM); + if (mode == CC_FPU_NEmode) + operands[6] = gen_rtx_NE (mode, operands[4], const0_rtx); + else + operands[6] = gen_rtx_EQ (mode, operands[4], const0_rtx); +}") (define_insn "cstoresf4" [(set (match_operand:SI 0 "register_operand" "=r") (match_operator:SI 1 "ordered_comparison_operator" [(match_operand:SF 2 "register_operand" "r") - (match_operand:SF 3 "register_operand" "r")]))] + (match_operand:SF 3 "register_operand" "r")])) + (clobber (reg:CC CC_REGNUM))] "TARGET_USE_FPU" { if (GET_CODE (operands[1]) == GT || GET_CODE (operands[1]) == GE) @@ -471,44 +487,47 @@ [(set_attr "length" "12") (set_attr "type" "fpu")]) -(define_expand "cbranchdf4" +(define_insn_and_split "cbranchdf4" [(set (pc) (if_then_else (match_operator 0 "ordered_comparison_operator" - [(match_operand:DF 1 "even_reg_operand") - (match_operand:DF 2 "even_reg_operand")]) + [(match_operand:DF 1 "even_reg_operand" "r") + (match_operand:DF 2 "even_reg_operand" "r")]) (label_ref (match_operand 3 "")) - (pc))) - (clobber (cc0))] + (pc)))] "TARGET_USE_FPU" -{ - enum rtx_code cond = GET_CODE (operands[0]); - machine_mode mode; - rtx fcc_reg; - rtx cc_reg; - rtx tmp; - - v850_compare_op0 = operands[1]; - v850_compare_op1 = operands[2]; - - if (GET_MODE_CLASS (GET_MODE (v850_compare_op0)) != MODE_FLOAT) - FAIL; - - mode = v850_gen_float_compare (cond, VOIDmode, v850_compare_op0, v850_compare_op1); - fcc_reg = gen_rtx_REG (mode, FCC_REGNUM); - cc_reg = gen_rtx_REG (mode, CC_REGNUM); - emit_insn (gen_rtx_SET (cc_reg, fcc_reg)); - tmp = gen_rtx_fmt_ee (cond, mode, cc_reg, const0_rtx); - tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp, - gen_rtx_LABEL_REF (VOIDmode, operands[3]), pc_rtx); - emit_jump_insn (gen_rtx_SET (pc_rtx, tmp)); - DONE; -}) + "#" + "reload_completed" +;; How to get the mode here? + [(set (match_dup 4) (match_dup 5)) + (set (pc) + (if_then_else (match_dup 6) + (label_ref (match_dup 3)) + (pc)))] + "{ + /* This will generate the comparison insn at the start of + the sequence and get us the right mode to use for our + condition code registers. */ + enum machine_mode mode + = v850_gen_float_compare (GET_CODE (operands[0]), + GET_MODE (operands[1]), + operands[1], operands[2]); + PUT_MODE (operands[0], mode); + /* We want operands referring to CC_REGNUM and FCC_REGNUM + in mode MODE. */ + operands[4] = gen_rtx_REG (mode, CC_REGNUM); + operands[5] = gen_rtx_REG (mode, FCC_REGNUM); + if (mode == CC_FPU_NEmode) + operands[6] = gen_rtx_NE (mode, operands[4], const0_rtx); + else + operands[6] = gen_rtx_EQ (mode, operands[4], const0_rtx); +}") (define_insn "cstoredf4" [(set (match_operand:SI 0 "register_operand" "=r") (match_operator:SI 1 "ordered_comparison_operator" [(match_operand:DF 2 "even_reg_operand" "r") - (match_operand:DF 3 "even_reg_operand" "r")]))] + (match_operand:DF 3 "even_reg_operand" "r")])) + (clobber (reg:CC CC_REGNUM))] "TARGET_USE_FPU" { if (GET_CODE (operands[1]) == GT || GET_CODE (operands[1]) == GE) @@ -524,38 +543,25 @@ [(set_attr "length" "12") (set_attr "type" "fpu")]) -(define_expand "cmpsf" - [(set (reg:CC CC_REGNUM) - (compare (match_operand:SF 0 "register_operand" "r") - (match_operand:SF 1 "register_operand" "r")))] - "TARGET_USE_FPU" - { - v850_compare_op0 = operands[0]; - v850_compare_op1 = operands[1]; - DONE; - }) - -(define_expand "cmpdf" - [(set (reg:CC CC_REGNUM) - (compare (match_operand:DF 0 "even_reg_operand" "r") - (match_operand:DF 1 "even_reg_operand" "r")))] - "TARGET_USE_FPU" - { - v850_compare_op0 = operands[0]; - v850_compare_op1 = operands[1]; - DONE; - }) - ;; ---------------------------------------------------------------------- ;; ADD INSTRUCTIONS ;; ---------------------------------------------------------------------- -(define_insn "addsi3" +(define_insn_and_split "addsi3" + [(set (match_operand:SI 0 "register_operand" "=r,r,r") + (plus:SI (match_operand:SI 1 "register_operand" "%0,r,r") + (match_operand:SI 2 "nonmemory_operand" "rJ,K,U")))] + "" + "#" + "reload_completed" + [(parallel [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2))) + (clobber (reg:CC CC_REGNUM))])]) + +(define_insn "addsi3_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r,r,r") (plus:SI (match_operand:SI 1 "register_operand" "%0,r,r") (match_operand:SI 2 "nonmemory_operand" "rJ,K,U"))) (clobber (reg:CC CC_REGNUM))] - "" "@ add %2,%0 @@ -566,8 +572,17 @@ ;; ---------------------------------------------------------------------- ;; SUBTRACT INSTRUCTIONS ;; ---------------------------------------------------------------------- +(define_insn_and_split "subsi3" + [(set (match_operand:SI 0 "register_operand" "=r,r") + (minus:SI (match_operand:SI 1 "register_operand" "0,r") + (match_operand:SI 2 "register_operand" "r,0")))] + "" + "#" + "reload_completed" + [(parallel [(set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2))) + (clobber (reg:CC CC_REGNUM))])]) -(define_insn "subsi3" +(define_insn "subsi3_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r,r") (minus:SI (match_operand:SI 1 "register_operand" "0,r") (match_operand:SI 2 "register_operand" "r,0"))) @@ -578,7 +593,16 @@ subr %1,%0" [(set_attr "length" "2,2")]) -(define_insn "negsi2" +(define_insn_and_split "negsi2" + [(set (match_operand:SI 0 "register_operand" "=r") + (neg:SI (match_operand:SI 1 "register_operand" "0")))] + "" + "#" + "reload_completed" + [(parallel [(set (match_dup 0) (neg:SI (match_dup 1))) + (clobber (reg:CC CC_REGNUM))])]) + +(define_insn "negsi2_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r") (neg:SI (match_operand:SI 1 "register_operand" "0"))) (clobber (reg:CC CC_REGNUM))] @@ -703,7 +727,7 @@ (match_dup 2))) (clobber (reg:CC CC_REGNUM))] "TARGET_V850E_UP" - "sxh %0\n\tdivh %2,%0,%3" + "sxh %0\\n\\tdivh %2,%0,%3" [(set_attr "length" "6") (set_attr "type" "div")]) @@ -719,7 +743,7 @@ (match_dup 2))) (clobber (reg:CC CC_REGNUM))] "TARGET_V850E_UP" - "zxh %0\n\tdivhu %2,%0,%3" + "zxh %0\\n\\ndivhu %2,%0,%3" [(set_attr "length" "6") (set_attr "type" "div")]) @@ -785,12 +809,22 @@ [(set_attr "length" "4") (set_attr "type" "bit1")]) -(define_insn "andsi3" +(define_insn_and_split "andsi3" + [(set (match_operand:SI 0 "register_operand" "=r,r,r") + (and:SI (match_operand:SI 1 "register_operand" "%0,0,r") + (match_operand:SI 2 "nonmemory_operand" "r,I,M")))] + "" + "#" + "reload_completed" + [(parallel [(set (match_dup 0) (and:SI (match_dup 1) (match_dup 2))) + (clobber (reg:CC CC_REGNUM))])]) + +(define_insn "andsi3_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r,r,r") (and:SI (match_operand:SI 1 "register_operand" "%0,0,r") (match_operand:SI 2 "nonmemory_operand" "r,I,M"))) (clobber (reg:CC CC_REGNUM))] - "" + "reload_completed" "@ and %2,%0 and %.,%0 @@ -860,7 +894,17 @@ [(set_attr "length" "4") (set_attr "type" "bit1")]) -(define_insn "iorsi3" +(define_insn_and_split "iorsi3" + [(set (match_operand:SI 0 "register_operand" "=r,r,r") + (ior:SI (match_operand:SI 1 "register_operand" "%0,0,r") + (match_operand:SI 2 "nonmemory_operand" "r,I,M")))] + "" + "#" + "reload_completed" + [(parallel [(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 2))) + (clobber (reg:CC CC_REGNUM))])]) + +(define_insn "iorsi3_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r,r,r") (ior:SI (match_operand:SI 1 "register_operand" "%0,0,r") (match_operand:SI 2 "nonmemory_operand" "r,I,M"))) @@ -935,7 +979,17 @@ [(set_attr "length" "4") (set_attr "type" "bit1")]) -(define_insn "xorsi3" +(define_insn_and_split "xorsi3" + [(set (match_operand:SI 0 "register_operand" "=r,r,r") + (xor:SI (match_operand:SI 1 "register_operand" "%0,0,r") + (match_operand:SI 2 "nonmemory_operand" "r,I,M")))] + "" + "#" + "reload_completed" + [(parallel [(set (match_dup 0) (xor:SI (match_dup 1) (match_dup 2))) + (clobber (reg:CC CC_REGNUM))])]) + +(define_insn "xorsi3_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r,r,r") (xor:SI (match_operand:SI 1 "register_operand" "%0,0,r") (match_operand:SI 2 "nonmemory_operand" "r,I,M"))) @@ -946,12 +1000,23 @@ xor %.,%0 xori %2,%1,%0" [(set_attr "length" "2,2,4")]) + ;; ---------------------------------------------------------------------- ;; NOT INSTRUCTIONS ;; ---------------------------------------------------------------------- -(define_insn "one_cmplsi2" +(define_insn_and_split "one_cmplsi2" + [(set (match_operand:SI 0 "register_operand" "=r") + (not:SI (match_operand:SI 1 "register_operand" "r")))] + "" + "#" + "reload_completed" + [(parallel [(set (match_dup 0) (not:SI (match_dup 1))) + (clobber (reg:CC CC_REGNUM))])]) + + +(define_insn "one_cmplsi2_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r") (not:SI (match_operand:SI 1 "register_operand" "r"))) (clobber (reg:CC CC_REGNUM))] @@ -977,7 +1042,8 @@ [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r") (match_operand:SI 1 "immediate_operand" "n") (match_operand:SI 2 "immediate_operand" "n")) - (match_operand:SI 3 "register_operand" "r"))] + (match_operand:SI 3 "register_operand" "r")) + (clobber (reg:CC CC_REGNUM))] "TARGET_V850E3V5_UP" "bins %3, %2, %1, %0" [(set_attr "length" "4")]) @@ -986,20 +1052,46 @@ ;; Scc INSTRUCTIONS ;; ----------------------------------------------------------------- -(define_insn "*setcc" +(define_insn_and_split "*cbranchsi4_insn" + [(set (pc) + (if_then_else (match_operator 0 "comparison_operator" + [(match_operand:SI 1 "register_operand" "r") + (match_operand:SI 2 "reg_or_int5_operand" "rJ")]) + (label_ref (match_operand 3 "" "")) + (pc)))] + "" + "#" + "reload_completed" + [(set (reg:CC CC_REGNUM) + (compare:CC (match_dup 1) (match_dup 2))) + (set (pc) + (if_then_else (match_op_dup 0 + [(reg:CC CC_REGNUM) (const_int 0)]) + (label_ref (match_dup 3)) + (pc)))] + "") + + +(define_insn_and_split "cstoresi4" [(set (match_operand:SI 0 "register_operand" "=r") (match_operator:SI 1 "comparison_operator" - [(cc0) (const_int 0)]))] + [(match_operand:SI 2 "register_operand" "r") + (match_operand:SI 3 "reg_or_int5_operand" "rJ")]))] "" - "setf %c1,%0" - [(set_attr "length" "4")]) + "#" + "reload_completed" + [(set (reg:CC CC_REGNUM) + (compare:CC (match_dup 2) (match_dup 3))) + (set (match_dup 0) (match_op_dup 1 + [(reg:CC CC_REGNUM) (const_int 0)]))] + "") -(define_insn "setf_insn" +(define_insn "*setcc_insn" [(set (match_operand:SI 0 "register_operand" "=r") - (match_operator:SI 1 "comparison_operator" - [(reg:CC CC_REGNUM) (const_int 0)]))] - "" - "setf %b1,%0" + (match_operator:SI 1 "comparison_operator" + [(reg:CC CC_REGNUM) (const_int 0)]))] + "reload_completed" + "setf %c1,%0" [(set_attr "length" "4")]) (define_insn "set_z_insn" @@ -1065,12 +1157,6 @@ } }) -;; ??? Clobbering the condition codes is overkill. - -;; ??? We sometimes emit an unnecessary compare instruction because the -;; condition codes may have already been set by an earlier instruction, -;; but we have no code here to avoid the compare if it is unnecessary. - (define_insn "movsicc_normal_cc" [(set (match_operand:SI 0 "register_operand" "=r") (if_then_else:SI @@ -1078,7 +1164,7 @@ [(reg:CC CC_REGNUM) (const_int 0)]) (match_operand:SI 2 "reg_or_int5_operand" "rJ") (match_operand:SI 3 "reg_or_0_operand" "rI")))] - "(TARGET_V850E_UP)" + "reload_completed && (TARGET_V850E_UP)" "cmov %c1,%2,%z3,%0"; [(set_attr "length" "6")]) @@ -1089,11 +1175,11 @@ [(reg:CC CC_REGNUM) (const_int 0)]) (match_operand:SI 2 "reg_or_0_operand" "rI") (match_operand:SI 3 "reg_or_int5_operand" "rJ")))] - "(TARGET_V850E_UP)" + "reload_completed && (TARGET_V850E_UP)" "cmov %C1,%3,%z2,%0" [(set_attr "length" "6")]) -(define_insn "*movsicc_normal" +(define_insn_and_split "*movsicc_normal" [(set (match_operand:SI 0 "register_operand" "=r") (if_then_else:SI (match_operator 1 "comparison_operator" @@ -1102,21 +1188,35 @@ (match_operand:SI 2 "reg_or_int5_operand" "rJ") (match_operand:SI 3 "reg_or_0_operand" "rI")))] "(TARGET_V850E_UP)" - "cmp %5,%4 ; cmov %c1,%2,%z3,%0" - [(set_attr "length" "6")]) + "#" + "reload_completed" + [(set (reg:CC CC_REGNUM) + (compare:CC (match_dup 4) (match_dup 5))) + (set (match_dup 0) + (if_then_else:SI (match_op_dup 1 + [(reg:CC CC_REGNUM) (const_int 0)]) + (match_dup 2) (match_dup 3)))]) -(define_insn "*movsicc_reversed" + +(define_insn_and_split "*movsicc_reversed" [(set (match_operand:SI 0 "register_operand" "=r") (if_then_else:SI (match_operator 1 "comparison_operator" [(match_operand:SI 4 "register_operand" "r") (match_operand:SI 5 "reg_or_int5_operand" "rJ")]) - (match_operand:SI 2 "reg_or_0_operand" "rI") - (match_operand:SI 3 "reg_or_int5_operand" "rJ")))] + (match_operand:SI 2 "reg_or_int5_operand" "rI") + (match_operand:SI 3 "reg_or_0_operand" "rJ")))] "(TARGET_V850E_UP)" - "cmp %5,%4 ; cmov %C1,%3,%z2,%0" - [(set_attr "length" "6")]) + "#" + "reload_completed" + [(set (reg:CC CC_REGNUM) + (compare:CC (match_dup 4) (match_dup 5))) + (set (match_dup 0) + (if_then_else:SI (match_op_dup 1 + [(reg:CC CC_REGNUM) (const_int 0)]) + (match_dup 2) (match_dup 3)))]) +;; We could expose the setting of the condition codes here. (define_insn "*movsicc_tst1" [(set (match_operand:SI 0 "register_operand" "=r") (if_then_else:SI @@ -1127,11 +1227,13 @@ (match_operand 3 "const_int_operand" "n")) (const_int 0)]) (match_operand:SI 4 "reg_or_int5_operand" "rJ") - (match_operand:SI 5 "reg_or_0_operand" "rI")))] + (match_operand:SI 5 "reg_or_0_operand" "rI"))) + (clobber (reg:CC CC_REGNUM))] "(TARGET_V850E_UP)" "tst1 %3,%2 ; cmov %c1,%4,%z5,%0" [(set_attr "length" "8")]) +;; We could expose the setting of the condition codes here. (define_insn "*movsicc_tst1_reversed" [(set (match_operand:SI 0 "register_operand" "=r") (if_then_else:SI @@ -1142,7 +1244,8 @@ (match_operand 3 "const_int_operand" "n")) (const_int 0)]) (match_operand:SI 4 "reg_or_0_operand" "rI") - (match_operand:SI 5 "reg_or_int5_operand" "rJ")))] + (match_operand:SI 5 "reg_or_int5_operand" "rJ"))) + (clobber (reg:CC CC_REGNUM))] "(TARGET_V850E_UP)" "tst1 %3,%2 ; cmov %C1,%5,%z4,%0" [(set_attr "length" "8")]) @@ -1152,6 +1255,9 @@ ;; second pattern by subsequent combining. As above, we must include the ;; comparison to avoid input reloads in an insn using cc0. +;; We could expose the setting of the condition codes here. +;; However, I haven't seen this pattern used, so I'm not going +;; to bother. (define_insn "*sasf" [(set (match_operand:SI 0 "register_operand" "=r") (ior:SI @@ -1235,7 +1341,8 @@ [(ashift:SI (match_operand:SI 1 "register_operand" "r") (match_operand:SI 2 "const_int_operand" "n")) (lshiftrt:SI (match_dup 1) - (match_operand:SI 3 "const_int_operand" "n"))]))] + (match_operand:SI 3 "const_int_operand" "n"))])) + (clobber (reg:CC CC_REGNUM))] "TARGET_V850E3V5_UP && (INTVAL (operands[2]) + INTVAL (operands[3]) == 32)" "rotl %2, %1, %0" [(set_attr "length" "4")]) @@ -1246,7 +1353,8 @@ [(lshiftrt:SI (match_operand:SI 1 "register_operand" "r") (match_operand:SI 3 "const_int_operand" "n")) (ashift:SI (match_dup 1) - (match_operand:SI 2 "const_int_operand" "n"))]))] + (match_operand:SI 2 "const_int_operand" "n"))])) + (clobber (reg:CC CC_REGNUM))] "TARGET_V850E3V5_UP && (INTVAL (operands[2]) + INTVAL (operands[3]) == 32)" "rotl %2, %1, %0" [(set_attr "length" "4")]) @@ -1287,9 +1395,11 @@ } ) +;; Note the embedded arithmetic. That affects the condition codes! (define_insn "fix_loop_counter" [(unspec:SI [(match_operand:SI 0 "register_operand" "+r,!m") - (clobber (match_scratch:SI 1 "=X,r"))] UNSPEC_LOOP)] + (clobber (match_scratch:SI 1 "=X,r"))] UNSPEC_LOOP) + (clobber (reg:CC CC_REGNUM))] "TARGET_V850E3V5_UP && TARGET_LOOP" { switch (which_alternative) @@ -1349,68 +1459,52 @@ ;; Conditional jump instructions -(define_insn "*branch_normal" +(define_insn_and_split "*cbranchsi4_insn" [(set (pc) - (if_then_else (match_operator 1 "comparison_operator" - [(cc0) (const_int 0)]) - (label_ref (match_operand 0 "" "")) + (if_then_else (match_operator 0 "comparison_operator" + [(match_operand:SI 1 "register_operand" "r") + (match_operand:SI 2 "reg_or_int5_operand" "rJ")]) + (label_ref (match_operand 3 "" "")) (pc)))] "" -{ - if (get_attr_length (insn) == 2) - return "b%b1 %l0"; - if (TARGET_V850E3V5_UP && get_attr_length (insn) == 4) - return "b%b1 %l0"; - return "b%B1 .+6 ; jr %l0"; -} - [(set (attr "length") - (if_then_else (lt (abs (minus (match_dup 0) (pc))) - (const_int 256)) - (const_int 2) - (if_then_else (lt (abs (minus (match_dup 0) (pc))) - (const_int 65536)) - (const_int 4) - (const_int 6))))]) + "#" + "reload_completed" + [(set (reg:CC CC_REGNUM) + (compare:CC (match_dup 1) (match_dup 2))) + (set (pc) + (if_then_else (match_op_dup 0 + [(reg:CC CC_REGNUM) (const_int 0)]) + (label_ref (match_dup 3)) + (pc)))] + "") -(define_insn "*branch_invert" +(define_insn "*branch_normal" [(set (pc) (if_then_else (match_operator 1 "comparison_operator" - [(cc0) (const_int 0)]) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" -{ - if (get_attr_length (insn) == 2) - return "b%B1 %l0"; - - if (TARGET_V850E3V5_UP && get_attr_length (insn) == 4) - return "b%B1 %l0"; - - return "b%b1 .+6 ; jr %l0"; -} - [(set (attr "length") - (if_then_else (lt (abs (minus (match_dup 0) (pc))) - (const_int 256)) - (const_int 2) - (if_then_else (lt (abs (minus (match_dup 0) (pc))) - (const_int 65536)) - (const_int 4) - (const_int 6))))]) - -(define_insn "branch_z_normal" - [(set (pc) - (if_then_else (match_operand 1 "v850_float_z_comparison_operator" "") + [(reg CC_REGNUM) (const_int 0)]) (label_ref (match_operand 0 "" "")) (pc)))] - "TARGET_V850E2V3_UP" + "reload_completed" { + bool nzmode = GET_MODE (XEXP (operands[1], 0)) == CCNZmode; if (get_attr_length (insn) == 2) - return "bz %l0"; - + { + if (nzmode) + return "b%d1 %l0"; + else + return "b%b1 %l0"; + } if (TARGET_V850E3V5_UP && get_attr_length (insn) == 4) - return "bz %l0"; - - return "bnz 1f ; jr %l0 ; 1:"; + { + if (nzmode) + return "b%d1 %l0"; + else + return "b%b1 %l0"; + } + if (nzmode) + return "b%D1 .+6 ; jr %l0"; + else + return "b%B1 .+6 ; jr %l0"; } [(set (attr "length") (if_then_else (lt (abs (minus (match_dup 0) (pc))) @@ -1421,68 +1515,36 @@ (const_int 4) (const_int 6))))]) -(define_insn "*branch_z_invert" +(define_insn "*branch_invert" [(set (pc) - (if_then_else (match_operand 1 "v850_float_z_comparison_operator" "") + (if_then_else (match_operator 1 "comparison_operator" + [(reg CC_REGNUM) (const_int 0)]) (pc) (label_ref (match_operand 0 "" ""))))] - "TARGET_V850E2V3_UP" + "reload_completed" { - if (get_attr_length (insn) == 2) - return "bnz %l0"; - - if (TARGET_V850E3V5_UP && get_attr_length (insn) == 4) - return "bnz %l0"; - - return "bz 1f ; jr %l0 ; 1:"; -} - [(set (attr "length") - (if_then_else (lt (abs (minus (match_dup 0) (pc))) - (const_int 256)) - (const_int 2) - (if_then_else (lt (abs (minus (match_dup 0) (pc))) - (const_int 65536)) - (const_int 4) - (const_int 6))))]) + bool nzmode = GET_MODE (XEXP (operands[1], 0)) == CCNZmode; -(define_insn "branch_nz_normal" - [(set (pc) - (if_then_else (match_operand 1 "v850_float_nz_comparison_operator" "") - (label_ref (match_operand 0 "" "")) - (pc)))] - "TARGET_V850E2V3_UP" -{ if (get_attr_length (insn) == 2) - return "bnz %l0"; - - if (TARGET_V850E3V5_UP && get_attr_length (insn) == 4) - return "bnz %l0"; - - return "bz 1f ; jr %l0 ; 1:"; -} -[(set (attr "length") - (if_then_else (lt (abs (minus (match_dup 0) (pc))) - (const_int 256)) - (const_int 2) - (if_then_else (lt (abs (minus (match_dup 0) (pc))) - (const_int 65536)) - (const_int 4) - (const_int 6))))]) - -(define_insn "*branch_nz_invert" - [(set (pc) - (if_then_else (match_operand 1 "v850_float_nz_comparison_operator" "") - (pc) - (label_ref (match_operand 0 "" ""))))] - "TARGET_V850E2V3_UP" -{ - if (get_attr_length (insn) == 2) - return "bz %l0"; + { + if (nzmode) + return "b%D1 %l0"; + else + return "b%B1 %l0"; + } if (TARGET_V850E3V5_UP && get_attr_length (insn) == 4) - return "bz %l0"; + { + if (nzmode) + return "b%D1 %l0"; + else + return "b%B1 %l0"; + } - return "bnz 1f ; jr %l0 ; 1:"; + if (nzmode) + return "b%d1 .+6 ; jr %l0"; + else + return "b%b1 .+6 ; jr %l0"; } [(set (attr "length") (if_then_else (lt (abs (minus (match_dup 0) (pc))) @@ -1602,6 +1664,7 @@ (define_insn "call_internal_short" [(call (mem:QI (match_operand:SI 0 "call_address_operand" "S,r")) (match_operand:SI 1 "general_operand" "g,g")) + (clobber (reg:CC CC_REGNUM)) (clobber (reg:SI 31))] "! TARGET_LONG_CALLS" { @@ -1620,6 +1683,7 @@ (define_insn "call_internal_long" [(call (mem:QI (match_operand:SI 0 "call_address_operand" "S,r")) (match_operand:SI 1 "general_operand" "g,g")) + (clobber (reg:CC CC_REGNUM)) (clobber (reg:SI 31))] "TARGET_LONG_CALLS" { @@ -1668,6 +1732,7 @@ [(set (match_operand 0 "" "=r,r") (call (mem:QI (match_operand:SI 1 "call_address_operand" "S,r")) (match_operand:SI 2 "general_operand" "g,g"))) + (clobber (reg:CC CC_REGNUM)) (clobber (reg:SI 31))] "! TARGET_LONG_CALLS" { @@ -1687,6 +1752,7 @@ [(set (match_operand 0 "" "=r,r") (call (mem:QI (match_operand:SI 1 "call_address_operand" "S,r")) (match_operand:SI 2 "general_operand" "g,g"))) + (clobber (reg:CC CC_REGNUM)) (clobber (reg:SI 31))] "TARGET_LONG_CALLS" { @@ -1719,6 +1785,7 @@ ;; EXTEND INSTRUCTIONS ;; ---------------------------------------------------------------------- +;; We only need the CC clobber because of the andi alternative (define_insn "*zero_extendhisi2_v850e" [(set (match_operand:SI 0 "register_operand" "=r,r,r,r") (zero_extend:SI @@ -1791,8 +1858,7 @@ (define_insn "*extendhisi_insn" [(set (match_operand:SI 0 "register_operand" "=r,r,r") - (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "0,Q,m"))) - (clobber (reg:CC CC_REGNUM))] + (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "0,Q,m")))] "(TARGET_V850E_UP)" "@ sxh %0 @@ -1822,8 +1888,7 @@ (define_insn "*extendqisi_insn" [(set (match_operand:SI 0 "register_operand" "=r,r,r") - (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0,Q,m"))) - (clobber (reg:CC CC_REGNUM))] + (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0,Q,m")))] "(TARGET_V850E_UP)" "@ sxb %0 @@ -1853,7 +1918,18 @@ ;; SHIFTS ;; ---------------------------------------------------------------------- -(define_insn "ashlsi3" +(define_insn_and_split "ashlsi3" + [(set (match_operand:SI 0 "register_operand" "=r,r") + (ashift:SI + (match_operand:SI 1 "register_operand" "0,0") + (match_operand:SI 2 "nonmemory_operand" "r,N")))] + "" + "#" + "reload_completed" + [(parallel [(set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 2))) + (clobber (reg:CC CC_REGNUM))])]) + +(define_insn "ashlsi3_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r,r") (ashift:SI (match_operand:SI 1 "register_operand" "0,0") @@ -1865,7 +1941,7 @@ shl %2,%0" [(set_attr "length" "4,2")]) -(define_insn "ashlsi3_v850e2" +(define_insn "ashlsi3_v850e2_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r") (ashift:SI (match_operand:SI 1 "register_operand" "r") @@ -1875,7 +1951,18 @@ "shl %2,%1,%0" [(set_attr "length" "4")]) -(define_insn "lshrsi3" +(define_insn_and_split "lshrsi3" + [(set (match_operand:SI 0 "register_operand" "=r,r") + (lshiftrt:SI + (match_operand:SI 1 "register_operand" "0,0") + (match_operand:SI 2 "nonmemory_operand" "r,N")))] + "" + "#" + "reload_completed" + [(parallel [(set (match_dup 0) (lshiftrt:SI (match_dup 1) (match_dup 2))) + (clobber (reg:CC CC_REGNUM))])]) + +(define_insn "lshrsi3_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r,r") (lshiftrt:SI (match_operand:SI 1 "register_operand" "0,0") @@ -1887,7 +1974,7 @@ shr %2,%0" [(set_attr "length" "4,2")]) -(define_insn "lshrsi3_v850e2" +(define_insn "lshrsi3_v850e2_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r") (lshiftrt:SI (match_operand:SI 1 "register_operand" "r") @@ -1897,7 +1984,18 @@ "shr %2,%1,%0" [(set_attr "length" "4")]) -(define_insn "ashrsi3" +(define_insn_and_split "ashrsi3" + [(set (match_operand:SI 0 "register_operand" "=r,r") + (ashiftrt:SI + (match_operand:SI 1 "register_operand" "0,0") + (match_operand:SI 2 "nonmemory_operand" "r,N")))] + "" + "#" + "reload_completed" + [(parallel [(set (match_dup 0) (ashiftrt:SI (match_dup 1) (match_dup 2))) + (clobber (reg:CC CC_REGNUM))])]) + +(define_insn "ashrsi3_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r,r") (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0") @@ -1909,7 +2007,7 @@ sar %2,%0" [(set_attr "length" "4,2")]) -(define_insn "ashrsi3_v850e2" +(define_insn "ashrsi3_v850e2_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r") (ashiftrt:SI (match_operand:SI 1 "register_operand" "r") @@ -2279,6 +2377,8 @@ ;; ---------------- special insns ;; +;; reciprocal + ;; Generic code demands that the recip and rsqrt named patterns ;; have precisely one operand. So that's what we expose in the ;; expander via the strange UNSPEC. However, those expanders @@ -2417,7 +2517,7 @@ [(set (reg:CC_FPU_LE FCC_REGNUM) (compare:CC_FPU_LE (match_operand:SF 0 "register_operand" "r") (match_operand:SF 1 "register_operand" "r")))] - "TARGET_USE_FPU" + "reload_completed && TARGET_USE_FPU" "cmpf.s le, %z0, %z1" [(set_attr "length" "4") (set_attr "type" "fpu")]) @@ -2426,7 +2526,7 @@ [(set (reg:CC_FPU_LT FCC_REGNUM) (compare:CC_FPU_LT (match_operand:SF 0 "register_operand" "r") (match_operand:SF 1 "register_operand" "r")))] - "TARGET_USE_FPU" + "reload_completed && TARGET_USE_FPU" "cmpf.s lt, %z0, %z1" [(set_attr "length" "4") (set_attr "type" "fpu")]) @@ -2435,7 +2535,7 @@ [(set (reg:CC_FPU_GE FCC_REGNUM) (compare:CC_FPU_GE (match_operand:SF 0 "register_operand" "r") (match_operand:SF 1 "register_operand" "r")))] - "TARGET_USE_FPU" + "reload_completed && TARGET_USE_FPU" "cmpf.s le, %z1, %z0" [(set_attr "length" "4") (set_attr "type" "fpu")]) @@ -2444,7 +2544,7 @@ [(set (reg:CC_FPU_GT FCC_REGNUM) (compare:CC_FPU_GT (match_operand:SF 0 "register_operand" "r") (match_operand:SF 1 "register_operand" "r")))] - "TARGET_USE_FPU" + "reload_completed && TARGET_USE_FPU" "cmpf.s lt, %z1, %z0" [(set_attr "length" "4") (set_attr "type" "fpu")]) @@ -2453,7 +2553,7 @@ [(set (reg:CC_FPU_EQ FCC_REGNUM) (compare:CC_FPU_EQ (match_operand:SF 0 "register_operand" "r") (match_operand:SF 1 "register_operand" "r")))] - "TARGET_USE_FPU" + "reload_completed && TARGET_USE_FPU" "cmpf.s eq, %z0, %z1" [(set_attr "length" "4") (set_attr "type" "fpu")]) @@ -2464,7 +2564,7 @@ [(set (reg:CC_FPU_LE FCC_REGNUM) (compare:CC_FPU_LE (match_operand:DF 0 "even_reg_operand" "r") (match_operand:DF 1 "even_reg_operand" "r")))] - "TARGET_USE_FPU" + "reload_completed && TARGET_USE_FPU" "cmpf.d le, %z0, %z1" [(set_attr "length" "4") (set_attr "type" "fpu")]) @@ -2473,7 +2573,7 @@ [(set (reg:CC_FPU_LT FCC_REGNUM) (compare:CC_FPU_LT (match_operand:DF 0 "even_reg_operand" "r") (match_operand:DF 1 "even_reg_operand" "r")))] - "TARGET_USE_FPU" + "reload_completed && TARGET_USE_FPU" "cmpf.d lt, %z0, %z1" [(set_attr "length" "4") (set_attr "type" "fpu")]) @@ -2482,7 +2582,7 @@ [(set (reg:CC_FPU_GE FCC_REGNUM) (compare:CC_FPU_GE (match_operand:DF 0 "even_reg_operand" "r") (match_operand:DF 1 "even_reg_operand" "r")))] - "TARGET_USE_FPU" + "reload_completed && TARGET_USE_FPU" "cmpf.d le, %z1, %z0" [(set_attr "length" "4") (set_attr "type" "fpu")]) @@ -2491,7 +2591,7 @@ [(set (reg:CC_FPU_GT FCC_REGNUM) (compare:CC_FPU_GT (match_operand:DF 0 "even_reg_operand" "r") (match_operand:DF 1 "even_reg_operand" "r")))] - "TARGET_USE_FPU" + "reload_completed && TARGET_USE_FPU" "cmpf.d lt, %z1, %z0" [(set_attr "length" "4") (set_attr "type" "fpu")]) @@ -2500,7 +2600,7 @@ [(set (reg:CC_FPU_EQ FCC_REGNUM) (compare:CC_FPU_EQ (match_operand:DF 0 "even_reg_operand" "r") (match_operand:DF 1 "even_reg_operand" "r")))] - "TARGET_USE_FPU" + "reload_completed && TARGET_USE_FPU" "cmpf.d eq, %z0, %z1" [(set_attr "length" "4") (set_attr "type" "fpu")]) @@ -2512,7 +2612,8 @@ (define_insn "trfsr" [(set (match_operand 0 "" "") (match_operand 1 "" ""))] - "TARGET_USE_FPU + "reload_completed + && TARGET_USE_FPU && GET_MODE(operands[0]) == GET_MODE(operands[1]) && GET_CODE(operands[0]) == REG && REGNO (operands[0]) == CC_REGNUM && GET_CODE(operands[1]) == REG && REGNO (operands[1]) == FCC_REGNUM @@ -2668,7 +2769,8 @@ ;; Initialize an interrupt function. Do not depend on TARGET_PROLOG_FUNCTION. (define_insn "callt_save_interrupt" - [(unspec_volatile [(const_int 0)] 2)] + [(unspec_volatile [(const_int 0)] 2) + (clobber (reg:CC CC_REGNUM))] "(TARGET_V850E_UP) && !TARGET_DISABLE_CALLT" ;; The CALLT instruction stores the next address of CALLT to CTPC register ;; without saving its previous value. So if the interrupt handler @@ -2689,7 +2791,8 @@ [(set_attr "length" "26")]) (define_insn "callt_return_interrupt" - [(unspec_volatile [(const_int 0)] 3)] + [(unspec_volatile [(const_int 0)] 3) + (clobber (reg:CC CC_REGNUM))] "(TARGET_V850E_UP) && !TARGET_DISABLE_CALLT" "callt ctoff(__callt_return_interrupt)" [(set_attr "length" "2")]) @@ -2700,7 +2803,8 @@ (set (mem:SI (plus:SI (reg:SI 3) (const_int -16))) (reg:SI 4)) (set (mem:SI (plus:SI (reg:SI 3) (const_int -12))) (reg:SI 1)) (set (mem:SI (plus:SI (reg:SI 3) (const_int -8))) (reg:SI 10)) - (set (mem:SI (plus:SI (reg:SI 3) (const_int -4))) (reg:SI 11))] + (set (mem:SI (plus:SI (reg:SI 3) (const_int -4))) (reg:SI 11)) + (clobber (reg:CC CC_REGNUM))] "" { if (TARGET_PROLOG_FUNCTION && !TARGET_LONG_CALLS) @@ -2733,7 +2837,8 @@ (set (reg:SI 10) (mem:SI (plus:SI (reg:SI 3) (const_int 12)))) (set (reg:SI 1) (mem:SI (plus:SI (reg:SI 3) (const_int 8)))) (set (reg:SI 4) (mem:SI (plus:SI (reg:SI 3) (const_int 4)))) - (set (reg:SI 30) (mem:SI (reg:SI 3)))] + (set (reg:SI 30) (mem:SI (reg:SI 3))) + (clobber (reg:CC CC_REGNUM))] "" { if (TARGET_PROLOG_FUNCTION && !TARGET_LONG_CALLS) @@ -2763,13 +2868,15 @@ ;; insns this complicated. (define_insn "callt_save_all_interrupt" - [(unspec_volatile [(const_int 0)] 0)] + [(unspec_volatile [(const_int 0)] 0) + (clobber (reg:CC CC_REGNUM))] "(TARGET_V850E_UP) && !TARGET_DISABLE_CALLT" "callt ctoff(__callt_save_all_interrupt)" [(set_attr "length" "2")]) (define_insn "save_all_interrupt" - [(unspec_volatile [(const_int 0)] 0)] + [(unspec_volatile [(const_int 0)] 0) + (clobber (reg:CC CC_REGNUM))] "" { if (TARGET_PROLOG_FUNCTION && !TARGET_LONG_CALLS) @@ -2844,10 +2951,12 @@ [(set (attr "length") (if_then_else (match_test "TARGET_LONG_CALLS") (const_int 4) - (const_int 62)))]) + (const_int 62) + ))]) (define_insn "_save_all_interrupt" - [(unspec_volatile [(const_int 0)] 0)] + [(unspec_volatile [(const_int 0)] 0) + (clobber (reg:CC CC_REGNUM))] "TARGET_V850 && ! TARGET_LONG_CALLS" "jarl __save_all_interrupt,r10" [(set_attr "length" "4")]) @@ -2859,13 +2968,15 @@ ;; insns this complicated. (define_insn "callt_restore_all_interrupt" - [(unspec_volatile [(const_int 0)] 1)] + [(unspec_volatile [(const_int 0)] 1) + (clobber (reg:CC CC_REGNUM))] "(TARGET_V850E_UP) && !TARGET_DISABLE_CALLT" "callt ctoff(__callt_restore_all_interrupt)" [(set_attr "length" "2")]) (define_insn "restore_all_interrupt" - [(unspec_volatile [(const_int 0)] 1)] + [(unspec_volatile [(const_int 0)] 1) + (clobber (reg:CC CC_REGNUM))] "" { if (TARGET_PROLOG_FUNCTION && !TARGET_LONG_CALLS) @@ -2942,7 +3053,8 @@ ))]) (define_insn "_restore_all_interrupt" - [(unspec_volatile [(const_int 0)] 1)] + [(unspec_volatile [(const_int 0)] 1) + (clobber (reg:CC CC_REGNUM))] "TARGET_V850 && ! TARGET_LONG_CALLS" "jarl __restore_all_interrupt,r10" [(set_attr "length" "4")]) From patchwork Wed Jun 27 18:33:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 935667 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480574-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="fg+SIVAd"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41GBP93bl9z9s2g for ; Thu, 28 Jun 2018 04:33:17 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=pSyU9zS1ZkWq7fPg8KRhPhki/M6weke9l2cPHBgTPi8Mp600qd mZcCO/D6VvqFg82wImcivOshh4rAlwfRA5g6KUHQAlwfP4CQ2qasi/7WVii96Ju+ RBL8HKHzkUaD2mHliQc+TMJT3tPgJC7WLmQC0wA2Gpxnp4mZbeMefWZko= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=Ru4Mfr4sEOBYvt4N5NfGurD/BD8=; b=fg+SIVAdDrM87TC46dDg 1FAPMykNLcpl7oQ5c56nz02Se0XMY2wnLuR3MTSBeXMnQfvh71rWDmdnwpN/YsdH YJ4NXECx3Y+aHgWUEwE3AT1JCT8HZK4OevA6iXhwGcmzHNqdE7kb2Kb3mvLVrwli kA/nNmjPgwPrmxHvxAJx/YU= Received: (qmail 73003 invoked by alias); 27 Jun 2018 18:33:10 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 72987 invoked by uid 89); 27 Jun 2018 18:33:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Jun 2018 18:33:08 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04A7130C10F4 for ; Wed, 27 Jun 2018 18:33:07 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-5.rdu2.redhat.com [10.10.112.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7679D91F20 for ; Wed, 27 Jun 2018 18:33:04 +0000 (UTC) To: gcc-patches From: Jeff Law Subject: [committed] [3/3] Converting the v850 port away from cc0 -- add flag setting patterns Openpgp: preference=signencrypt Message-ID: <80945db7-9543-dc66-6ab3-768f2e8ef9fc@redhat.com> Date: Wed, 27 Jun 2018 12:33:03 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 X-IsSubscribed: yes This is strictly an optimization patch. It adds flag setting variants of key arithmetic, logical, extensions, shifts, etc. That in turn allows the compare-elim pass to do its job. At this point the v8 port is converted and should be functioning at the same level it was before the conversion. As I noted in the cover message, there are some further things that could be improved, the only one I plan to look at is conversion to LRA. Committed to the trunk. Jeff * config/v850/v850.md (addsi3_set_flags): New pattern. (subsi3_set_flags, negsi2_set_flags, andsi3_set_flags): Likewise. (iorsi3_set_flags, xorsi3_set_flags, one_cmplsi2_set_flags): Likewise. (zero_extendhisi2_v850_set_flags): Likewise. (zero_extendqisi2_v850_set_flags): Likewise. (ashlsi3_set_flags, ashlsi3_v850e2_set_flags): Likewise. (lshrsi3_set_flags, lshrsi3_v850e2_set_flags): Likewise. (ashrsi3_set_flags, ashrsi3_v850e2_set_flags): Likewise. diff --git a/gcc/config/v850/v850.md b/gcc/config/v850/v850.md index 3cfec74..b8f098b 100644 --- a/gcc/config/v850/v850.md +++ b/gcc/config/v850/v850.md @@ -569,6 +569,20 @@ addi %O2(%P2),%1,%0" [(set_attr "length" "2,4,4")]) +(define_insn "addsi3_set_flags" + [(set (reg:CCNZ CC_REGNUM) + (compare:CCNZ (plus:SI (match_operand:SI 1 "register_operand" "%0,r,r") + (match_operand:SI 2 "nonmemory_operand" "rJ,K,U")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r,r,r") + (plus:SI (match_dup 1) (match_dup 2)))] + "reload_completed" + "@ + add %2,%0 + addi %2,%1,%0 + addi %O2(%P2),%1,%0" + [(set_attr "length" "2,4,4")]) + ;; ---------------------------------------------------------------------- ;; SUBTRACT INSTRUCTIONS ;; ---------------------------------------------------------------------- @@ -593,6 +607,19 @@ subr %1,%0" [(set_attr "length" "2,2")]) +(define_insn "*subsi3_set_flags" + [(set (reg:CCNZ CC_REGNUM) + (compare:CCNZ (minus:SI (match_operand:SI 1 "register_operand" "0,r") + (match_operand:SI 2 "nonmemory_operand" "r,0")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r,r") + (minus:SI (match_dup 1) (match_dup 2)))] + "reload_completed" + "@ + sub %2,%0 + subr %1,%0" + [(set_attr "length" "2,2")]) + (define_insn_and_split "negsi2" [(set (match_operand:SI 0 "register_operand" "=r") (neg:SI (match_operand:SI 1 "register_operand" "0")))] @@ -610,6 +637,16 @@ "subr %.,%0" [(set_attr "length" "2")]) +(define_insn "*negsi2_set_flags" + [(set (reg:CCNZ CC_REGNUM) + (compare:CCNZ (neg:SI (match_operand:SI 1 "register_operand" "0")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r") + (neg:SI (match_dup 1)))] + "reload_completed" + "subr %.,%0" + [(set_attr "length" "2")]) + ;; ---------------------------------------------------------------------- ;; MULTIPLY INSTRUCTIONS ;; ---------------------------------------------------------------------- @@ -831,6 +868,20 @@ andi %2,%1,%0" [(set_attr "length" "2,2,4")]) +(define_insn "andsi3_set_flags" + [(set (reg:CC CC_REGNUM) + (compare:CC (and:SI (match_operand:SI 1 "register_operand" "%0,0,r") + (match_operand:SI 2 "nonmemory_operand" "r,I,M")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r,r,r") + (and:SI (match_dup 1) (match_dup 2)))] + "reload_completed" + "@ + and %2,%0 + and %.,%0 + andi %2,%1,%0" + [(set_attr "length" "2,2,4")]) + ;; ---------------------------------------------------------------------- ;; OR INSTRUCTIONS ;; ---------------------------------------------------------------------- @@ -916,6 +967,20 @@ ori %2,%1,%0" [(set_attr "length" "2,2,4")]) +(define_insn "*iorsi3_set_flags" + [(set (reg:CC CC_REGNUM) + (compare:CC (ior:SI (match_operand:SI 1 "register_operand" "%0,0,r") + (match_operand:SI 2 "nonmemory_operand" "r,I,M")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r,r,r") + (ior:SI (match_dup 1) (match_dup 2)))] + "reload_completed" + "@ + or %2,%0 + or %.,%0 + ori %2,%1,%0" + [(set_attr "length" "2,2,4")]) + ;; ---------------------------------------------------------------------- ;; XOR INSTRUCTIONS ;; ---------------------------------------------------------------------- @@ -1001,6 +1066,20 @@ xori %2,%1,%0" [(set_attr "length" "2,2,4")]) +(define_insn "*xorsi3_set_flags" + [(set (reg:CC CC_REGNUM) + (compare:CC (xor:SI (match_operand:SI 1 "register_operand" "%0,0,r") + (match_operand:SI 2 "nonmemory_operand" "r,I,M")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r,r,r") + (xor:SI (match_dup 1) (match_dup 2)))] + "reload_completed" + "@ + xor %2,%0 + xor %.,%0 + xori %2,%1,%0" + [(set_attr "length" "2,2,4")]) + ;; ---------------------------------------------------------------------- ;; NOT INSTRUCTIONS @@ -1024,6 +1103,16 @@ "not %1,%0" [(set_attr "length" "2")]) +(define_insn "*one_cmplsi2_set_flags" + [(set (reg:CC CC_REGNUM) + (compare:CC (not:SI (match_operand:SI 1 "register_operand" "r")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r") + (not:SI (match_dup 1)))] + "reload_completed" + "not %1,%0" + [(set_attr "length" "2")]) + ;; ----------------------------------------------------------------- ;; BIT FIELDS ;; ----------------------------------------------------------------- @@ -1808,6 +1897,16 @@ "andi 65535,%1,%0" [(set_attr "length" "4")]) +(define_insn "*zero_extendhisi2_v850_set_flags" + [(set (reg:CCNZ CC_REGNUM) + (compare:CCNZ (zero_extend:SI (match_operand:HI 1 "register_operand" "r")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r") + (zero_extend:SI (match_dup 1)))] + "reload_completed" + "andi 65535,%1,%0" + [(set_attr "length" "4")]) + (define_expand "zero_extendhisi2" [(parallel [(set (match_operand:SI 0 "register_operand") (zero_extend:SI @@ -1841,6 +1940,16 @@ "andi 255,%1,%0" [(set_attr "length" "4")]) +(define_insn "*zero_extendqisi2_v850_set_flags" + [(set (reg:CCNZ CC_REGNUM) + (compare:CCNZ (zero_extend:SI (match_operand:QI 1 "register_operand" "r")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r") + (zero_extend:SI (match_dup 1)))] + "reload_completed" + "andi 255,%1,%0" + [(set_attr "length" "4")]) + (define_expand "zero_extendqisi2" [(parallel [(set (match_operand:SI 0 "register_operand") (zero_extend:SI @@ -1941,6 +2050,19 @@ shl %2,%0" [(set_attr "length" "4,2")]) +(define_insn "ashlsi3_set_flags" + [(set (reg:CCNZ CC_REGNUM) + (compare:CCNZ (ashift:SI (match_operand:SI 1 "register_operand" "0,0") + (match_operand:SI 2 "nonmemory_operand" "r,N")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r,r") + (ashift:SI (match_dup 1) (match_dup 2)))] + "reload_completed" + "@ + shl %2,%0 + shl %2,%0" + [(set_attr "length" "4,2")]) + (define_insn "ashlsi3_v850e2_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r") (ashift:SI @@ -1951,6 +2073,17 @@ "shl %2,%1,%0" [(set_attr "length" "4")]) +(define_insn "ashlsi3_v850e2_set_flags" + [(set (reg:CCNZ CC_REGNUM) + (compare:CCNZ (ashift:SI (match_operand:SI 1 "register_operand" "r") + (match_operand:SI 2 "nonmemory_operand" "r")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r") + (ashift:SI (match_dup 1) (match_dup 2)))] + "reload_completed && TARGET_V850E2_UP" + "shl %2,%1,%0" + [(set_attr "length" "4")]) + (define_insn_and_split "lshrsi3" [(set (match_operand:SI 0 "register_operand" "=r,r") (lshiftrt:SI @@ -1974,6 +2107,19 @@ shr %2,%0" [(set_attr "length" "4,2")]) +(define_insn "lshrsi3_set_flags" + [(set (reg:CC CC_REGNUM) + (compare:CC (lshiftrt:SI (match_operand:SI 1 "register_operand" "0,0") + (match_operand:SI 2 "nonmemory_operand" "r,N")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r,r") + (lshiftrt:SI (match_dup 1) (match_dup 2)))] + "reload_completed" + "@ + shr %2,%0 + shr %2,%0" + [(set_attr "length" "4,2")]) + (define_insn "lshrsi3_v850e2_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r") (lshiftrt:SI @@ -1984,6 +2130,17 @@ "shr %2,%1,%0" [(set_attr "length" "4")]) +(define_insn "lshrsi3_v850e2_set_flags" + [(set (reg:CC CC_REGNUM) + (compare:CC (lshiftrt:SI (match_operand:SI 1 "register_operand" "r") + (match_operand:SI 2 "nonmemory_operand" "r")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r") + (lshiftrt:SI (match_dup 1) (match_dup 2)))] + "reload_completed && TARGET_V850E2_UP" + "shr %2,%1,%0" + [(set_attr "length" "4")]) + (define_insn_and_split "ashrsi3" [(set (match_operand:SI 0 "register_operand" "=r,r") (ashiftrt:SI @@ -2007,6 +2164,19 @@ sar %2,%0" [(set_attr "length" "4,2")]) +(define_insn "ashrsi3_set_flags" + [(set (reg:CC CC_REGNUM) + (compare:CC (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0") + (match_operand:SI 2 "nonmemory_operand" "r,N")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r,r") + (ashiftrt:SI (match_dup 1) (match_dup 2)))] + "reload_completed" + "@ + sar %2,%0 + sar %2,%0" + [(set_attr "length" "4,2")]) + (define_insn "ashrsi3_v850e2_clobber_flags" [(set (match_operand:SI 0 "register_operand" "=r") (ashiftrt:SI @@ -2017,6 +2187,17 @@ "sar %2,%1,%0" [(set_attr "length" "4")]) +(define_insn "ashrsi3_v850e2_set_flags" + [(set (reg:CC CC_REGNUM) + (compare:CC (ashiftrt:SI (match_operand:SI 1 "register_operand" "r") + (match_operand:SI 2 "nonmemory_operand" "r")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r") + (ashiftrt:SI (match_dup 1) (match_dup 2)))] + "reload_completed && TARGET_V850E2_UP" + "sar %2,%1,%0" + [(set_attr "length" "4")]) + ;; ---------------------------------------------------------------------- ;; FIND FIRST BIT INSTRUCTION ;; ----------------------------------------------------------------------