Daily bump.
[official-gcc.git] / gcc / cp / expr.c
blob34f779ebb97fcd3e9137b065ba5dac1dfdcba9cf
1 /* Convert language-specific tree expression to rtl instructions,
2 for GNU compiler.
3 Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4 2000, 2001 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)
11 any later version.
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. */
24 #include "config.h"
25 #include "system.h"
26 #include "rtl.h"
27 #include "tree.h"
28 #include "flags.h"
29 #include "expr.h"
30 #include "cp-tree.h"
31 #include "toplev.h"
32 #include "except.h"
33 #include "tm_p.h"
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
39 constants. */
41 tree
42 cplus_expand_constant (cst)
43 tree cst;
45 switch (TREE_CODE (cst))
47 case PTRMEM_CST:
49 tree type = TREE_TYPE (cst);
50 tree member;
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);
59 cst = fold (build1 (NOP_EXPR, type, offset));
61 else
63 tree delta;
64 tree pfn;
66 expand_ptrmemfunc_cst (cst, &delta, &pfn);
67 cst = build_ptrmemfunc1 (type, delta, pfn);
70 break;
72 default:
73 /* There's nothing to do. */
74 break;
77 return cst;
80 /* Hook used by expand_expr to expand language-specific tree codes. */
82 static rtx
83 cplus_expand_expr (exp, target, tmode, modifier)
84 tree exp;
85 rtx target;
86 enum machine_mode tmode;
87 enum expand_modifier modifier;
89 tree type = TREE_TYPE (exp);
90 register enum machine_mode mode = TYPE_MODE (type);
91 register enum tree_code code = TREE_CODE (exp);
92 rtx ret;
94 /* No sense saving up arithmetic to be done
95 if it's all in the wrong mode to form part of an address.
96 And force_operand won't know whether to sign-extend or zero-extend. */
98 if (mode != Pmode && modifier == EXPAND_SUM)
99 modifier = EXPAND_NORMAL;
101 switch (code)
103 case PTRMEM_CST:
104 return expand_expr (cplus_expand_constant (exp),
105 target, tmode, modifier);
107 case OFFSET_REF:
108 /* Offset refs should not make it through to here. */
109 abort ();
110 return const0_rtx;
112 case THROW_EXPR:
113 expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
114 return NULL;
116 case MUST_NOT_THROW_EXPR:
117 expand_eh_region_start ();
118 ret = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
119 expand_eh_region_end_must_not_throw (build_call (terminate_node, 0));
120 return ret;
122 case EMPTY_CLASS_EXPR:
123 /* We don't need to generate any code for an empty class. */
124 return const0_rtx;
126 default:
127 return c_expand_expr (exp, target, tmode, modifier);
129 abort ();
130 /* NOTREACHED */
131 return NULL;
134 void
135 init_cplus_expand ()
137 lang_expand_expr = cplus_expand_expr;
141 extract_init (decl, init)
142 tree decl ATTRIBUTE_UNUSED, init ATTRIBUTE_UNUSED;
144 return 0;