8sa1-gcc/gcc/cp/expr.c
Richard Kenner ac79cd5ab9 Makefile.in (c-lang.o): Depends on langhooks-def.h.
* Makefile.in (c-lang.o): Depends on langhooks-def.h.
	(expr.o, varasm.o): Depends on langhooks.h.
	* c-common.c (c_safe_from_p): Always declare.
	(c_expand_expr): Refine when declared.
	* c-lang.c (c-common.h): Now include.
	(LANG_HOOKS_SAFE_FROM_P): Define new hook.
	(c_init): Don't set lang_safe_from_expr.
	* expr.c (langhooks.h): Now include.
	(lang_safe_from_p): No longer define.
	(safe_from_p): Use lang hook.
	(expand_expr): Set IGNORE if VOID_TYPE result of VIEW_CONVERT_EXPR too.
	(expand_expr, case VIEW_CONVERT_EXPR): Pass ro_modifier down.
	* expr.h (lang_expand_constant, lang_safe_from_p): Delete.
	* langhooks-def.h (lhd_return_tree, lhd_safe_from_p): New decls.
	(LANG_HOOKS_EXPAND_CONSTANT, LANG_HOOKS_SAFE_FROM_P): New hooks.
	* langhooks.c (lhd_return_tree, lhd_safe_from_p): New functions.
	* langhooks.h (struct lang_hooks): New fields expand_constant
	and safe_from_p.
	* output.h (output_constant): Size arg is HOST_WIDE_INT.
	* stmt.c (expand_decl_init): No longer need to expand constant
	for CONST_DECL.
	* stor-layout.c (put_pending_size): Don't check for SAVE_EXPR.
	* toplev.c (lang_expand_constant): Delete var.
	* tree.c (save_expr): Don't put another SAVE_EXPR around simple
	operations on SAVE_EXPR.
	* varasm.c (langhooks.h): Now include.
	(compare_constant_1): Use lang_hooks, not lang_expand_constant.
	(record_constant_1, output_addressed_constants): Likewise.
	(initializer_constant_valid_p, output_constant): Likewise.
	(output_constant_def): Process no-defer of string constant.
	(output_addressed_constants, case ADDR_EXPR): Use handled_component_p.
	(output_constant): Strip more conversions.
	Track our size and pad for the rest.
	(array_size_for_constructor): Remove code for non-byte STRING_CST.
	(output_constructor): SIZE now HOST_WIDE_INT.
	* cp/Make-lang.in (cp-lang.o): Depends on c-common.h.
	* cp/cp-lang.c (c-common.h): Include.
	(LANG_HOOKS_EXPAND_CONSTANT, LANG_HOOKS_SAFE_FROM_P): New hooks.
	* cp/decl.c (cxx_init_decl_processing): Don't set lang_safe_from_p.
	* cp/expr.c (init_cplus_expand): Don't set lang_expand_constant.

From-SVN: r47376
2001-11-27 09:31:29 -05:00

147 lines
3.5 KiB
C

/* Convert language-specific tree expression to rtl instructions,
for GNU compiler.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
GNU CC 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 2, or (at your option)
any later version.
GNU CC 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 GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "config.h"
#include "system.h"
#include "rtl.h"
#include "tree.h"
#include "flags.h"
#include "expr.h"
#include "cp-tree.h"
#include "toplev.h"
#include "except.h"
#include "tm_p.h"
static rtx cplus_expand_expr PARAMS ((tree, rtx, enum machine_mode,
enum expand_modifier));
/* Hook used by output_constant to expand language-specific
constants. */
tree
cplus_expand_constant (cst)
tree cst;
{
switch (TREE_CODE (cst))
{
case PTRMEM_CST:
{
tree type = TREE_TYPE (cst);
tree member;
/* Find the member. */
member = PTRMEM_CST_MEMBER (cst);
if (TREE_CODE (member) == FIELD_DECL)
{
/* Find the offset for the field. */
tree offset = byte_position (member);
cst = fold (build1 (NOP_EXPR, type, offset));
}
else
{
tree delta;
tree pfn;
expand_ptrmemfunc_cst (cst, &delta, &pfn);
cst = build_ptrmemfunc1 (type, delta, pfn);
}
}
break;
default:
/* There's nothing to do. */
break;
}
return cst;
}
/* Hook used by expand_expr to expand language-specific tree codes. */
static rtx
cplus_expand_expr (exp, target, tmode, modifier)
tree exp;
rtx target;
enum machine_mode tmode;
enum expand_modifier modifier;
{
tree type = TREE_TYPE (exp);
register enum machine_mode mode = TYPE_MODE (type);
register enum tree_code code = TREE_CODE (exp);
rtx ret;
/* No sense saving up arithmetic to be done
if it's all in the wrong mode to form part of an address.
And force_operand won't know whether to sign-extend or zero-extend. */
if (mode != Pmode && modifier == EXPAND_SUM)
modifier = EXPAND_NORMAL;
switch (code)
{
case PTRMEM_CST:
return expand_expr (cplus_expand_constant (exp),
target, tmode, modifier);
case OFFSET_REF:
/* Offset refs should not make it through to here. */
my_friendly_abort (20010724);
return const0_rtx;
case THROW_EXPR:
expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
return NULL;
case MUST_NOT_THROW_EXPR:
expand_eh_region_start ();
ret = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
expand_eh_region_end_must_not_throw (build_call (terminate_node, 0));
return ret;
case EMPTY_CLASS_EXPR:
/* We don't need to generate any code for an empty class. */
return const0_rtx;
default:
return c_expand_expr (exp, target, tmode, modifier);
}
my_friendly_abort (40);
/* NOTREACHED */
return NULL;
}
void
init_cplus_expand ()
{
lang_expand_expr = cplus_expand_expr;
}
int
extract_init (decl, init)
tree decl ATTRIBUTE_UNUSED, init ATTRIBUTE_UNUSED;
{
return 0;
}