From patchwork Mon Feb 14 20:24:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 83155 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 1EDD0B7105 for ; Tue, 15 Feb 2011 07:25:21 +1100 (EST) Received: (qmail 3708 invoked by alias); 14 Feb 2011 20:25:13 -0000 Received: (qmail 3640 invoked by uid 22791); 14 Feb 2011 20:25:08 -0000 X-SWARE-Spam-Status: No, hits=2.2 required=5.0 tests=AWL, BAYES_50, MEDICAL_SUBJECT, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Feb 2011 20:25:02 +0000 Received: (qmail 27434 invoked from network); 14 Feb 2011 20:25:00 -0000 Received: from unknown (HELO localhost) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 14 Feb 2011 20:25:00 -0000 Date: Mon, 14 Feb 2011 12:24:59 -0800 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: nickc@redhat.com Subject: [PATCH] convert stormy16 to constraints.md Message-ID: <20110214202459.GG6247@codesourcery.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-IsSubscribed: yes 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 suggests. The fiddling with stormy16-protos.h comes about from needing to export xstormy16_legitimate_address_p for the 'S' constraint. Tested with cross to xstormy16-elf. OK to commit? -Nathan * config/stormy16/constraints.md: New file. * config/stormy16/predicates.md (nonimmediate_nonstack_operand): Use satisfies_constraint_Q and satisfies_constraint_R. * config/stormy16/stomry16-protos.h (xstormy16_extra_constraint_p): Delete. (xstormy16_legitiamte_address_p): Declare. * config/stormy16/stormy16.h (REG_CLASS_FROM_LETTER): Delete. (CONST_OK_FOR_LETTER_P, CONST_DOUBLE_OK_FOR_LETTER_P): Delete. (EXTRA_CONSTRAINT): Delete. * config/stormy16/stormy16.c (xstormy16_legitiamte_address_p): Un-staticize. (xstormy16_extra_constraint_p): Delete. diff --git a/gcc/config/stormy16/constraints.md b/gcc/config/stormy16/constraints.md new file mode 100644 index 0000000..aab5ec1 --- /dev/null +++ b/gcc/config/stormy16/constraints.md @@ -0,0 +1,119 @@ +;; Constraint definitions for XSTORMY16. +;; Copyright (C) 2011 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 +;; . + +;; Register constraints. +(define_register_constraint "a" "R0_REGS" + "@internal") + +(define_register_constraint "b" "R1_REGS" + "@internal") + +(define_register_constraint "c" "R2_REGS" + "@internal") + +(define_register_constraint "d" "R8_REGS" + "@internal") + +(define_register_constraint "e" "EIGHT_REGS" + "@internal") + +(define_register_constraint "t" "TWO_REGS" + "@internal") + +(define_register_constraint "z" "ICALL_REGS" + "@internal") + +;; Integer constraints. +(define_constraint "I" + "An integer between 0 and 3." + (and (match_code "const_int") + (match_test "IN_RANGE (ival, 0, 3)"))) + +(define_constraint "J" + "A power of two." + (and (match_code "const_int") + (match_test "exact_log2 (ival) != -1"))) + +(define_constraint "K" + "A power of two when inverted." + (and (match_code "const_int") + (match_test "exact_log2 (~ival) != -1"))) + +(define_constraint "L" + "An 8-bit unsigned integer." + (and (match_code "const_int") + (match_test "IN_RANGE (ival, 0, 255)"))) + +(define_constraint "M" + "An integer between -255 and 0." + (and (match_code "const_int") + (match_test "IN_RANGE (ival, -255, 0)"))) + +(define_constraint "N" + "An integer between -3 and 0." + (and (match_code "const_int") + (match_test "IN_RANGE (ival, -3, 0)"))) + +(define_constraint "O" + "An integer between 1 and 4." + (and (match_code "const_int") + (match_test "IN_RANGE (ival, 1, 4)"))) + +(define_constraint "P" + "An integer between -4 and -1." + (and (match_code "const_int") + (match_test "IN_RANGE (ival, -4, -1)"))) + +;; Extra constraints. +(define_constraint "Q" + "A register push operation." + (and (match_code "mem") + (match_code "post_inc" "0") + (match_test "XEXP (XEXP (op, 0), 0) == stack_pointer_rtx"))) + +(define_constraint "R" + "A register pop operation." + (and (match_code "mem") + (match_code "pre_dec" "0") + (match_test "XEXP (XEXP (op, 0), 0) == stack_pointer_rtx"))) + +(define_constraint "S" + "An immediate memory address." + (and (match_code "mem") + (match_code "const_int" "0") + (match_test "xstormy16_legitimate_address_p (VOIDmode, XEXP (op, 0), false)"))) + +(define_constraint "T" + "@internal" + ;; For Rx; not implemented yet. + (match_test "0")) + +(define_constraint "U" + "An integer not between 2 and 15." + (and (match_code "const_int") + (match_test "!IN_RANGE (ival, 2, 15)"))) + +(define_constraint "W" + "@internal" + (match_test "xstormy16_below100_operand (op, mode)")) + +(define_constraint "Z" + "Zero." + (and (match_code "const_int") + (match_test "ival == 0"))) \ No newline at end of file diff --git a/gcc/config/stormy16/predicates.md b/gcc/config/stormy16/predicates.md index 0e1d394..7270c7f 100644 --- a/gcc/config/stormy16/predicates.md +++ b/gcc/config/stormy16/predicates.md @@ -140,8 +140,8 @@ { /* 'Q' is for pushes, 'R' for pops. */ return (nonimmediate_operand (op, mode) - && ! xstormy16_extra_constraint_p (op, 'Q') - && ! xstormy16_extra_constraint_p (op, 'R')); + && ! satisfies_constraint_Q (op) + && ! satisfies_constraint_R (op)); }) (define_predicate "xstormy16_carry_plus_operand" diff --git a/gcc/config/stormy16/stormy16-protos.h b/gcc/config/stormy16/stormy16-protos.h index 3edbc33..ad44e15 100644 --- a/gcc/config/stormy16/stormy16-protos.h +++ b/gcc/config/stormy16/stormy16-protos.h @@ -45,7 +45,6 @@ extern void xstormy16_emit_cbranch (enum rtx_code, rtx, rtx, rtx); extern char *xstormy16_output_cbranch_hi (rtx, const char *, int, rtx); extern char *xstormy16_output_cbranch_si (rtx, const char *, int, rtx); extern int xstormy16_mode_dependent_address_p (rtx); -extern int xstormy16_extra_constraint_p (rtx, int); extern void xstormy16_print_operand (FILE *, rtx, int); extern void xstormy16_print_operand_address (FILE *, rtx); @@ -72,5 +71,6 @@ extern const char * xstormy16_output_shift (enum machine_mode, enum rtx_code, rtx, rtx, rtx); extern int xstormy16_below100_symbol (rtx, enum machine_mode); extern int xstormy16_splittable_below100_operand (rtx, enum machine_mode); +extern bool xstormy16_legitimate_address_p (enum machine_mode, rtx, bool); #endif diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c index fa5c5b5..e4cd10e 100644 --- a/gcc/config/stormy16/stormy16.c +++ b/gcc/config/stormy16/stormy16.c @@ -615,7 +615,7 @@ xstormy16_expand_andqi3 (rtx *operands) && INTVAL (X) + (OFFSET) < 0x8000 \ && (INTVAL (X) + (OFFSET) < 0x100 || INTVAL (X) + (OFFSET) >= 0x7F00)) -static bool +bool xstormy16_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx x, bool strict) { @@ -683,60 +683,6 @@ xstormy16_mode_dependent_address_p (rtx x) return 0; } -/* A C expression that defines the optional machine-dependent constraint - letters (`Q', `R', `S', `T', `U') that can be used to segregate specific - types of operands, usually memory references, for the target machine. - Normally this macro will not be defined. If it is required for a particular - target machine, it should return 1 if VALUE corresponds to the operand type - represented by the constraint letter C. If C is not defined as an extra - constraint, the value returned should be 0 regardless of VALUE. */ - -int -xstormy16_extra_constraint_p (rtx x, int c) -{ - switch (c) - { - /* 'Q' is for pushes. */ - case 'Q': - return (MEM_P (x) - && GET_CODE (XEXP (x, 0)) == POST_INC - && XEXP (XEXP (x, 0), 0) == stack_pointer_rtx); - - /* 'R' is for pops. */ - case 'R': - return (MEM_P (x) - && GET_CODE (XEXP (x, 0)) == PRE_DEC - && XEXP (XEXP (x, 0), 0) == stack_pointer_rtx); - - /* 'S' is for immediate memory addresses. */ - case 'S': - return (MEM_P (x) - && CONST_INT_P (XEXP (x, 0)) - && xstormy16_legitimate_address_p (VOIDmode, XEXP (x, 0), 0)); - - /* 'T' is for Rx. */ - case 'T': - /* Not implemented yet. */ - return 0; - - /* 'U' is for CONST_INT values not between 2 and 15 inclusive, - for allocating a scratch register for 32-bit shifts. */ - case 'U': - return (CONST_INT_P (x) && (! IN_RANGE (INTVAL (x), 2, 15))); - - /* 'Z' is for CONST_INT value zero. This is for adding zero to - a register in addhi3, which would otherwise require a carry. */ - case 'Z': - return (CONST_INT_P (x) && (INTVAL (x) == 0)); - - case 'W': - return xstormy16_below100_operand (x, GET_MODE (x)); - - default: - return 0; - } -} - int short_memory_operand (rtx x, enum machine_mode mode) { diff --git a/gcc/config/stormy16/stormy16.h b/gcc/config/stormy16/stormy16.h index 8789d90..c92af1d 100644 --- a/gcc/config/stormy16/stormy16.h +++ b/gcc/config/stormy16/stormy16.h @@ -225,26 +225,6 @@ enum reg_class #define INDEX_REG_CLASS GENERAL_REGS -/* The following letters are unavailable, due to being used as - constraints: - '0'..'9' - '<', '>' - 'E', 'F', 'G', 'H' - 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P' - 'Q', 'R', 'S', 'T', 'U' - 'V', 'X' - 'g', 'i', 'm', 'n', 'o', 'p', 'r', 's'. */ - -#define REG_CLASS_FROM_LETTER(CHAR) \ - ( (CHAR) == 'a' ? R0_REGS \ - : (CHAR) == 'b' ? R1_REGS \ - : (CHAR) == 'c' ? R2_REGS \ - : (CHAR) == 'd' ? R8_REGS \ - : (CHAR) == 'e' ? EIGHT_REGS \ - : (CHAR) == 't' ? TWO_REGS \ - : (CHAR) == 'z' ? ICALL_REGS \ - : NO_REGS) - #define REGNO_OK_FOR_BASE_P(NUM) 1 #define REGNO_OK_FOR_INDEX_P(NUM) REGNO_OK_FOR_BASE_P (NUM) @@ -263,22 +243,6 @@ enum reg_class #define CLASS_MAX_NREGS(CLASS, MODE) \ ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD) -#define CONST_OK_FOR_LETTER_P(VALUE, C) \ - ( (C) == 'I' ? (VALUE) >= 0 && (VALUE) <= 3 \ - : (C) == 'J' ? exact_log2 (VALUE) != -1 \ - : (C) == 'K' ? exact_log2 (~(VALUE)) != -1 \ - : (C) == 'L' ? (VALUE) >= 0 && (VALUE) <= 255 \ - : (C) == 'M' ? (VALUE) >= -255 && (VALUE) <= 0 \ - : (C) == 'N' ? (VALUE) >= -3 && (VALUE) <= 0 \ - : (C) == 'O' ? (VALUE) >= 1 && (VALUE) <= 4 \ - : (C) == 'P' ? (VALUE) >= -4 && (VALUE) <= -1 \ - : 0 ) - -#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) 0 - -#define EXTRA_CONSTRAINT(VALUE, C) \ - xstormy16_extra_constraint_p (VALUE, C) - /* Basic Stack Layout. */ diff --git a/gcc/config/stormy16/stormy16.md b/gcc/config/stormy16/stormy16.md index 8c6fd9d..3eb74b7 100644 --- a/gcc/config/stormy16/stormy16.md +++ b/gcc/config/stormy16/stormy16.md @@ -95,6 +95,7 @@ (set_attr "psw_operand" "clobber")]) (include "predicates.md") +(include "constraints.md") ;; :::::::::::::::::::: ;; ::