From: Jeff Law Date: Thu, 21 May 2015 12:44:35 +0000 (-0600) Subject: pa.c (pa_print_operand): New 'o' output modifier. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b47fbc5307fe0f03ff302627d8977c402e34feff;p=gcc.git pa.c (pa_print_operand): New 'o' output modifier. 2015-05-20 Jeff Law * config/pa/pa.c (pa_print_operand): New 'o' output modifier. (pa_mem_shadd_constant_p): Renamed from pa_shadd_constant_p. (pa_shadd_constant_p): Allow constants for shadd insns rather than valid scaling constants for memory addresses. * config/pa/pa-protos.h (pa_mem_shadd_constant_p): Add prototype. * config/pa/predicates.md (mem_shadd_operand): New predicate. * config/pa/pa.md (shift-add insns using MULT): Use mem_shadd_operand. (shift-add insns using ASHIFT): New patterns. * gcc.target/hppa/hppa.exp: New target test driver. * gcc.target/hppa/shadd-1.c: New test. From-SVN: r223480 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9218257629f..c02cdadc7de 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -15,6 +15,17 @@ * genrecog.c (MAX_DEPTH, MIN_NUM_STATEMENTS, MAX_NUM_STATEMENTS): Change to unsigned int. +2015-05-20 Jeff Law + + * config/pa/pa.c (pa_print_operand): New 'o' output modifier. + (pa_mem_shadd_constant_p): Renamed from pa_shadd_constant_p. + (pa_shadd_constant_p): Allow constants for shadd insns rather + than valid scaling constants for memory addresses. + * config/pa/pa-protos.h (pa_mem_shadd_constant_p): Add prototype. + * config/pa/predicates.md (mem_shadd_operand): New predicate. + * config/pa/pa.md (shift-add insns using MULT): Use mem_shadd_operand. + (shift-add insns using ASHIFT): New patterns. + 2015-05-20 Mikhail Maltsev * bb-reorder.c (set_edge_can_fallthru_flag): Use rtx_jump_insn where diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h index 4a44dab6710..58cc463b7c4 100644 --- a/gcc/config/pa/pa-protos.h +++ b/gcc/config/pa/pa-protos.h @@ -85,6 +85,7 @@ extern int pa_and_mask_p (unsigned HOST_WIDE_INT); extern int pa_cint_ok_for_move (HOST_WIDE_INT); extern int pa_ior_mask_p (unsigned HOST_WIDE_INT); extern int pa_ldil_cint_p (HOST_WIDE_INT); +extern int pa_mem_shadd_constant_p (int); extern int pa_shadd_constant_p (int); extern int pa_zdepi_cint_p (unsigned HOST_WIDE_INT); diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index cfdafa69c27..f99cf335f49 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -5242,6 +5242,11 @@ pa_print_operand (FILE *file, rtx x, int code) gcc_assert (GET_CODE (x) == CONST_INT); fprintf (file, HOST_WIDE_INT_PRINT_DEC, 32 - (INTVAL (x) & 31)); return; + case 'o': + gcc_assert (GET_CODE (x) == CONST_INT + && (INTVAL (x) == 1 || INTVAL (x) == 2 || INTVAL (x) == 3)); + fprintf (file, "%d", INTVAL (x)); + return; case 'O': gcc_assert (GET_CODE (x) == CONST_INT && exact_log2 (INTVAL (x)) >= 0); fprintf (file, "%d", exact_log2 (INTVAL (x))); @@ -8729,11 +8734,22 @@ pa_fmpysuboperands (rtx *operands) } /* Return 1 if the given constant is 2, 4, or 8. These are the valid + constants for a MULT embedded inside a memory address. */ +int +pa_mem_shadd_constant_p (int val) +{ + if (val == 2 || val == 4 || val == 8) + return 1; + else + return 0; +} + +/* Return 1 if the given constant is 1, 2, or 3. These are the valid constants for shadd instructions. */ int pa_shadd_constant_p (int val) { - if (val == 2 || val == 4 || val == 8) + if (val == 1 || val == 2 || val == 3) return 1; else return 0; diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md index cc077a419e5..73c8f6bce13 100644 --- a/gcc/config/pa/pa.md +++ b/gcc/config/pa/pa.md @@ -6337,7 +6337,7 @@ (define_insn "" [(set (match_operand:SI 0 "register_operand" "=r") (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r") - (match_operand:SI 3 "shadd_operand" "")) + (match_operand:SI 3 "mem_shadd_operand" "")) (match_operand:SI 1 "register_operand" "r")))] "" "{sh%O3addl %2,%1,%0|shladd,l %2,%O3,%1,%0} " @@ -6347,13 +6347,33 @@ (define_insn "" [(set (match_operand:DI 0 "register_operand" "=r") (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r") - (match_operand:DI 3 "shadd_operand" "")) + (match_operand:DI 3 "mem_shadd_operand" "")) (match_operand:DI 1 "register_operand" "r")))] "TARGET_64BIT" "shladd,l %2,%O3,%1,%0" [(set_attr "type" "binary") (set_attr "length" "4")]) +(define_insn "" + [(set (match_operand:SI 0 "register_operand" "=r") + (plus:SI (ashift:SI (match_operand:SI 2 "register_operand" "r") + (match_operand:SI 3 "shadd_operand" "")) + (match_operand:SI 1 "register_operand" "r")))] + "" + "{sh%o3addl %2,%1,%0|shladd,l %2,%o3,%1,%0} " + [(set_attr "type" "binary") + (set_attr "length" "4")]) + +(define_insn "" + [(set (match_operand:DI 0 "register_operand" "=r") + (plus:DI (ashift:DI (match_operand:DI 2 "register_operand" "r") + (match_operand:DI 3 "shadd_operand" "")) + (match_operand:DI 1 "register_operand" "r")))] + "TARGET_64BIT" + "shladd,l %2,%o3,%1,%0" + [(set_attr "type" "binary") + (set_attr "length" "4")]) + (define_expand "ashlsi3" [(set (match_operand:SI 0 "register_operand" "") (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "") diff --git a/gcc/config/pa/predicates.md b/gcc/config/pa/predicates.md index fcf68462d4c..bbbaa852b25 100644 --- a/gcc/config/pa/predicates.md +++ b/gcc/config/pa/predicates.md @@ -581,6 +581,10 @@ ;; Return 1 if OP is a CONST_INT with the value 2, 4, or 8. These are ;; the valid constants for shadd instructions. +(define_predicate "mem_shadd_operand" + (and (match_code "const_int") + (match_test "pa_mem_shadd_constant_p (INTVAL (op))"))) + (define_predicate "shadd_operand" (and (match_code "const_int") (match_test "pa_shadd_constant_p (INTVAL (op))"))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2cd1577e067..dd6c236d906 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -28,6 +28,11 @@ * gcc.dg/format/c90-printf-1.c: Likewise. Add tests for column locations within strings with embedded escape sequences. +2015-05-20 Jeff Law + + * gcc.target/hppa/hppa.exp: New target test driver. + * gcc.target/hppa/shadd-1.c: New test. + 2015-05-20 Alex Velenko * gcc.target/arm/thumb1-far-jump-2.c (r4): Added int in definition. diff --git a/gcc/testsuite/gcc.target/hppa/hppa.exp b/gcc/testsuite/gcc.target/hppa/hppa.exp new file mode 100644 index 00000000000..a47141d6d5d --- /dev/null +++ b/gcc/testsuite/gcc.target/hppa/hppa.exp @@ -0,0 +1,41 @@ +# Copyright (C) 1997-2015 Free Software Foundation, Inc. + +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 +# . + +# GCC testsuite that uses the `dg.exp' driver. + +# Exit immediately if this isn't an m68k target. +if { ![istarget hppa*-*-*] } then { + return +} + +# Load support procs. +load_lib gcc-dg.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS " -ansi -pedantic-errors" +} + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \ + "" $DEFAULT_CFLAGS + +# All done. +dg-finish diff --git a/gcc/testsuite/gcc.target/hppa/shadd-1.c b/gcc/testsuite/gcc.target/hppa/shadd-1.c new file mode 100644 index 00000000000..de4776bc5b0 --- /dev/null +++ b/gcc/testsuite/gcc.target/hppa/shadd-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times "sh.add" 1 } } */ + +typedef struct +{ + unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))]; +} +__sigset_t; +int +__sigaddset (__sigset_t * __set, int __sig, int __stuff) +{ + unsigned long int __word = + (((__sig) - 1) / (8 * sizeof (unsigned long int))); + return __set->__val[__word] |= __stuff; +}