1996-09-18 05:35:50 +00:00
|
|
|
/* Convert language-specific tree expression to rtl instructions,
|
|
|
|
for GNU compiler.
|
2002-02-01 18:16:02 +00:00
|
|
|
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
2004-07-28 03:11:36 +00:00
|
|
|
2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
1996-09-18 05:35:50 +00:00
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
This file is part of GCC.
|
1996-09-18 05:35:50 +00:00
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
GCC is free software; you can redistribute it and/or modify
|
1996-09-18 05:35:50 +00:00
|
|
|
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.
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
GCC is distributed in the hope that it will be useful,
|
1996-09-18 05:35:50 +00:00
|
|
|
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
|
2004-07-28 03:11:36 +00:00
|
|
|
along with GCC; see the file COPYING. If not, write to
|
2007-05-19 01:19:51 +00:00
|
|
|
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA. */
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
1999-08-26 09:30:50 +00:00
|
|
|
#include "system.h"
|
2004-07-28 03:11:36 +00:00
|
|
|
#include "coretypes.h"
|
|
|
|
#include "tm.h"
|
1996-09-18 05:35:50 +00:00
|
|
|
#include "rtl.h"
|
|
|
|
#include "tree.h"
|
|
|
|
#include "flags.h"
|
|
|
|
#include "expr.h"
|
|
|
|
#include "cp-tree.h"
|
1999-08-26 09:30:50 +00:00
|
|
|
#include "toplev.h"
|
2002-02-01 18:16:02 +00:00
|
|
|
#include "except.h"
|
|
|
|
#include "tm_p.h"
|
1996-09-18 05:35:50 +00:00
|
|
|
|
1999-10-16 06:09:09 +00:00
|
|
|
/* Hook used by output_constant to expand language-specific
|
|
|
|
constants. */
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
tree
|
2004-07-28 03:11:36 +00:00
|
|
|
cplus_expand_constant (tree cst)
|
1999-10-16 06:09:09 +00:00
|
|
|
{
|
|
|
|
switch (TREE_CODE (cst))
|
|
|
|
{
|
|
|
|
case PTRMEM_CST:
|
|
|
|
{
|
|
|
|
tree type = TREE_TYPE (cst);
|
|
|
|
tree member;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
1999-10-16 06:09:09 +00:00
|
|
|
/* Find the member. */
|
|
|
|
member = PTRMEM_CST_MEMBER (cst);
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
if (TREE_CODE (member) == FIELD_DECL)
|
1999-10-16 06:09:09 +00:00
|
|
|
{
|
|
|
|
/* Find the offset for the field. */
|
2004-07-28 03:11:36 +00:00
|
|
|
cst = byte_position (member);
|
|
|
|
while (!same_type_p (DECL_CONTEXT (member),
|
|
|
|
TYPE_PTRMEM_CLASS_TYPE (type)))
|
|
|
|
{
|
|
|
|
/* The MEMBER must have been nestled within an
|
|
|
|
anonymous aggregate contained in TYPE. Find the
|
|
|
|
anonymous aggregate. */
|
|
|
|
member = lookup_anon_field (TYPE_PTRMEM_CLASS_TYPE (type),
|
|
|
|
DECL_CONTEXT (member));
|
|
|
|
cst = size_binop (PLUS_EXPR, cst, byte_position (member));
|
|
|
|
}
|
|
|
|
cst = fold (build_nop (type, cst));
|
1999-10-16 06:09:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tree delta;
|
|
|
|
tree pfn;
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
expand_ptrmemfunc_cst (cst, &delta, &pfn);
|
|
|
|
cst = build_ptrmemfunc1 (type, delta, pfn);
|
1999-10-16 06:09:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* There's nothing to do. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cst;
|
|
|
|
}
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
/* Hook used by expand_expr to expand language-specific tree codes. */
|
2007-05-19 01:19:51 +00:00
|
|
|
/* ??? The only thing that should be here are things needed to expand
|
|
|
|
constant initializers; everything else should be handled by the
|
|
|
|
gimplification routines. Are EMPTY_CLASS_EXPR or BASELINK needed? */
|
1996-09-18 05:35:50 +00:00
|
|
|
|
2003-07-11 03:40:53 +00:00
|
|
|
rtx
|
2004-07-28 03:11:36 +00:00
|
|
|
cxx_expand_expr (tree exp, rtx target, enum machine_mode tmode, int modifier,
|
|
|
|
rtx *alt_rtl)
|
1996-09-18 05:35:50 +00:00
|
|
|
{
|
|
|
|
tree type = TREE_TYPE (exp);
|
2004-07-28 03:11:36 +00:00
|
|
|
enum machine_mode mode = TYPE_MODE (type);
|
|
|
|
enum tree_code code = TREE_CODE (exp);
|
1996-09-18 05:35:50 +00:00
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
1999-10-16 06:09:09 +00:00
|
|
|
case PTRMEM_CST:
|
|
|
|
return expand_expr (cplus_expand_constant (exp),
|
|
|
|
target, tmode, modifier);
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
case OFFSET_REF:
|
2003-07-11 03:40:53 +00:00
|
|
|
/* Offset refs should not make it through to here. */
|
2007-05-19 01:19:51 +00:00
|
|
|
gcc_unreachable ();
|
1999-08-26 09:30:50 +00:00
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
case EMPTY_CLASS_EXPR:
|
|
|
|
/* We don't need to generate any code for an empty class. */
|
|
|
|
return const0_rtx;
|
1996-09-18 05:35:50 +00:00
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
case BASELINK:
|
|
|
|
return expand_expr (BASELINK_FUNCTIONS (exp), target, tmode,
|
|
|
|
modifier);
|
|
|
|
|
1996-09-18 05:35:50 +00:00
|
|
|
default:
|
2004-07-28 03:11:36 +00:00
|
|
|
return c_expand_expr (exp, target, tmode, modifier, alt_rtl);
|
1996-09-18 05:35:50 +00:00
|
|
|
}
|
|
|
|
}
|