OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [config/] [iq2000/] [predicates.md] - Diff between revs 38 and 154

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 38 Rev 154
;; Predicate definitions for Vitesse IQ2000.
;; Predicate definitions for Vitesse IQ2000.
;; Copyright (C) 2005, 2007 Free Software Foundation, Inc.
;; Copyright (C) 2005, 2007 Free Software Foundation, Inc.
;;
;;
;; This file is part of GCC.
;; This file is part of GCC.
;;
;;
;; GCC is free software; you can redistribute it and/or modify
;; GCC is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; any later version.
;;
;;
;; GCC is distributed in the hope that it will be useful,
;; GCC is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;; GNU General Public License for more details.
;;
;;
;; You should have received a copy of the GNU General Public License
;; You should have received a copy of the GNU General Public License
;; along with GCC; see the file COPYING3.  If not see
;; along with GCC; see the file COPYING3.  If not see
;; .
;; .
;; Return 1 if OP can be used as an operand where a register or 16 bit
;; Return 1 if OP can be used as an operand where a register or 16 bit
;; unsigned integer is needed.
;; unsigned integer is needed.
(define_predicate "uns_arith_operand"
(define_predicate "uns_arith_operand"
  (match_code "reg,const_int,subreg")
  (match_code "reg,const_int,subreg")
{
{
  if (GET_CODE (op) == CONST_INT && SMALL_INT_UNSIGNED (op))
  if (GET_CODE (op) == CONST_INT && SMALL_INT_UNSIGNED (op))
    return 1;
    return 1;
  return register_operand (op, mode);
  return register_operand (op, mode);
})
})
;; Return 1 if OP can be used as an operand where a 16 bit integer is
;; Return 1 if OP can be used as an operand where a 16 bit integer is
;; needed.
;; needed.
(define_predicate "arith_operand"
(define_predicate "arith_operand"
  (match_code "reg,const_int,subreg")
  (match_code "reg,const_int,subreg")
{
{
  if (GET_CODE (op) == CONST_INT && SMALL_INT (op))
  if (GET_CODE (op) == CONST_INT && SMALL_INT (op))
    return 1;
    return 1;
  return register_operand (op, mode);
  return register_operand (op, mode);
})
})
;; Return 1 if OP is a integer which fits in 16 bits.
;; Return 1 if OP is a integer which fits in 16 bits.
(define_predicate "small_int"
(define_predicate "small_int"
  (match_code "const_int")
  (match_code "const_int")
{
{
  return (GET_CODE (op) == CONST_INT && SMALL_INT (op));
  return (GET_CODE (op) == CONST_INT && SMALL_INT (op));
})
})
;; Return 1 if OP is a 32 bit integer which is too big to be loaded
;; Return 1 if OP is a 32 bit integer which is too big to be loaded
;; with one instruction.
;; with one instruction.
(define_predicate "large_int"
(define_predicate "large_int"
  (match_code "const_int")
  (match_code "const_int")
{
{
  HOST_WIDE_INT value;
  HOST_WIDE_INT value;
  if (GET_CODE (op) != CONST_INT)
  if (GET_CODE (op) != CONST_INT)
    return 0;
    return 0;
  value = INTVAL (op);
  value = INTVAL (op);
  /* IOR reg,$r0,value.  */
  /* IOR reg,$r0,value.  */
  if ((value & ~ ((HOST_WIDE_INT) 0x0000ffff)) == 0)
  if ((value & ~ ((HOST_WIDE_INT) 0x0000ffff)) == 0)
    return 0;
    return 0;
  /* SUBU reg,$r0,value.  */
  /* SUBU reg,$r0,value.  */
  if (((unsigned HOST_WIDE_INT) (value + 32768)) <= 32767)
  if (((unsigned HOST_WIDE_INT) (value + 32768)) <= 32767)
    return 0;
    return 0;
  /* LUI reg,value >> 16.  */
  /* LUI reg,value >> 16.  */
  if ((value & 0x0000ffff) == 0)
  if ((value & 0x0000ffff) == 0)
    return 0;
    return 0;
  return 1;
  return 1;
})
})
;; Return 1 if OP is a register or the constant 0.
;; Return 1 if OP is a register or the constant 0.
(define_predicate "reg_or_0_operand"
(define_predicate "reg_or_0_operand"
  (match_code "reg,const_int,const_double,subreg")
  (match_code "reg,const_int,const_double,subreg")
{
{
  switch (GET_CODE (op))
  switch (GET_CODE (op))
    {
    {
    case CONST_INT:
    case CONST_INT:
      return INTVAL (op) == 0;
      return INTVAL (op) == 0;
    case CONST_DOUBLE:
    case CONST_DOUBLE:
      return op == CONST0_RTX (mode);
      return op == CONST0_RTX (mode);
    case REG:
    case REG:
    case SUBREG:
    case SUBREG:
      return register_operand (op, mode);
      return register_operand (op, mode);
    default:
    default:
      break;
      break;
    }
    }
  return 0;
  return 0;
})
})
;; Return 1 if OP is a memory operand that fits in a single
;; Return 1 if OP is a memory operand that fits in a single
;; instruction (i.e., register + small offset).
;; instruction (i.e., register + small offset).
(define_predicate "simple_memory_operand"
(define_predicate "simple_memory_operand"
  (match_code "mem,subreg")
  (match_code "mem,subreg")
{
{
  rtx addr, plus0, plus1;
  rtx addr, plus0, plus1;
  /* Eliminate non-memory operations.  */
  /* Eliminate non-memory operations.  */
  if (GET_CODE (op) != MEM)
  if (GET_CODE (op) != MEM)
    return 0;
    return 0;
  /* Dword operations really put out 2 instructions, so eliminate them.  */
  /* Dword operations really put out 2 instructions, so eliminate them.  */
  if (GET_MODE_SIZE (GET_MODE (op)) > (unsigned) UNITS_PER_WORD)
  if (GET_MODE_SIZE (GET_MODE (op)) > (unsigned) UNITS_PER_WORD)
    return 0;
    return 0;
  /* Decode the address now.  */
  /* Decode the address now.  */
  addr = XEXP (op, 0);
  addr = XEXP (op, 0);
  switch (GET_CODE (addr))
  switch (GET_CODE (addr))
    {
    {
    case REG:
    case REG:
    case LO_SUM:
    case LO_SUM:
      return 1;
      return 1;
    case CONST_INT:
    case CONST_INT:
      return SMALL_INT (addr);
      return SMALL_INT (addr);
    case PLUS:
    case PLUS:
      plus0 = XEXP (addr, 0);
      plus0 = XEXP (addr, 0);
      plus1 = XEXP (addr, 1);
      plus1 = XEXP (addr, 1);
      if (GET_CODE (plus0) == REG
      if (GET_CODE (plus0) == REG
          && GET_CODE (plus1) == CONST_INT && SMALL_INT (plus1)
          && GET_CODE (plus1) == CONST_INT && SMALL_INT (plus1)
          && SMALL_INT_UNSIGNED (plus1) /* No negative offsets.  */)
          && SMALL_INT_UNSIGNED (plus1) /* No negative offsets.  */)
        return 1;
        return 1;
      else if (GET_CODE (plus1) == REG
      else if (GET_CODE (plus1) == REG
               && GET_CODE (plus0) == CONST_INT && SMALL_INT (plus0)
               && GET_CODE (plus0) == CONST_INT && SMALL_INT (plus0)
               && SMALL_INT_UNSIGNED (plus1) /* No negative offsets.  */)
               && SMALL_INT_UNSIGNED (plus1) /* No negative offsets.  */)
        return 1;
        return 1;
      else
      else
        return 0;
        return 0;
    case SYMBOL_REF:
    case SYMBOL_REF:
      return 0;
      return 0;
    default:
    default:
      break;
      break;
    }
    }
  return 0;
  return 0;
})
})
;; Return nonzero if the code of this rtx pattern is EQ or NE.
;; Return nonzero if the code of this rtx pattern is EQ or NE.
(define_predicate "equality_op"
(define_predicate "equality_op"
  (match_code "eq,ne")
  (match_code "eq,ne")
{
{
  if (mode != GET_MODE (op))
  if (mode != GET_MODE (op))
    return 0;
    return 0;
  return GET_CODE (op) == EQ || GET_CODE (op) == NE;
  return GET_CODE (op) == EQ || GET_CODE (op) == NE;
})
})
;; Return nonzero if the code is a relational operations (EQ, LE,
;; Return nonzero if the code is a relational operations (EQ, LE,
;; etc).
;; etc).
(define_predicate "cmp_op"
(define_predicate "cmp_op"
  (match_code "eq,ne,gt,ge,gtu,geu,lt,le,ltu,leu")
  (match_code "eq,ne,gt,ge,gtu,geu,lt,le,ltu,leu")
{
{
  if (mode != GET_MODE (op))
  if (mode != GET_MODE (op))
    return 0;
    return 0;
  return COMPARISON_P (op);
  return COMPARISON_P (op);
})
})
;; Return nonzero if the operand is either the PC or a label_ref.
;; Return nonzero if the operand is either the PC or a label_ref.
(define_special_predicate "pc_or_label_operand"
(define_special_predicate "pc_or_label_operand"
  (match_code "pc,label_ref")
  (match_code "pc,label_ref")
{
{
  if (op == pc_rtx)
  if (op == pc_rtx)
    return 1;
    return 1;
  if (GET_CODE (op) == LABEL_REF)
  if (GET_CODE (op) == LABEL_REF)
    return 1;
    return 1;
  return 0;
  return 0;
})
})
;; Return nonzero if OP is a valid operand for a call instruction.
;; Return nonzero if OP is a valid operand for a call instruction.
(define_predicate "call_insn_operand"
(define_predicate "call_insn_operand"
  (match_code "const_int,const,symbol_ref,reg")
  (match_code "const_int,const,symbol_ref,reg")
{
{
  return (CONSTANT_ADDRESS_P (op)
  return (CONSTANT_ADDRESS_P (op)
          || (GET_CODE (op) == REG && op != arg_pointer_rtx
          || (GET_CODE (op) == REG && op != arg_pointer_rtx
              && ! (REGNO (op) >= FIRST_PSEUDO_REGISTER
              && ! (REGNO (op) >= FIRST_PSEUDO_REGISTER
                    && REGNO (op) <= LAST_VIRTUAL_REGISTER)));
                    && REGNO (op) <= LAST_VIRTUAL_REGISTER)));
})
})
;; Return nonzero if OP is valid as a source operand for a move
;; Return nonzero if OP is valid as a source operand for a move
;; instruction.
;; instruction.
(define_predicate "move_operand"
(define_predicate "move_operand"
  (match_code "const_int,const_double,const,symbol_ref,label_ref,subreg,reg,mem")
  (match_code "const_int,const_double,const,symbol_ref,label_ref,subreg,reg,mem")
{
{
  /* Accept any general operand after reload has started; doing so
  /* Accept any general operand after reload has started; doing so
     avoids losing if reload does an in-place replacement of a register
     avoids losing if reload does an in-place replacement of a register
     with a SYMBOL_REF or CONST.  */
     with a SYMBOL_REF or CONST.  */
  return (general_operand (op, mode)
  return (general_operand (op, mode)
          && (! (iq2000_check_split (op, mode))
          && (! (iq2000_check_split (op, mode))
              || reload_in_progress || reload_completed));
              || reload_in_progress || reload_completed));
})
})
;; Return nonzero if OP is a constant power of 2.
;; Return nonzero if OP is a constant power of 2.
(define_predicate "power_of_2_operand"
(define_predicate "power_of_2_operand"
  (match_code "const_int")
  (match_code "const_int")
{
{
  int intval;
  int intval;
  if (GET_CODE (op) != CONST_INT)
  if (GET_CODE (op) != CONST_INT)
    return 0;
    return 0;
  else
  else
    intval = INTVAL (op);
    intval = INTVAL (op);
  return ((intval & ((unsigned)(intval) - 1)) == 0);
  return ((intval & ((unsigned)(intval) - 1)) == 0);
})
})
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.