From d634083bd4b4d5ca55b47c3a5f17083e0fba61f3 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Mon, 14 Feb 2011 20:59:19 +0000 Subject: [PATCH] make stormy16 use constraints.md make stormy16 use constraints.md * 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. From-SVN: r170152 --- gcc/ChangeLog | 15 ++++ gcc/config/stormy16/constraints.md | 119 ++++++++++++++++++++++++++ gcc/config/stormy16/predicates.md | 4 +- gcc/config/stormy16/stormy16-protos.h | 2 +- gcc/config/stormy16/stormy16.c | 56 +----------- gcc/config/stormy16/stormy16.h | 36 -------- gcc/config/stormy16/stormy16.md | 1 + 7 files changed, 139 insertions(+), 94 deletions(-) create mode 100644 gcc/config/stormy16/constraints.md diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c9b7f354471..1b1914000ff 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2011-02-14 Nathan Froyd + + * 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. + 2011-02-14 Eric Botcazou PR tree-optimization/46494 diff --git a/gcc/config/stormy16/constraints.md b/gcc/config/stormy16/constraints.md new file mode 100644 index 00000000000..5ad17bdbfd9 --- /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_operand 0 "xstormy16_below100_operand")) + +(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 0e1d39431f7..7270c7fe7a7 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 3edbc33959f..ad44e154fae 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 fa5c5b5a8dc..e4cd10e2764 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 8789d90105e..c92af1dbd8a 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 8c6fd9d0f9c..3eb74b72e0f 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") ;; :::::::::::::::::::: ;; :: -- 2.30.2