1 /* Convert language-specific tree expression to rtl instructions,
3 Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4 2000 Free Software Foundation, Inc.
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
35 static rtx cplus_expand_expr PARAMS ((tree, rtx, enum machine_mode,
36 enum expand_modifier));
38 /* Hook used by output_constant to expand language-specific
42 cplus_expand_constant (cst)
45 switch (TREE_CODE (cst))
49 tree type = TREE_TYPE (cst);
52 /* Find the member. */
53 member = PTRMEM_CST_MEMBER (cst);
55 if (TREE_CODE (member) == FIELD_DECL)
57 /* Find the offset for the field. */
58 tree offset = byte_position (member);
61 /* Under the new ABI, we use -1 to represent the NULL
62 pointer; non-NULL values simply contain the offset of
66 /* We offset all pointer to data members by 1 so that we
67 can distinguish between a null pointer to data member
68 and the first data member of a structure. */
69 offset = size_binop (PLUS_EXPR, offset, size_one_node);
71 cst = fold (build1 (NOP_EXPR, type, offset));
75 tree delta, idx, pfn, delta2;
77 expand_ptrmemfunc_cst (cst, &delta, &idx, &pfn, &delta2);
78 cst = build_ptrmemfunc1 (type, delta, idx, pfn, delta2);
84 /* There's nothing to do. */
91 /* Hook used by expand_expr to expand language-specific tree codes. */
94 cplus_expand_expr (exp, target, tmode, modifier)
97 enum machine_mode tmode;
98 enum expand_modifier modifier;
100 tree type = TREE_TYPE (exp);
101 register enum machine_mode mode = TYPE_MODE (type);
102 register enum tree_code code = TREE_CODE (exp);
103 int ignore = target == const0_rtx;
108 /* No sense saving up arithmetic to be done
109 if it's all in the wrong mode to form part of an address.
110 And force_operand won't know whether to sign-extend or zero-extend. */
112 if (mode != Pmode && modifier == EXPAND_SUM)
113 modifier = EXPAND_NORMAL;
118 return expand_expr (cplus_expand_constant (exp),
119 target, tmode, modifier);
123 return expand_expr (default_conversion (resolve_offset_ref (exp)),
124 target, tmode, EXPAND_NORMAL);
128 expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
129 expand_internal_throw ();
132 case EMPTY_CLASS_EXPR:
133 /* We don't need to generate any code for an empty class. */
137 return c_expand_expr (exp, target, tmode, modifier);
139 my_friendly_abort (40);
147 lang_expand_expr = cplus_expand_expr;
148 lang_expand_constant = cplus_expand_constant;
152 extract_init (decl, init)
153 tree decl ATTRIBUTE_UNUSED, init ATTRIBUTE_UNUSED;