From patchwork Fri Aug 3 02:28:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 174838 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id DECC42C007B for ; Fri, 3 Aug 2012 12:28:57 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1344565739; h=Comment: DomainKey-Signature:Received:Received:Received:Received:From:To: Cc:Subject:Date:Message-Id:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=DMvrgY+7iewX7RqO9o4wNTi8dsg=; b=mtbfiZJnT/kpG8b eM+4RxJ1npCbkP/QuZoYuUxEpofG2qhHVvBLPGJHMXeEUn4FGrCwHyTGiMnT0b0u y9oEOgzit2HGT2GW37Tcs2oJ4s2jHJ3F4qI3wtveJaUFzS/WHMR37MuvqLQ+5+gw rf2a3DNEbpV4eXQXRhKI1HSstRT4= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:From:To:Cc:Subject:Date:Message-Id:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=wbNShLAadp+Qt1R53kNJSVf6RxIIHiHMEvSbiYkyeNMrQALgALR5g3ylO+/n2M S5u4B5a9ty+BMb4fbkKu99oNO7bDmvofFwaAmWITFFZsYAHVce0DqtRxVbdcyoke f4PmWbK9M9fLp5OZLpHXdep7bd5mM4pz7Xy6eGVUgglLo=; Received: (qmail 8858 invoked by alias); 3 Aug 2012 02:28:54 -0000 Received: (qmail 8846 invoked by uid 22791); 3 Aug 2012 02:28:52 -0000 X-SWARE-Spam-Status: No, hits=2.0 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, MEDICAL_SUBJECT X-Spam-Check-By: sourceware.org Received: from mx2.corp.phx1.mozilla.com (HELO smtp.mozilla.org) (63.245.216.70) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Aug 2012 02:28:38 +0000 Received: from localhost (cpe-107-10-247-225.indy.res.rr.com [107.10.247.225]) (Authenticated sender: nfroyd@mozilla.com) by mx2.mail.corp.phx1.mozilla.com (Postfix) with ESMTPSA id 04F0FF2312; Thu, 2 Aug 2012 19:28:35 -0700 (PDT) From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: hp@bitrange.com Subject: [PATCH,mmix] convert to constraints.md Date: Thu, 2 Aug 2012 22:28:31 -0400 Message-Id: <1343960911-11811-1-git-send-email-froydnj@mozilla.com> 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 As $SUBJECT says. There's not too much interesting here. I did a fairly literal-minded conversion, so it's possible there's smarter ways to do some things. Compiled with cross to mmix-knuth-mmixware and spot-checked by comparing libgcc object files. I have no idea how to set up a simulator environment. H-P, if you'd like to test beforehand, that'd be great. OK to commit? -Nathan * config/mmix/mmix.h (REG_CLASS_FROM_LETTER): Delete. (CONST_OK_FOR_LETTER_P, CONST_DOUBLE_OK_FOR_LETTER_P): Delete. (EXTRA_CONSTRAINT): Delete. * config/mmix/mmix-protos.h (mmix_intval): Declare. (mmix_const_ok_for_letter_p, mmix_extra_constraint): Delete. (mmix_const_double_ok_for_letter_p): Delete. * config/mmix/constraints.md: New file. * config/mmix/mmix.md: Include it. (iordi3): Delete dead H constraint. * config/mmix/predicates.md (mmix_reg_or_8bit_operand): Use satisfies_constraint_I. (mmix_address_operand): New predicate. * config/mmix/mmix.c: #include tm-constrs.h. (mmix_intval): Delete declaration. Make non-static. (mmix_const_ok_for_letter_p, mmix_extra_constraint): Delete. (mmix_const_double_ok_for_letter_p): Delete. (mmix_legitimate_address_p): Use satisfies_constraint_I. (mmix_print_operand_address): Likewise. --- gcc/ChangeLog | 21 +++++++++ gcc/config/mmix/constraints.md | 93 ++++++++++++++++++++++++++++++++++++++++ gcc/config/mmix/mmix-protos.h | 4 +- gcc/config/mmix/mmix.c | 93 ++------------------------------------- gcc/config/mmix/mmix.h | 15 ------ gcc/config/mmix/mmix.md | 3 +- gcc/config/mmix/predicates.md | 14 ++++-- 7 files changed, 132 insertions(+), 111 deletions(-) create mode 100644 gcc/config/mmix/constraints.md diff --git a/gcc/config/mmix/constraints.md b/gcc/config/mmix/constraints.md new file mode 100644 index 0000000..b8cc690 --- /dev/null +++ b/gcc/config/mmix/constraints.md @@ -0,0 +1,93 @@ +;; MMIX constraints +;; Copyright (C) 2012 Free Software Foundation, Inc. +;; +;; This file is part of GCC. +;; +;; GCC is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. +;; +;; GCC is distributed in the hope that it will be useful, but WITHOUT +;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +;; License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GCC; see the file COPYING3. If not see +;; . */ + +(define_register_constraint "x" "SYSTEM_REGS" + "@internal") + +(define_register_constraint "y" "REMAINDER_REG" + "@internal") + +(define_register_constraint "z" "HIMULT_REG" + "@internal") + +(define_constraint "I" + "A 8-bit unsigned integer" + (and (match_code "const_int") + (match_test "IN_RANGE (ival, 0, 255)"))) + +(define_constraint "J" + "A 16-bit unsigned integer." + (and (match_code "const_int") + (match_test "IN_RANGE (ival, 0, 65535)"))) + +(define_constraint "K" + "An integer between -255 and 0." + (and (match_code "const_int") + (match_test "IN_RANGE (ival, -255, 0)"))) + +(define_constraint "L" + "@internal" + (and (match_code "const_int") + (match_test "mmix_shiftable_wyde_value (ival)"))) + +(define_constraint "M" + "The value 0." + (and (match_code "const_int") + (match_test "ival == 0"))) + +(define_constraint "N" + "@internal" + (and (match_code "const_int") + (match_test "mmix_shiftable_wyde_value (~ival)"))) + +(define_constraint "O" + "The value 3, 5, 9, or 17." + (and (match_code "const_int") + (ior (match_test "ival == 3") + (match_test "ival == 5") + (match_test "ival == 9") + (match_test "ival == 17")))) + +(define_constraint "G" + "Floating-point zero." + (and (match_code "const_double") + (match_test "op == CONST0_RTX (mode)"))) + +(define_constraint "R" + "@internal" + (and (not (match_code "const_int,const_double")) + (match_test "mmix_constant_address_p (op)") + (ior (match_test "!TARGET_BASE_ADDRESSES") + (match_code "LABEL_REF") + (and (match_code "SYMBOL_REF") + (match_test "SYMBOL_REF_FLAG (op)"))))) + +(define_constraint "S" + "@internal" + (and (match_code "const_int,const_double") + (match_test "mmix_shiftable_wyde_value (mmix_intval (op))"))) + +(define_constraint "T" + "@internal" + (and (match_code "const_int,const_double") + (match_test "mmix_shiftable_wyde_value (~mmix_intval (op))"))) + +(define_constraint "U" + "@internal" + (match_operand 0 "mmix_address_operand")) diff --git a/gcc/config/mmix/mmix-protos.h b/gcc/config/mmix/mmix-protos.h index 4e8c338..62cdbae 100644 --- a/gcc/config/mmix/mmix-protos.h +++ b/gcc/config/mmix/mmix-protos.h @@ -40,6 +40,7 @@ extern void mmix_asm_output_reg_push (FILE *, int); extern void mmix_asm_output_reg_pop (FILE *, int); extern void mmix_asm_output_skip (FILE *, int); extern void mmix_asm_output_align (FILE *, int); +extern HOST_WIDEST_INT mmix_intval (const_rtx); extern int mmix_shiftable_wyde_value (unsigned HOST_WIDEST_INT); extern void mmix_output_register_setting (FILE *, int, HOST_WIDEST_INT, int); extern int mmix_opposite_regno (int, int); @@ -59,9 +60,6 @@ extern void mmix_asm_output_addr_diff_elt (FILE *, rtx, int, int); extern void mmix_asm_output_addr_vec_elt (FILE *, int); extern enum reg_class mmix_secondary_reload_class (enum reg_class, enum machine_mode, rtx, int); -extern int mmix_const_ok_for_letter_p (HOST_WIDE_INT, int); -extern int mmix_const_double_ok_for_letter_p (rtx, int); -extern int mmix_extra_constraint (rtx, int, int); extern rtx mmix_dynamic_chain_address (rtx); extern rtx mmix_return_addr_rtx (int, rtx); extern rtx mmix_eh_return_stackadj_rtx (void); diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c index 3a99cb6..3b72729 100644 --- a/gcc/config/mmix/mmix.c +++ b/gcc/config/mmix/mmix.c @@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. If not see #include "target.h" #include "target-def.h" #include "df.h" +#include "tm-constrs.h" /* First some local helper definitions. */ #define MMIX_FIRST_GLOBAL_REGNUM 32 @@ -118,7 +119,6 @@ static void mmix_output_shiftvalue_op_from_str (FILE *, const char *, HOST_WIDEST_INT); static void mmix_output_shifted_value (FILE *, HOST_WIDEST_INT); static void mmix_output_condition (FILE *, const_rtx, int); -static HOST_WIDEST_INT mmix_intval (const_rtx); static void mmix_output_octa (FILE *, HOST_WIDEST_INT, int); static bool mmix_assemble_integer (rtx, unsigned int, int); static struct machine_function *mmix_init_machine_status (void); @@ -459,87 +459,6 @@ mmix_secondary_reload_class (enum reg_class rclass, return NO_REGS; } -/* CONST_OK_FOR_LETTER_P. */ - -int -mmix_const_ok_for_letter_p (HOST_WIDE_INT value, int c) -{ - return - (c == 'I' ? value >= 0 && value <= 255 - : c == 'J' ? value >= 0 && value <= 65535 - : c == 'K' ? value <= 0 && value >= -255 - : c == 'L' ? mmix_shiftable_wyde_value (value) - : c == 'M' ? value == 0 - : c == 'N' ? mmix_shiftable_wyde_value (~value) - : c == 'O' ? (value == 3 || value == 5 || value == 9 - || value == 17) - : 0); -} - -/* CONST_DOUBLE_OK_FOR_LETTER_P. */ - -int -mmix_const_double_ok_for_letter_p (rtx value, int c) -{ - return - (c == 'G' ? value == CONST0_RTX (GET_MODE (value)) - : 0); -} - -/* EXTRA_CONSTRAINT. - We need this since our constants are not always expressible as - CONST_INT:s, but rather often as CONST_DOUBLE:s. */ - -int -mmix_extra_constraint (rtx x, int c, int strict) -{ - HOST_WIDEST_INT value; - - /* When checking for an address, we need to handle strict vs. non-strict - register checks. Don't use address_operand, but instead its - equivalent (its callee, which it is just a wrapper for), - memory_operand_p and the strict-equivalent strict_memory_address_p. */ - if (c == 'U') - return - strict - ? strict_memory_address_p (Pmode, x) - : memory_address_p (Pmode, x); - - /* R asks whether x is to be loaded with GETA or something else. Right - now, only a SYMBOL_REF and LABEL_REF can fit for - TARGET_BASE_ADDRESSES. - - Only constant symbolic addresses apply. With TARGET_BASE_ADDRESSES, - we just allow straight LABEL_REF or SYMBOL_REFs with SYMBOL_REF_FLAG - set right now; only function addresses and code labels. If we change - to let SYMBOL_REF_FLAG be set on other symbols, we have to check - inside CONST expressions. When TARGET_BASE_ADDRESSES is not in - effect, a "raw" constant check together with mmix_constant_address_p - is all that's needed; we want all constant addresses to be loaded - with GETA then. */ - if (c == 'R') - return - GET_CODE (x) != CONST_INT && GET_CODE (x) != CONST_DOUBLE - && mmix_constant_address_p (x) - && (! TARGET_BASE_ADDRESSES - || (GET_CODE (x) == LABEL_REF - || (GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_FLAG (x)))); - - if (GET_CODE (x) != CONST_DOUBLE || GET_MODE (x) != VOIDmode) - return 0; - - value = mmix_intval (x); - - /* We used to map Q->J, R->K, S->L, T->N, U->O, but we don't have to any - more ('U' taken for address_operand, 'R' similarly). Some letters map - outside of CONST_INT, though; we still use 'S' and 'T'. */ - if (c == 'S') - return mmix_shiftable_wyde_value (value); - else if (c == 'T') - return mmix_shiftable_wyde_value (~value); - return 0; -} - /* DYNAMIC_CHAIN_ADDRESS. */ rtx @@ -1161,8 +1080,7 @@ mmix_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, return 1; /* (mem (plus (reg) (0..255?))) */ - if (GET_CODE (x2) == CONST_INT - && CONST_OK_FOR_LETTER_P (INTVAL (x2), 'I')) + if (satisfies_constraint_I (x2)) return 1; return 0; @@ -1843,8 +1761,7 @@ mmix_print_operand_address (FILE *stream, rtx x) reg_names[MMIX_OUTPUT_REGNO (REGNO (x2))]); return; } - else if (GET_CODE (x2) == CONST_INT - && CONST_OK_FOR_LETTER_P (INTVAL (x2), 'I')) + else if (satisfies_constraint_I (x2)) { output_addr_const (stream, x2); return; @@ -2529,7 +2446,7 @@ mmix_emit_sp_add (HOST_WIDE_INT offset) { /* Positive adjustments are in the epilogue only. Don't mark them as "frame-related" for unwind info. */ - if (CONST_OK_FOR_LETTER_P (offset, 'L')) + if (insn_const_int_ok_for_constraint (offset, CONSTRAINT_L)) emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx, GEN_INT (offset))); @@ -2754,7 +2671,7 @@ mmix_output_condition (FILE *stream, const_rtx x, int reversed) /* Return the bit-value for a const_int or const_double. */ -static HOST_WIDEST_INT +HOST_WIDEST_INT mmix_intval (const_rtx x) { unsigned HOST_WIDEST_INT retval; diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h index 787f64f..ba6ded7 100644 --- a/gcc/config/mmix/mmix.h +++ b/gcc/config/mmix/mmix.h @@ -439,11 +439,6 @@ enum reg_class #define INDEX_REG_CLASS GENERAL_REGS -#define REG_CLASS_FROM_LETTER(CHAR) \ - ((CHAR) == 'x' ? SYSTEM_REGS \ - : (CHAR) == 'y' ? REMAINDER_REG \ - : (CHAR) == 'z' ? HIMULT_REG : NO_REGS) - #define REGNO_OK_FOR_BASE_P(REGNO) \ ((REGNO) <= MMIX_LAST_GENERAL_REGISTER \ || (REGNO) == MMIX_ARG_POINTER_REGNUM \ @@ -460,16 +455,6 @@ enum reg_class #define CLASS_MAX_NREGS(CLASS, MODE) HARD_REGNO_NREGS (CLASS, MODE) -#define CONST_OK_FOR_LETTER_P(VALUE, C) \ - mmix_const_ok_for_letter_p (VALUE, C) - -#define EXTRA_CONSTRAINT(VALUE, C) \ - mmix_extra_constraint (VALUE, C, MMIX_REG_OK_STRICT) - -/* Do we need anything serious here? Yes, any FLOT constant. */ -#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \ - mmix_const_double_ok_for_letter_p (VALUE, C) - /* Node: Frame Layout */ diff --git a/gcc/config/mmix/mmix.md b/gcc/config/mmix/mmix.md index 1cd397a..a806819 100644 --- a/gcc/config/mmix/mmix.md +++ b/gcc/config/mmix/mmix.md @@ -43,6 +43,7 @@ ;; Operand and operator predicates. (include "predicates.md") +(include "constraints.md") ;; FIXME: Can we remove the reg-to-reg for smaller modes? Shouldn't they ;; be synthesized ok? @@ -274,7 +275,7 @@ (define_insn "iordi3" [(set (match_operand:DI 0 "register_operand" "=r,r") (ior:DI (match_operand:DI 1 "register_operand" "%r,0") - (match_operand:DI 2 "mmix_reg_or_constant_operand" "rH,LS")))] + (match_operand:DI 2 "mmix_reg_or_constant_operand" "r,LS")))] "" "@ OR %0,%1,%2 diff --git a/gcc/config/mmix/predicates.md b/gcc/config/mmix/predicates.md index b5773b8..7fa3bf1 100644 --- a/gcc/config/mmix/predicates.md +++ b/gcc/config/mmix/predicates.md @@ -149,7 +149,13 @@ ;; True if this is a register or an int 0..255. (define_predicate "mmix_reg_or_8bit_operand" - (ior - (match_operand 0 "register_operand") - (and (match_code "const_int") - (match_test "CONST_OK_FOR_LETTER_P (INTVAL (op), 'I')")))) + (if_then_else (match_code "const_int") + (match_test "satisfies_constraint_I (op)") + (match_operand 0 "register_operand"))) + +;; True if this is a memory address, possibly strictly. + +(define_predicate "mmix_address_operand" + (if_then_else (match_test "reload_in_progress || reload_completed") + (match_test "strict_memory_address_p (Pmode, op)") + (match_test "memory_address_p (Pmode, op)")))