OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [rtlhooks.c] - Diff between revs 816 and 826

Only display areas with differences | Details | Blame | View Log

Rev 816 Rev 826
/* Generic hooks for the RTL middle-end.
/* Generic hooks for the RTL middle-end.
   Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
   Copyright (C) 2004, 2005, 2007, 2008 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 it under
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
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
Software Foundation; either version 3, or (at your option) any later
version.
version.
 
 
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.
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
<http://www.gnu.org/licenses/>.  */
<http://www.gnu.org/licenses/>.  */
 
 
#include "config.h"
#include "config.h"
#include "system.h"
#include "system.h"
#include "coretypes.h"
#include "coretypes.h"
#include "tm.h"
#include "tm.h"
#include "rtl.h"
#include "rtl.h"
#include "rtlhooks-def.h"
#include "rtlhooks-def.h"
#include "expr.h"
#include "expr.h"
#include "recog.h"
#include "recog.h"


 
 
/* For speed, we will copy the RTX hooks struct member-by-member
/* For speed, we will copy the RTX hooks struct member-by-member
   instead of doing indirect calls.  For these reason, we initialize
   instead of doing indirect calls.  For these reason, we initialize
   *two* struct rtl_hooks globals: rtl_hooks is the one that is used
   *two* struct rtl_hooks globals: rtl_hooks is the one that is used
   to actually call the hooks, while general_rtl_hooks is used
   to actually call the hooks, while general_rtl_hooks is used
   to restore the hooks by passes that modify them.  */
   to restore the hooks by passes that modify them.  */
 
 
const struct rtl_hooks general_rtl_hooks = RTL_HOOKS_INITIALIZER;
const struct rtl_hooks general_rtl_hooks = RTL_HOOKS_INITIALIZER;
struct rtl_hooks rtl_hooks = RTL_HOOKS_INITIALIZER;
struct rtl_hooks rtl_hooks = RTL_HOOKS_INITIALIZER;
 
 
rtx
rtx
gen_lowpart_general (enum machine_mode mode, rtx x)
gen_lowpart_general (enum machine_mode mode, rtx x)
{
{
  rtx result = gen_lowpart_common (mode, x);
  rtx result = gen_lowpart_common (mode, x);
 
 
  if (result)
  if (result)
    return result;
    return result;
  /* Handle SUBREGs and hard REGs that were rejected by
  /* Handle SUBREGs and hard REGs that were rejected by
     simplify_gen_subreg.  */
     simplify_gen_subreg.  */
  else if (REG_P (x) || GET_CODE (x) == SUBREG)
  else if (REG_P (x) || GET_CODE (x) == SUBREG)
    {
    {
      result = gen_lowpart_common (mode, copy_to_reg (x));
      result = gen_lowpart_common (mode, copy_to_reg (x));
      gcc_assert (result != 0);
      gcc_assert (result != 0);
      return result;
      return result;
    }
    }
  else
  else
    {
    {
      int offset = 0;
      int offset = 0;
 
 
      /* The only additional case we can do is MEM.  */
      /* The only additional case we can do is MEM.  */
      gcc_assert (MEM_P (x));
      gcc_assert (MEM_P (x));
 
 
      /* The following exposes the use of "x" to CSE.  */
      /* The following exposes the use of "x" to CSE.  */
      if (GET_MODE_SIZE (GET_MODE (x)) <= UNITS_PER_WORD
      if (GET_MODE_SIZE (GET_MODE (x)) <= UNITS_PER_WORD
          && SCALAR_INT_MODE_P (GET_MODE (x))
          && SCALAR_INT_MODE_P (GET_MODE (x))
          && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
          && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
                                    GET_MODE_BITSIZE (GET_MODE (x)))
                                    GET_MODE_BITSIZE (GET_MODE (x)))
          && !reload_completed)
          && !reload_completed)
        return gen_lowpart_general (mode, force_reg (GET_MODE (x), x));
        return gen_lowpart_general (mode, force_reg (GET_MODE (x), x));
 
 
      if (WORDS_BIG_ENDIAN)
      if (WORDS_BIG_ENDIAN)
        offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
        offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
                  - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
                  - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
 
 
      if (BYTES_BIG_ENDIAN)
      if (BYTES_BIG_ENDIAN)
        /* Adjust the address so that the address-after-the-data
        /* Adjust the address so that the address-after-the-data
           is unchanged.  */
           is unchanged.  */
        offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
        offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
                   - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
                   - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
 
 
      return adjust_address (x, mode, offset);
      return adjust_address (x, mode, offset);
    }
    }
}
}
 
 
/* Similar to gen_lowpart, but cannot emit any instruction via
/* Similar to gen_lowpart, but cannot emit any instruction via
   copy_to_reg or force_reg.  Mainly used in simplify-rtx.c.  */
   copy_to_reg or force_reg.  Mainly used in simplify-rtx.c.  */
