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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [tree-gimple.c] - Diff between revs 38 and 154

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

Rev 38 Rev 154
/* Functions to analyze and validate GIMPLE trees.
/* Functions to analyze and validate GIMPLE trees.
   Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
   Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
   Contributed by Diego Novillo <dnovillo@redhat.com>
   Contributed by Diego Novillo <dnovillo@redhat.com>
   Rewritten by Jason Merrill <jason@redhat.com>
   Rewritten by Jason Merrill <jason@redhat.com>
 
 
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
<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 "ggc.h"
#include "ggc.h"
#include "tm.h"
#include "tm.h"
#include "tree.h"
#include "tree.h"
#include "tree-gimple.h"
#include "tree-gimple.h"
#include "tree-flow.h"
#include "tree-flow.h"
#include "output.h"
#include "output.h"
#include "rtl.h"
#include "rtl.h"
#include "expr.h"
#include "expr.h"
#include "bitmap.h"
#include "bitmap.h"
 
 
/* For the definitive definition of GIMPLE, see doc/tree-ssa.texi.  */
/* For the definitive definition of GIMPLE, see doc/tree-ssa.texi.  */
 
 
/* Validation of GIMPLE expressions.  */
/* Validation of GIMPLE expressions.  */
 
 
/* Return true if T is a GIMPLE RHS for an assignment to a temporary.  */
/* Return true if T is a GIMPLE RHS for an assignment to a temporary.  */
 
 
bool
bool
is_gimple_formal_tmp_rhs (tree t)
is_gimple_formal_tmp_rhs (tree t)
{
{
  enum tree_code code = TREE_CODE (t);
  enum tree_code code = TREE_CODE (t);
 
 
  switch (TREE_CODE_CLASS (code))
  switch (TREE_CODE_CLASS (code))
    {
    {
    case tcc_unary:
    case tcc_unary:
    case tcc_binary:
    case tcc_binary:
    case tcc_comparison:
    case tcc_comparison:
      return true;
      return true;
 
 
    default:
    default:
      break;
      break;
    }
    }
 
 
  switch (code)
  switch (code)
    {
    {
    case TRUTH_NOT_EXPR:
    case TRUTH_NOT_EXPR:
    case TRUTH_AND_EXPR:
    case TRUTH_AND_EXPR:
    case TRUTH_OR_EXPR:
    case TRUTH_OR_EXPR:
    case TRUTH_XOR_EXPR:
    case TRUTH_XOR_EXPR:
    case ADDR_EXPR:
    case ADDR_EXPR:
    case CALL_EXPR:
    case CALL_EXPR:
    case CONSTRUCTOR:
    case CONSTRUCTOR:
    case COMPLEX_EXPR:
    case COMPLEX_EXPR:
    case INTEGER_CST:
    case INTEGER_CST:
    case REAL_CST:
    case REAL_CST:
    case STRING_CST:
    case STRING_CST:
    case COMPLEX_CST:
    case COMPLEX_CST:
    case VECTOR_CST:
    case VECTOR_CST:
    case OBJ_TYPE_REF:
    case OBJ_TYPE_REF:
    case ASSERT_EXPR:
    case ASSERT_EXPR:
      return true;
      return true;
 
 
    default:
    default:
      break;
      break;
    }
    }
 
 
  return is_gimple_lvalue (t) || is_gimple_val (t);
  return is_gimple_lvalue (t) || is_gimple_val (t);
}
}
 
 
/* Returns true iff T is a valid RHS for an assignment to a renamed
/* Returns true iff T is a valid RHS for an assignment to a renamed
   user -- or front-end generated artificial -- variable.  */
   user -- or front-end generated artificial -- variable.  */
 
 
