]>
Commit | Line | Data |
---|---|---|
8d08fdba MS |
1 | /* Convert language-specific tree expression to rtl instructions, |
2 | for GNU compiler. | |
d6a8bdff | 3 | Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, |
45b8ddb4 | 4 | 2000, 2001 Free Software Foundation, Inc. |
8d08fdba MS |
5 | |
6 | This file is part of GNU CC. | |
7 | ||
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. | |
12 | ||
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. | |
17 | ||
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 | |
e9fa0c7c RK |
20 | the Free Software Foundation, 59 Temple Place - Suite 330, |
21 | Boston, MA 02111-1307, USA. */ | |
8d08fdba MS |
22 | |
23 | ||
24 | #include "config.h" | |
8d052bc7 | 25 | #include "system.h" |
8d08fdba MS |
26 | #include "rtl.h" |
27 | #include "tree.h" | |
28 | #include "flags.h" | |
29 | #include "expr.h" | |
30 | #include "cp-tree.h" | |
54f92bfb | 31 | #include "toplev.h" |
59ccf49d | 32 | #include "except.h" |
b1474bb7 | 33 | #include "tm_p.h" |
8d08fdba | 34 | |
158991b7 | 35 | static rtx cplus_expand_expr PARAMS ((tree, rtx, enum machine_mode, |
9f617717 | 36 | enum expand_modifier)); |
49c249e1 | 37 | |
87533b37 MM |
38 | /* Hook used by output_constant to expand language-specific |
39 | constants. */ | |
40 | ||
b928a651 | 41 | tree |
87533b37 MM |
42 | cplus_expand_constant (cst) |
43 | tree cst; | |
44 | { | |
45 | switch (TREE_CODE (cst)) | |
46 | { | |
47 | case PTRMEM_CST: | |
48 | { | |
49 | tree type = TREE_TYPE (cst); | |
50 | tree member; | |
87533b37 MM |
51 | |
52 | /* Find the member. */ | |
53 | member = PTRMEM_CST_MEMBER (cst); | |
54 | ||
55 | if (TREE_CODE (member) == FIELD_DECL) | |
56 | { | |
57 | /* Find the offset for the field. */ | |
770ae6cc | 58 | tree offset = byte_position (member); |
cd8ed629 | 59 | cst = fold (build1 (NOP_EXPR, type, offset)); |
87533b37 MM |
60 | } |
61 | else | |
62 | { | |
770ae6cc | 63 | tree delta, idx, pfn, delta2; |
87533b37 MM |
64 | |
65 | expand_ptrmemfunc_cst (cst, &delta, &idx, &pfn, &delta2); | |
1f84ec23 | 66 | cst = build_ptrmemfunc1 (type, delta, pfn); |
87533b37 MM |
67 | } |
68 | } | |
69 | break; | |
70 | ||
71 | default: | |
72 | /* There's nothing to do. */ | |
73 | break; | |
74 | } | |
75 | ||
76 | return cst; | |
77 | } | |
78 | ||
8d08fdba MS |
79 | /* Hook used by expand_expr to expand language-specific tree codes. */ |
80 | ||
9f617717 | 81 | static rtx |
8d08fdba MS |
82 | cplus_expand_expr (exp, target, tmode, modifier) |
83 | tree exp; | |
84 | rtx target; | |
85 | enum machine_mode tmode; | |
86 | enum expand_modifier modifier; | |
87 | { | |
88 | tree type = TREE_TYPE (exp); | |
89 | register enum machine_mode mode = TYPE_MODE (type); | |
90 | register enum tree_code code = TREE_CODE (exp); | |
52a11cbf | 91 | rtx ret; |
8d08fdba MS |
92 | |
93 | /* No sense saving up arithmetic to be done | |
94 | if it's all in the wrong mode to form part of an address. | |
95 | And force_operand won't know whether to sign-extend or zero-extend. */ | |
96 | ||
97 | if (mode != Pmode && modifier == EXPAND_SUM) | |
98 | modifier = EXPAND_NORMAL; | |
99 | ||
100 | switch (code) | |
101 | { | |
61a127b3 | 102 | case PTRMEM_CST: |
87533b37 MM |
103 | return expand_expr (cplus_expand_constant (exp), |
104 | target, tmode, modifier); | |
61a127b3 | 105 | |
8d08fdba | 106 | case OFFSET_REF: |
52a11cbf RH |
107 | return expand_expr (default_conversion (resolve_offset_ref (exp)), |
108 | target, tmode, EXPAND_NORMAL); | |
8d08fdba | 109 | |
8d2733ca | 110 | case THROW_EXPR: |
59ccf49d | 111 | expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0); |
8d2733ca MS |
112 | return NULL; |
113 | ||
52a11cbf RH |
114 | case MUST_NOT_THROW_EXPR: |
115 | expand_eh_region_start (); | |
116 | ret = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier); | |
117 | expand_eh_region_end_must_not_throw (build_call (terminate_node, 0)); | |
118 | return ret; | |
119 | ||
5f7cbe4e MM |
120 | case EMPTY_CLASS_EXPR: |
121 | /* We don't need to generate any code for an empty class. */ | |
122 | return const0_rtx; | |
123 | ||
8d08fdba | 124 | default: |
8f17b5c5 | 125 | return c_expand_expr (exp, target, tmode, modifier); |
8d08fdba MS |
126 | } |
127 | my_friendly_abort (40); | |
128 | /* NOTREACHED */ | |
129 | return NULL; | |
130 | } | |
131 | ||
132 | void | |
133 | init_cplus_expand () | |
134 | { | |
135 | lang_expand_expr = cplus_expand_expr; | |
87533b37 | 136 | lang_expand_constant = cplus_expand_constant; |
8d08fdba MS |
137 | } |
138 | ||
28cbf42c MS |
139 | int |
140 | extract_init (decl, init) | |
b370501f | 141 | tree decl ATTRIBUTE_UNUSED, init ATTRIBUTE_UNUSED; |
28cbf42c MS |
142 | { |
143 | return 0; | |
28cbf42c | 144 | } |
5566b478 | 145 |