rtx
rtx
gen_lowpart_no_emit_general (enum machine_mode mode, rtx x)
gen_lowpart_no_emit_general (enum machine_mode mode, rtx x)
{
{
  rtx result = gen_lowpart_if_possible (mode, x);
  rtx result = gen_lowpart_if_possible (mode, x);
  if (result)
  if (result)
    return result;
    return result;
  else
  else
    return x;
    return x;
}
}
 
 
rtx
rtx
reg_num_sign_bit_copies_general (const_rtx x ATTRIBUTE_UNUSED,
reg_num_sign_bit_copies_general (const_rtx x ATTRIBUTE_UNUSED,
                                 enum machine_mode mode ATTRIBUTE_UNUSED,
                                 enum machine_mode mode ATTRIBUTE_UNUSED,
                                 const_rtx known_x ATTRIBUTE_UNUSED,
                                 const_rtx known_x ATTRIBUTE_UNUSED,
                                 enum machine_mode known_mode ATTRIBUTE_UNUSED,
                                 enum machine_mode known_mode ATTRIBUTE_UNUSED,
                                 unsigned int known_ret ATTRIBUTE_UNUSED,
                                 unsigned int known_ret ATTRIBUTE_UNUSED,
                                 unsigned int *result ATTRIBUTE_UNUSED)
                                 unsigned int *result ATTRIBUTE_UNUSED)
{
{
  return NULL;
  return NULL;
}
}
 
 
rtx
rtx
reg_nonzero_bits_general (const_rtx x ATTRIBUTE_UNUSED,
reg_nonzero_bits_general (const_rtx x ATTRIBUTE_UNUSED,
                          enum machine_mode mode ATTRIBUTE_UNUSED,
                          enum machine_mode mode ATTRIBUTE_UNUSED,
                          const_rtx known_x ATTRIBUTE_UNUSED,
                          const_rtx known_x ATTRIBUTE_UNUSED,
                          enum machine_mode known_mode ATTRIBUTE_UNUSED,
                          enum machine_mode known_mode ATTRIBUTE_UNUSED,
                          unsigned HOST_WIDE_INT known_ret ATTRIBUTE_UNUSED,
                          unsigned HOST_WIDE_INT known_ret ATTRIBUTE_UNUSED,
                          unsigned HOST_WIDE_INT *nonzero ATTRIBUTE_UNUSED)
                          unsigned HOST_WIDE_INT *nonzero ATTRIBUTE_UNUSED)
{
{
  return NULL;
  return NULL;
}
}
 
 
bool
bool
reg_truncated_to_mode_general (enum machine_mode mode ATTRIBUTE_UNUSED,
reg_truncated_to_mode_general (enum machine_mode mode ATTRIBUTE_UNUSED,
                               const_rtx x ATTRIBUTE_UNUSED)
                               const_rtx x ATTRIBUTE_UNUSED)
{
{
  return false;
  return false;
}
}
 
 
/* Assuming that X is an rtx (e.g., MEM, REG or SUBREG) for a fixed-point
/* Assuming that X is an rtx (e.g., MEM, REG or SUBREG) for a fixed-point
   number, return an rtx (MEM, SUBREG, or CONST_INT) that refers to the
   number, return an rtx (MEM, SUBREG, or CONST_INT) that refers to the
   least-significant part of X.
   least-significant part of X.
   MODE specifies how big a part of X to return.
   MODE specifies how big a part of X to return.
 
 
   If the requested operation cannot be done, 0 is returned.
   If the requested operation cannot be done, 0 is returned.
 
 
   This is similar to gen_lowpart_general.  */
   This is similar to gen_lowpart_general.  */
 
 
rtx
rtx
gen_lowpart_if_possible (enum machine_mode mode, rtx x)
gen_lowpart_if_possible (enum machine_mode mode, rtx x)
{
{
  rtx result = gen_lowpart_common (mode, x);
  rtx result = gen_lowpart_common (mode, x);
 
 
  if (result)
  if (result)
    return result;
    return result;
  else if (MEM_P (x))
  else if (MEM_P (x))
    {
    {
      /* This is the only other case we handle.  */
      /* This is the only other case we handle.  */
      int offset = 0;
      int offset = 0;
      rtx new_rtx;
      rtx new_rtx;
 
 
      if (WORDS_BIG_ENDIAN)
      if (WORDS_BIG_ENDIAN)
        offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
        offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
                  - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
                  - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
      if (BYTES_BIG_ENDIAN)
      if (BYTES_BIG_ENDIAN)
        /* Adjust the address so that the address-after-the-data is
        /* Adjust the address so that the address-after-the-data is
           unchanged.  */
           unchanged.  */
        offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
        offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
                   - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
                   - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
 
 
      new_rtx = adjust_address_nv (x, mode, offset);
      new_rtx = adjust_address_nv (x, mode, offset);
      if (! memory_address_addr_space_p (mode, XEXP (new_rtx, 0),
      if (! memory_address_addr_space_p (mode, XEXP (new_rtx, 0),
                                         MEM_ADDR_SPACE (x)))
                                         MEM_ADDR_SPACE (x)))
        return 0;
        return 0;
 
 
      return new_rtx;
      return new_rtx;
    }
    }
  else if (mode != GET_MODE (x) && GET_MODE (x) != VOIDmode
  else if (mode != GET_MODE (x) && GET_MODE (x) != VOIDmode
           && validate_subreg (mode, GET_MODE (x), x,
           && validate_subreg (mode, GET_MODE (x), x,
                                subreg_lowpart_offset (mode, GET_MODE (x))))
                                subreg_lowpart_offset (mode, GET_MODE (x))))
    return gen_lowpart_SUBREG (mode, x);
    return gen_lowpart_SUBREG (mode, x);
  else
  else
    return 0;
    return 0;
}
}


 
 

powered by: WebSVN 2.1.0

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