bool
bool
is_gimple_reg_rhs (tree t)
is_gimple_reg_rhs (tree t)
{
{
  /* If the RHS of the MODIFY_EXPR may throw or make a nonlocal goto
  /* If the RHS of the MODIFY_EXPR may throw or make a nonlocal goto
     and the LHS is a user variable, then we need to introduce a formal
     and the LHS is a user variable, then we need to introduce a formal
     temporary.  This way the optimizers can determine that the user
     temporary.  This way the optimizers can determine that the user
     variable is only modified if evaluation of the RHS does not throw.
     variable is only modified if evaluation of the RHS does not throw.
 
 
     Don't force a temp of a non-renamable type; the copy could be
     Don't force a temp of a non-renamable type; the copy could be
     arbitrarily expensive.  Instead we will generate a V_MAY_DEF for
     arbitrarily expensive.  Instead we will generate a V_MAY_DEF for
     the assignment.  */
     the assignment.  */
 
 
  if (is_gimple_reg_type (TREE_TYPE (t))
  if (is_gimple_reg_type (TREE_TYPE (t))
      && ((TREE_CODE (t) == CALL_EXPR && TREE_SIDE_EFFECTS (t))
      && ((TREE_CODE (t) == CALL_EXPR && TREE_SIDE_EFFECTS (t))
          || tree_could_throw_p (t)))
          || tree_could_throw_p (t)))
    return false;
    return false;
 
 
  return is_gimple_formal_tmp_rhs (t);
  return is_gimple_formal_tmp_rhs (t);
}
}
 
 
/* Returns true iff T is a valid RHS for an assignment to an un-renamed
/* Returns true iff T is a valid RHS for an assignment to an un-renamed
   LHS, or for a call argument.  */
   LHS, or for a call argument.  */
 
 
bool
bool
is_gimple_mem_rhs (tree t)
is_gimple_mem_rhs (tree t)
{
{
  /* If we're dealing with a renamable type, either source or dest must be
  /* If we're dealing with a renamable type, either source or dest must be
     a renamed variable.  Also force a temporary if the type doesn't need
     a renamed variable.  Also force a temporary if the type doesn't need
     to be stored in memory, since it's cheap and prevents erroneous
     to be stored in memory, since it's cheap and prevents erroneous
     tailcalls (PR 17526).  */
     tailcalls (PR 17526).  */
  if (is_gimple_reg_type (TREE_TYPE (t))
  if (is_gimple_reg_type (TREE_TYPE (t))
      || (TYPE_MODE (TREE_TYPE (t)) != BLKmode
      || (TYPE_MODE (TREE_TYPE (t)) != BLKmode
          && (TREE_CODE (t) != CALL_EXPR
          && (TREE_CODE (t) != CALL_EXPR
              || ! aggregate_value_p (t, t))))
              || ! aggregate_value_p (t, t))))
    return is_gimple_val (t);
    return is_gimple_val (t);
  else
  else
    return is_gimple_formal_tmp_rhs (t);
    return is_gimple_formal_tmp_rhs (t);
}
}
 
 
/* Returns the appropriate RHS predicate for this LHS.  */
/* Returns the appropriate RHS predicate for this LHS.  */
 
 
gimple_predicate
gimple_predicate
rhs_predicate_for (tree lhs)
rhs_predicate_for (tree lhs)
{
{
  if (is_gimple_formal_tmp_var (lhs))
  if (is_gimple_formal_tmp_var (lhs))
    return is_gimple_formal_tmp_rhs;
    return is_gimple_formal_tmp_rhs;
  else if (is_gimple_reg (lhs))
  else if (is_gimple_reg (lhs))
    return is_gimple_reg_rhs;
    return is_gimple_reg_rhs;
  else
  else
    return is_gimple_mem_rhs;
    return is_gimple_mem_rhs;
}
}
 
 
/*  Return true if T is a valid LHS for a GIMPLE assignment expression.  */
/*  Return true if T is a valid LHS for a GIMPLE assignment expression.  */
 
 
bool
bool
is_gimple_lvalue (tree t)
is_gimple_lvalue (tree t)
{
{
  return (is_gimple_addressable (t)
  return (is_gimple_addressable (t)
          || TREE_CODE (t) == WITH_SIZE_EXPR
          || TREE_CODE (t) == WITH_SIZE_EXPR
          /* These are complex lvalues, but don't have addresses, so they
          /* These are complex lvalues, but don't have addresses, so they
             go here.  */
             go here.  */
          || TREE_CODE (t) == BIT_FIELD_REF);
          || TREE_CODE (t) == BIT_FIELD_REF);
}
}
 
 
/*  Return true if T is a GIMPLE condition.  */
/*  Return true if T is a GIMPLE condition.  */
 
 
bool
bool
is_gimple_condexpr (tree t)
is_gimple_condexpr (tree t)
{
{
  return (is_gimple_val (t) || COMPARISON_CLASS_P (t));
  return (is_gimple_val (t) || COMPARISON_CLASS_P (t));
}
}
 
 
/*  Return true if T is something whose address can be taken.  */
/*  Return true if T is something whose address can be taken.  */
 
 
bool
bool
is_gimple_addressable (tree t)
is_gimple_addressable (tree t)
{
{
  return (is_gimple_id (t) || handled_component_p (t)
  return (is_gimple_id (t) || handled_component_p (t)
          || INDIRECT_REF_P (t));
          || INDIRECT_REF_P (t));
}
}
 
 
/* Return true if T is function invariant.  Or rather a restricted
/* Return true if T is function invariant.  Or rather a restricted
   form of function invariant.  */
   form of function invariant.  */
 
 
bool
bool
is_gimple_min_invariant (tree t)
is_gimple_min_invariant (tree t)
{
{
  switch (TREE_CODE (t))
  switch (TREE_CODE (t))
    {
    {
    case ADDR_EXPR:
    case ADDR_EXPR:
      return TREE_INVARIANT (t);
      return TREE_INVARIANT (t);
 
 
    case INTEGER_CST:
    case INTEGER_CST:
    case REAL_CST:
    case REAL_CST:
    case STRING_CST:
    case STRING_CST:
    case COMPLEX_CST:
    case COMPLEX_CST:
    case VECTOR_CST:
    case VECTOR_CST:
      return true;
      return true;
 
 
    default:
    default:
      return false;
      return false;
    }
    }
}
}
 
 
/* Return true if T looks like a valid GIMPLE statement.  */
/* Return true if T looks like a valid GIMPLE statement.  */
 
 
bool
bool
is_gimple_stmt (tree t)
is_gimple_stmt (tree t)
{
{
  enum tree_code code = TREE_CODE (t);
  enum tree_code code = TREE_CODE (t);
 
 
  switch (code)
  switch (code)
    {
    {
    case NOP_EXPR:
    case NOP_EXPR:
      /* The only valid NOP_EXPR is the empty statement.  */
      /* The only valid NOP_EXPR is the empty statement.  */
      return IS_EMPTY_STMT (t);
      return IS_EMPTY_STMT (t);
 
 
    case BIND_EXPR:
    case BIND_EXPR:
    case COND_EXPR:
    case COND_EXPR:
      /* These are only valid if they're void.  */
      /* These are only valid if they're void.  */
      return TREE_TYPE (t) == NULL || VOID_TYPE_P (TREE_TYPE (t));
      return TREE_TYPE (t) == NULL || VOID_TYPE_P (TREE_TYPE (t));
 
 
    case SWITCH_EXPR:
    case SWITCH_EXPR:
    case GOTO_EXPR:
    case GOTO_EXPR:
    case RETURN_EXPR:
    case RETURN_EXPR:
    case LABEL_EXPR:
    case LABEL_EXPR:
    case CASE_LABEL_EXPR:
    case CASE_LABEL_EXPR:
    case TRY_CATCH_EXPR:
    case TRY_CATCH_EXPR:
    case TRY_FINALLY_EXPR:
    case TRY_FINALLY_EXPR:
    case EH_FILTER_EXPR:
    case EH_FILTER_EXPR:
    case CATCH_EXPR:
    case CATCH_EXPR:
    case ASM_EXPR:
    case ASM_EXPR:
    case RESX_EXPR:
    case RESX_EXPR:
    case PHI_NODE:
    case PHI_NODE:
    case STATEMENT_LIST:
    case STATEMENT_LIST:
    case OMP_PARALLEL:
    case OMP_PARALLEL:
    case OMP_FOR:
    case OMP_FOR:
    case OMP_SECTIONS:
    case OMP_SECTIONS:
    case OMP_SECTION:
    case OMP_SECTION:
    case OMP_SINGLE:
    case OMP_SINGLE:
    case OMP_MASTER:
    case OMP_MASTER:
    case OMP_ORDERED:
    case OMP_ORDERED:
    case OMP_CRITICAL:
    case OMP_CRITICAL:
    case OMP_RETURN:
    case OMP_RETURN:
    case OMP_CONTINUE:
    case OMP_CONTINUE:
      /* These are always void.  */
      /* These are always void.  */
      return true;
      return true;
 
 
    case CALL_EXPR:
    case CALL_EXPR:
    case MODIFY_EXPR:
    case MODIFY_EXPR:
      /* These are valid regardless of their type.  */
      /* These are valid regardless of their type.  */
      return true;
      return true;
 
 
    default:
    default:
      return false;
      return false;
    }
    }
}
}
 
 
/* Return true if T is a variable.  */
/* Return true if T is a variable.  */
 
 
bool
bool
is_gimple_variable (tree t)
is_gimple_variable (tree t)
{
{
  return (TREE_CODE (t) == VAR_DECL
  return (TREE_CODE (t) == VAR_DECL
          || TREE_CODE (t) == PARM_DECL
          || TREE_CODE (t) == PARM_DECL
          || TREE_CODE (t) == RESULT_DECL
          || TREE_CODE (t) == RESULT_DECL
          || TREE_CODE (t) == SSA_NAME);
          || TREE_CODE (t) == SSA_NAME);
}
}
 
 
/*  Return true if T is a GIMPLE identifier (something with an address).  */
/*  Return true if T is a GIMPLE identifier (something with an address).  */
 
 
bool
bool
is_gimple_id (tree t)
is_gimple_id (tree t)
{
{
  return (is_gimple_variable (t)
  return (is_gimple_variable (t)
          || TREE_CODE (t) == FUNCTION_DECL
          || TREE_CODE (t) == FUNCTION_DECL
          || TREE_CODE (t) == LABEL_DECL
          || TREE_CODE (t) == LABEL_DECL
          || TREE_CODE (t) == CONST_DECL
          || TREE_CODE (t) == CONST_DECL
          /* Allow string constants, since they are addressable.  */
          /* Allow string constants, since they are addressable.  */
          || TREE_CODE (t) == STRING_CST);
          || TREE_CODE (t) == STRING_CST);
}
}
 
 
/* Return true if TYPE is a suitable type for a scalar register variable.  */
/* Return true if TYPE is a suitable type for a scalar register variable.  */
 
 
bool
bool
is_gimple_reg_type (tree type)
is_gimple_reg_type (tree type)
{
{
  return !AGGREGATE_TYPE_P (type);
  return !AGGREGATE_TYPE_P (type);
}
}
 
 
/* Return true if T is a non-aggregate register variable.  */
/* Return true if T is a non-aggregate register variable.  */
 
 
bool
bool
is_gimple_reg (tree t)
is_gimple_reg (tree t)
{
{
  if (TREE_CODE (t) == SSA_NAME)
  if (TREE_CODE (t) == SSA_NAME)
    t = SSA_NAME_VAR (t);
    t = SSA_NAME_VAR (t);
 
 
  if (MTAG_P (t))
  if (MTAG_P (t))
    return false;
    return false;
 
 
  if (!is_gimple_variable (t))
  if (!is_gimple_variable (t))
    return false;
    return false;
 
 
  if (!is_gimple_reg_type (TREE_TYPE (t)))
  if (!is_gimple_reg_type (TREE_TYPE (t)))
    return false;
    return false;
 
 
  /* A volatile decl is not acceptable because we can't reuse it as
  /* A volatile decl is not acceptable because we can't reuse it as
     needed.  We need to copy it into a temp first.  */
     needed.  We need to copy it into a temp first.  */
  if (TREE_THIS_VOLATILE (t))
  if (TREE_THIS_VOLATILE (t))
    return false;
    return false;
 
 
  /* We define "registers" as things that can be renamed as needed,
  /* We define "registers" as things that can be renamed as needed,
     which with our infrastructure does not apply to memory.  */
     which with our infrastructure does not apply to memory.  */
  if (needs_to_live_in_memory (t))
  if (needs_to_live_in_memory (t))
    return false;
    return false;
 
 
  /* Hard register variables are an interesting case.  For those that
  /* Hard register variables are an interesting case.  For those that
     are call-clobbered, we don't know where all the calls are, since
     are call-clobbered, we don't know where all the calls are, since
     we don't (want to) take into account which operations will turn
     we don't (want to) take into account which operations will turn
     into libcalls at the rtl level.  For those that are call-saved,
     into libcalls at the rtl level.  For those that are call-saved,
     we don't currently model the fact that calls may in fact change
     we don't currently model the fact that calls may in fact change
     global hard registers, nor do we examine ASM_CLOBBERS at the tree
     global hard registers, nor do we examine ASM_CLOBBERS at the tree
     level, and so miss variable changes that might imply.  All around,
     level, and so miss variable changes that might imply.  All around,
     it seems safest to not do too much optimization with these at the
     it seems safest to not do too much optimization with these at the
     tree level at all.  We'll have to rely on the rtl optimizers to
     tree level at all.  We'll have to rely on the rtl optimizers to
     clean this up, as there we've got all the appropriate bits exposed.  */
     clean this up, as there we've got all the appropriate bits exposed.  */
  if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
  if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
    return false;
    return false;
 
 
  /* Complex values must have been put into ssa form.  That is, no
  /* Complex values must have been put into ssa form.  That is, no
     assignments to the individual components.  */
     assignments to the individual components.  */
  if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE)
  if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE)
    return DECL_COMPLEX_GIMPLE_REG_P (t);
    return DECL_COMPLEX_GIMPLE_REG_P (t);
 
 
  return true;
  return true;
}
}
 
 
 
 
/* Returns true if T is a GIMPLE formal temporary variable.  */
/* Returns true if T is a GIMPLE formal temporary variable.  */
 
 
bool
bool
is_gimple_formal_tmp_var (tree t)
is_gimple_formal_tmp_var (tree t)
{
{
  if (TREE_CODE (t) == SSA_NAME)
  if (TREE_CODE (t) == SSA_NAME)
    return true;
    return true;
 
 
  return TREE_CODE (t) == VAR_DECL && DECL_GIMPLE_FORMAL_TEMP_P (t);
  return TREE_CODE (t) == VAR_DECL && DECL_GIMPLE_FORMAL_TEMP_P (t);
}
}
 
 
/* Returns true if T is a GIMPLE formal temporary register variable.  */
/* Returns true if T is a GIMPLE formal temporary register variable.  */
 
 
bool
bool
is_gimple_formal_tmp_reg (tree t)
is_gimple_formal_tmp_reg (tree t)
{
{
  /* The intent of this is to get hold of a value that won't change.
  /* The intent of this is to get hold of a value that won't change.
     An SSA_NAME qualifies no matter if its of a user variable or not.  */
     An SSA_NAME qualifies no matter if its of a user variable or not.  */
  if (TREE_CODE (t) == SSA_NAME)
  if (TREE_CODE (t) == SSA_NAME)
    return true;
    return true;
 
 
  /* We don't know the lifetime characteristics of user variables.  */
  /* We don't know the lifetime characteristics of user variables.  */
  if (!is_gimple_formal_tmp_var (t))
  if (!is_gimple_formal_tmp_var (t))
    return false;
    return false;
 
 
  /* Finally, it must be capable of being placed in a register.  */
  /* Finally, it must be capable of being placed in a register.  */
  return is_gimple_reg (t);
  return is_gimple_reg (t);
}
}
 
 
/* Return true if T is a GIMPLE variable whose address is not needed.  */
/* Return true if T is a GIMPLE variable whose address is not needed.  */
 
 
bool
bool
is_gimple_non_addressable (tree t)
is_gimple_non_addressable (tree t)
{
{
  if (TREE_CODE (t) == SSA_NAME)
  if (TREE_CODE (t) == SSA_NAME)
    t = SSA_NAME_VAR (t);
    t = SSA_NAME_VAR (t);
 
 
  return (is_gimple_variable (t) && ! needs_to_live_in_memory (t));
  return (is_gimple_variable (t) && ! needs_to_live_in_memory (t));
}
}
 
 
/* Return true if T is a GIMPLE rvalue, i.e. an identifier or a constant.  */
/* Return true if T is a GIMPLE rvalue, i.e. an identifier or a constant.  */
 
 
bool
bool
is_gimple_val (tree t)
is_gimple_val (tree t)
{
{
  /* Make loads from volatiles and memory vars explicit.  */
  /* Make loads from volatiles and memory vars explicit.  */
  if (is_gimple_variable (t)
  if (is_gimple_variable (t)
      && is_gimple_reg_type (TREE_TYPE (t))
      && is_gimple_reg_type (TREE_TYPE (t))
      && !is_gimple_reg (t))
      && !is_gimple_reg (t))
    return false;
    return false;
 
 
  /* FIXME make these decls.  That can happen only when we expose the
  /* FIXME make these decls.  That can happen only when we expose the
     entire landing-pad construct at the tree level.  */
     entire landing-pad construct at the tree level.  */
  if (TREE_CODE (t) == EXC_PTR_EXPR || TREE_CODE (t) == FILTER_EXPR)
  if (TREE_CODE (t) == EXC_PTR_EXPR || TREE_CODE (t) == FILTER_EXPR)
    return 1;
    return 1;
 
 
  return (is_gimple_variable (t) || is_gimple_min_invariant (t));
  return (is_gimple_variable (t) || is_gimple_min_invariant (t));
}
}
 
 
/* Similarly, but accept hard registers as inputs to asm statements.  */
/* Similarly, but accept hard registers as inputs to asm statements.  */
 
 
bool
bool
is_gimple_asm_val (tree t)
is_gimple_asm_val (tree t)
{
{
  if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
  if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
    return true;
    return true;
 
 
  return is_gimple_val (t);
  return is_gimple_val (t);
}
}
 
 
/* Return true if T is a GIMPLE minimal lvalue.  */
/* Return true if T is a GIMPLE minimal lvalue.  */
 
 
bool
bool
is_gimple_min_lval (tree t)
is_gimple_min_lval (tree t)
{
{
  return (is_gimple_id (t)
  return (is_gimple_id (t)
          || TREE_CODE (t) == INDIRECT_REF);
          || TREE_CODE (t) == INDIRECT_REF);
}
}
 
 
/* Return true if T is a typecast operation.  */
/* Return true if T is a typecast operation.  */
 
 
bool
bool
is_gimple_cast (tree t)
is_gimple_cast (tree t)
{
{
  return (TREE_CODE (t) == NOP_EXPR
  return (TREE_CODE (t) == NOP_EXPR
          || TREE_CODE (t) == CONVERT_EXPR
          || TREE_CODE (t) == CONVERT_EXPR
          || TREE_CODE (t) == FIX_TRUNC_EXPR
          || TREE_CODE (t) == FIX_TRUNC_EXPR
          || TREE_CODE (t) == FIX_CEIL_EXPR
          || TREE_CODE (t) == FIX_CEIL_EXPR
          || TREE_CODE (t) == FIX_FLOOR_EXPR
          || TREE_CODE (t) == FIX_FLOOR_EXPR
          || TREE_CODE (t) == FIX_ROUND_EXPR);
          || TREE_CODE (t) == FIX_ROUND_EXPR);
}
}
 
 
/* Return true if T is a valid op0 of a CALL_EXPR.  */
/* Return true if T is a valid op0 of a CALL_EXPR.  */
 
 
bool
bool
is_gimple_call_addr (tree t)
is_gimple_call_addr (tree t)
{
{
  return (TREE_CODE (t) == OBJ_TYPE_REF
  return (TREE_CODE (t) == OBJ_TYPE_REF
          || is_gimple_val (t));
          || is_gimple_val (t));
}
}
 
 
/* If T makes a function call, return the corresponding CALL_EXPR operand.
/* If T makes a function call, return the corresponding CALL_EXPR operand.
   Otherwise, return NULL_TREE.  */
   Otherwise, return NULL_TREE.  */
 
 
tree
tree
get_call_expr_in (tree t)
get_call_expr_in (tree t)
{
{
  if (TREE_CODE (t) == MODIFY_EXPR)
  if (TREE_CODE (t) == MODIFY_EXPR)
    t = TREE_OPERAND (t, 1);
    t = TREE_OPERAND (t, 1);
  if (TREE_CODE (t) == WITH_SIZE_EXPR)
  if (TREE_CODE (t) == WITH_SIZE_EXPR)
    t = TREE_OPERAND (t, 0);
    t = TREE_OPERAND (t, 0);
  if (TREE_CODE (t) == CALL_EXPR)
  if (TREE_CODE (t) == CALL_EXPR)
    return t;
    return t;
  return NULL_TREE;
  return NULL_TREE;
}
}
 
 
/* Given a memory reference expression T, return its base address.
/* Given a memory reference expression T, return its base address.
   The base address of a memory reference expression is the main
   The base address of a memory reference expression is the main
   object being referenced.  For instance, the base address for
   object being referenced.  For instance, the base address for
   'array[i].fld[j]' is 'array'.  You can think of this as stripping
   'array[i].fld[j]' is 'array'.  You can think of this as stripping
   away the offset part from a memory address.
   away the offset part from a memory address.
 
 
   This function calls handled_component_p to strip away all the inner
   This function calls handled_component_p to strip away all the inner
   parts of the memory reference until it reaches the base object.  */
   parts of the memory reference until it reaches the base object.  */
 
 
tree
tree
get_base_address (tree t)
get_base_address (tree t)
{
{
  while (handled_component_p (t))
  while (handled_component_p (t))
    t = TREE_OPERAND (t, 0);
    t = TREE_OPERAND (t, 0);
 
 
  if (SSA_VAR_P (t)
  if (SSA_VAR_P (t)
      || TREE_CODE (t) == STRING_CST
      || TREE_CODE (t) == STRING_CST
      || TREE_CODE (t) == CONSTRUCTOR
      || TREE_CODE (t) == CONSTRUCTOR
      || INDIRECT_REF_P (t))
      || INDIRECT_REF_P (t))
    return t;
    return t;
  else
  else
    return NULL_TREE;
    return NULL_TREE;
}
}
 
 
void
void
recalculate_side_effects (tree t)
recalculate_side_effects (tree t)
{
{
  enum tree_code code = TREE_CODE (t);
  enum tree_code code = TREE_CODE (t);
  int len = TREE_CODE_LENGTH (code);
  int len = TREE_CODE_LENGTH (code);
  int i;
  int i;
 
 
  switch (TREE_CODE_CLASS (code))
  switch (TREE_CODE_CLASS (code))
    {
    {
    case tcc_expression:
    case tcc_expression:
      switch (code)
      switch (code)
        {
        {
        case INIT_EXPR:
        case INIT_EXPR:
        case MODIFY_EXPR:
        case MODIFY_EXPR:
        case VA_ARG_EXPR:
        case VA_ARG_EXPR:
        case PREDECREMENT_EXPR:
        case PREDECREMENT_EXPR:
        case PREINCREMENT_EXPR:
        case PREINCREMENT_EXPR:
        case POSTDECREMENT_EXPR:
        case POSTDECREMENT_EXPR:
        case POSTINCREMENT_EXPR:
        case POSTINCREMENT_EXPR:
          /* All of these have side-effects, no matter what their
          /* All of these have side-effects, no matter what their
             operands are.  */
             operands are.  */
          return;
          return;
 
 
        default:
        default:
          break;
          break;
        }
        }
      /* Fall through.  */
      /* Fall through.  */
 
 
    case tcc_comparison:  /* a comparison expression */
    case tcc_comparison:  /* a comparison expression */
    case tcc_unary:       /* a unary arithmetic expression */
    case tcc_unary:       /* a unary arithmetic expression */
    case tcc_binary:      /* a binary arithmetic expression */
    case tcc_binary:      /* a binary arithmetic expression */
    case tcc_reference:   /* a reference */
    case tcc_reference:   /* a reference */
      TREE_SIDE_EFFECTS (t) = TREE_THIS_VOLATILE (t);
      TREE_SIDE_EFFECTS (t) = TREE_THIS_VOLATILE (t);
      for (i = 0; i < len; ++i)
      for (i = 0; i < len; ++i)
        {
        {
          tree op = TREE_OPERAND (t, i);
          tree op = TREE_OPERAND (t, i);
          if (op && TREE_SIDE_EFFECTS (op))
          if (op && TREE_SIDE_EFFECTS (op))
            TREE_SIDE_EFFECTS (t) = 1;
            TREE_SIDE_EFFECTS (t) = 1;
        }
        }
      break;
      break;
 
 
    default:
    default:
      /* Can never be used with non-expressions.  */
      /* Can never be used with non-expressions.  */
      gcc_unreachable ();
      gcc_unreachable ();
   }
   }
}
}
 
 

powered by: WebSVN 2.1.0

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