Mercurial > hg > CbC > CbC_gcc
annotate gcc/config/mmix/mmix.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | b7f97abdc517 |
children | 04ced10e8804 |
rev | line source |
---|---|
0 | 1 /* Definitions of target machine for GNU compiler, for MMIX. |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3 2010 |
0 | 4 Free Software Foundation, Inc. |
5 Contributed by Hans-Peter Nilsson (hp@bitrange.com) | |
6 | |
7 This file is part of GCC. | |
8 | |
9 GCC is free software; you can redistribute it and/or modify | |
10 it under the terms of the GNU General Public License as published by | |
11 the Free Software Foundation; either version 3, or (at your option) | |
12 any later version. | |
13 | |
14 GCC is distributed in the hope that it will be useful, | |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 GNU General Public License for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
20 along with GCC; see the file COPYING3. If not see | |
21 <http://www.gnu.org/licenses/>. */ | |
22 | |
23 #include "config.h" | |
24 #include "system.h" | |
25 #include "coretypes.h" | |
26 #include "tm.h" | |
27 #include "rtl.h" | |
28 #include "regs.h" | |
29 #include "hard-reg-set.h" | |
30 #include "hashtab.h" | |
31 #include "insn-config.h" | |
32 #include "output.h" | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
33 #include "basic-block.h" |
0 | 34 #include "flags.h" |
35 #include "tree.h" | |
36 #include "function.h" | |
37 #include "expr.h" | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
38 #include "diagnostic-core.h" |
0 | 39 #include "recog.h" |
40 #include "ggc.h" | |
41 #include "dwarf2.h" | |
42 #include "debug.h" | |
43 #include "tm_p.h" | |
44 #include "integrate.h" | |
45 #include "target.h" | |
46 #include "target-def.h" | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
47 #include "df.h" |
0 | 48 |
49 /* First some local helper definitions. */ | |
50 #define MMIX_FIRST_GLOBAL_REGNUM 32 | |
51 | |
52 /* We'd need a current_function_has_landing_pad. It's marked as such when | |
53 a nonlocal_goto_receiver is expanded. Not just a C++ thing, but | |
54 mostly. */ | |
55 #define MMIX_CFUN_HAS_LANDING_PAD (cfun->machine->has_landing_pad != 0) | |
56 | |
57 /* We have no means to tell DWARF 2 about the register stack, so we need | |
58 to store the return address on the stack if an exception can get into | |
59 this function. FIXME: Narrow condition. Before any whole-function | |
60 analysis, df_regs_ever_live_p () isn't initialized. We know it's up-to-date | |
61 after reload_completed; it may contain incorrect information some time | |
62 before that. Within a RTL sequence (after a call to start_sequence, | |
63 such as in RTL expanders), leaf_function_p doesn't see all insns | |
64 (perhaps any insn). But regs_ever_live is up-to-date when | |
65 leaf_function_p () isn't, so we "or" them together to get accurate | |
66 information. FIXME: Some tweak to leaf_function_p might be | |
67 preferable. */ | |
68 #define MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS \ | |
69 (flag_exceptions \ | |
70 && ((reload_completed && df_regs_ever_live_p (MMIX_rJ_REGNUM)) \ | |
71 || !leaf_function_p ())) | |
72 | |
73 #define IS_MMIX_EH_RETURN_DATA_REG(REGNO) \ | |
74 (crtl->calls_eh_return \ | |
75 && (EH_RETURN_DATA_REGNO (0) == REGNO \ | |
76 || EH_RETURN_DATA_REGNO (1) == REGNO \ | |
77 || EH_RETURN_DATA_REGNO (2) == REGNO \ | |
78 || EH_RETURN_DATA_REGNO (3) == REGNO)) | |
79 | |
80 /* For the default ABI, we rename registers at output-time to fill the gap | |
81 between the (statically partitioned) saved registers and call-clobbered | |
82 registers. In effect this makes unused call-saved registers to be used | |
83 as call-clobbered registers. The benefit comes from keeping the number | |
84 of local registers (value of rL) low, since there's a cost of | |
85 increasing rL and clearing unused (unset) registers with lower numbers. | |
86 Don't translate while outputting the prologue. */ | |
87 #define MMIX_OUTPUT_REGNO(N) \ | |
88 (TARGET_ABI_GNU \ | |
89 || (int) (N) < MMIX_RETURN_VALUE_REGNUM \ | |
90 || (int) (N) > MMIX_LAST_STACK_REGISTER_REGNUM \ | |
91 || cfun == NULL \ | |
92 || cfun->machine == NULL \ | |
93 || cfun->machine->in_prologue \ | |
94 ? (N) : ((N) - MMIX_RETURN_VALUE_REGNUM \ | |
95 + cfun->machine->highest_saved_stack_register + 1)) | |
96 | |
97 /* The %d in "POP %d,0". */ | |
98 #define MMIX_POP_ARGUMENT() \ | |
99 ((! TARGET_ABI_GNU \ | |
100 && crtl->return_rtx != NULL \ | |
101 && ! cfun->returns_struct) \ | |
102 ? (GET_CODE (crtl->return_rtx) == PARALLEL \ | |
103 ? GET_NUM_ELEM (XVEC (crtl->return_rtx, 0)) : 1) \ | |
104 : 0) | |
105 | |
106 /* The canonical saved comparison operands for non-cc0 machines, set in | |
107 the compare expander. */ | |
108 rtx mmix_compare_op0; | |
109 rtx mmix_compare_op1; | |
110 | |
111 /* Declarations of locals. */ | |
112 | |
113 /* Intermediate for insn output. */ | |
114 static int mmix_output_destination_register; | |
115 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
116 static void mmix_option_override (void); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
117 static void mmix_asm_output_source_filename (FILE *, const char *); |
0 | 118 static void mmix_output_shiftvalue_op_from_str |
119 (FILE *, const char *, HOST_WIDEST_INT); | |
120 static void mmix_output_shifted_value (FILE *, HOST_WIDEST_INT); | |
121 static void mmix_output_condition (FILE *, rtx, int); | |
122 static HOST_WIDEST_INT mmix_intval (rtx); | |
123 static void mmix_output_octa (FILE *, HOST_WIDEST_INT, int); | |
124 static bool mmix_assemble_integer (rtx, unsigned int, int); | |
125 static struct machine_function *mmix_init_machine_status (void); | |
126 static void mmix_encode_section_info (tree, rtx, int); | |
127 static const char *mmix_strip_name_encoding (const char *); | |
128 static void mmix_emit_sp_add (HOST_WIDE_INT offset); | |
129 static void mmix_target_asm_function_prologue (FILE *, HOST_WIDE_INT); | |
130 static void mmix_target_asm_function_end_prologue (FILE *); | |
131 static void mmix_target_asm_function_epilogue (FILE *, HOST_WIDE_INT); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
132 static bool mmix_legitimate_address_p (enum machine_mode, rtx, bool); |
0 | 133 static void mmix_reorg (void); |
134 static void mmix_asm_output_mi_thunk | |
135 (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree); | |
136 static void mmix_setup_incoming_varargs | |
137 (CUMULATIVE_ARGS *, enum machine_mode, tree, int *, int); | |
138 static void mmix_file_start (void); | |
139 static void mmix_file_end (void); | |
140 static bool mmix_rtx_costs (rtx, int, int, int *, bool); | |
141 static rtx mmix_struct_value_rtx (tree, int); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
142 static enum machine_mode mmix_promote_function_mode (const_tree, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
143 enum machine_mode, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
144 int *, const_tree, int); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
145 static void mmix_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
146 const_tree, bool); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
147 static rtx mmix_function_arg_1 (const CUMULATIVE_ARGS *, enum machine_mode, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
148 const_tree, bool, bool); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
149 static rtx mmix_function_incoming_arg (CUMULATIVE_ARGS *, enum machine_mode, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
150 const_tree, bool); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
151 static rtx mmix_function_arg (CUMULATIVE_ARGS *, enum machine_mode, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
152 const_tree, bool); |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
153 static rtx mmix_function_value (const_tree, const_tree, bool); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
154 static rtx mmix_libcall_value (enum machine_mode, const_rtx); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
155 static bool mmix_function_value_regno_p (const unsigned int); |
0 | 156 static bool mmix_pass_by_reference (CUMULATIVE_ARGS *, |
157 enum machine_mode, const_tree, bool); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
158 static bool mmix_frame_pointer_required (void); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
159 static void mmix_asm_trampoline_template (FILE *); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
160 static void mmix_trampoline_init (rtx, tree, rtx); |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
161 static void mmix_conditional_register_usage (void); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
162 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
163 /* TARGET_OPTION_OPTIMIZATION_TABLE. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
164 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
165 static const struct default_options mmix_option_optimization_table[] = |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
166 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
167 { OPT_LEVELS_1_PLUS, OPT_fregmove, NULL, 1 }, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
168 { OPT_LEVELS_2_PLUS, OPT_fomit_frame_pointer, NULL, 1 }, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
169 { OPT_LEVELS_NONE, 0, NULL, 0 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
170 }; |
0 | 171 |
172 /* Target structure macros. Listed by node. See `Using and Porting GCC' | |
173 for a general description. */ | |
174 | |
175 /* Node: Function Entry */ | |
176 | |
177 #undef TARGET_ASM_BYTE_OP | |
178 #define TARGET_ASM_BYTE_OP NULL | |
179 #undef TARGET_ASM_ALIGNED_HI_OP | |
180 #define TARGET_ASM_ALIGNED_HI_OP NULL | |
181 #undef TARGET_ASM_ALIGNED_SI_OP | |
182 #define TARGET_ASM_ALIGNED_SI_OP NULL | |
183 #undef TARGET_ASM_ALIGNED_DI_OP | |
184 #define TARGET_ASM_ALIGNED_DI_OP NULL | |
185 #undef TARGET_ASM_INTEGER | |
186 #define TARGET_ASM_INTEGER mmix_assemble_integer | |
187 | |
188 #undef TARGET_ASM_FUNCTION_PROLOGUE | |
189 #define TARGET_ASM_FUNCTION_PROLOGUE mmix_target_asm_function_prologue | |
190 | |
191 #undef TARGET_ASM_FUNCTION_END_PROLOGUE | |
192 #define TARGET_ASM_FUNCTION_END_PROLOGUE mmix_target_asm_function_end_prologue | |
193 | |
194 #undef TARGET_ASM_FUNCTION_EPILOGUE | |
195 #define TARGET_ASM_FUNCTION_EPILOGUE mmix_target_asm_function_epilogue | |
196 | |
197 #undef TARGET_ENCODE_SECTION_INFO | |
198 #define TARGET_ENCODE_SECTION_INFO mmix_encode_section_info | |
199 #undef TARGET_STRIP_NAME_ENCODING | |
200 #define TARGET_STRIP_NAME_ENCODING mmix_strip_name_encoding | |
201 | |
202 #undef TARGET_ASM_OUTPUT_MI_THUNK | |
203 #define TARGET_ASM_OUTPUT_MI_THUNK mmix_asm_output_mi_thunk | |
204 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK | |
205 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK default_can_output_mi_thunk_no_vcall | |
206 #undef TARGET_ASM_FILE_START | |
207 #define TARGET_ASM_FILE_START mmix_file_start | |
208 #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE | |
209 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true | |
210 #undef TARGET_ASM_FILE_END | |
211 #define TARGET_ASM_FILE_END mmix_file_end | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
212 #undef TARGET_ASM_OUTPUT_SOURCE_FILENAME |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
213 #define TARGET_ASM_OUTPUT_SOURCE_FILENAME mmix_asm_output_source_filename |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
214 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
215 #undef TARGET_CONDITIONAL_REGISTER_USAGE |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
216 #define TARGET_CONDITIONAL_REGISTER_USAGE mmix_conditional_register_usage |
0 | 217 |
218 #undef TARGET_RTX_COSTS | |
219 #define TARGET_RTX_COSTS mmix_rtx_costs | |
220 #undef TARGET_ADDRESS_COST | |
221 #define TARGET_ADDRESS_COST hook_int_rtx_bool_0 | |
222 | |
223 #undef TARGET_MACHINE_DEPENDENT_REORG | |
224 #define TARGET_MACHINE_DEPENDENT_REORG mmix_reorg | |
225 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
226 #undef TARGET_PROMOTE_FUNCTION_MODE |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
227 #define TARGET_PROMOTE_FUNCTION_MODE mmix_promote_function_mode |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
228 |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
229 #undef TARGET_FUNCTION_VALUE |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
230 #define TARGET_FUNCTION_VALUE mmix_function_value |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
231 #undef TARGET_LIBCALL_VALUE |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
232 #define TARGET_LIBCALL_VALUE mmix_libcall_value |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
233 #undef TARGET_FUNCTION_VALUE_REGNO_P |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
234 #define TARGET_FUNCTION_VALUE_REGNO_P mmix_function_value_regno_p |
0 | 235 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
236 #undef TARGET_FUNCTION_ARG |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
237 #define TARGET_FUNCTION_ARG mmix_function_arg |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
238 #undef TARGET_FUNCTION_INCOMING_ARG |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
239 #define TARGET_FUNCTION_INCOMING_ARG mmix_function_incoming_arg |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
240 #undef TARGET_FUNCTION_ARG_ADVANCE |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
241 #define TARGET_FUNCTION_ARG_ADVANCE mmix_function_arg_advance |
0 | 242 #undef TARGET_STRUCT_VALUE_RTX |
243 #define TARGET_STRUCT_VALUE_RTX mmix_struct_value_rtx | |
244 #undef TARGET_SETUP_INCOMING_VARARGS | |
245 #define TARGET_SETUP_INCOMING_VARARGS mmix_setup_incoming_varargs | |
246 #undef TARGET_PASS_BY_REFERENCE | |
247 #define TARGET_PASS_BY_REFERENCE mmix_pass_by_reference | |
248 #undef TARGET_CALLEE_COPIES | |
249 #define TARGET_CALLEE_COPIES hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true | |
250 #undef TARGET_DEFAULT_TARGET_FLAGS | |
251 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT | |
252 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
253 #undef TARGET_LEGITIMATE_ADDRESS_P |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
254 #define TARGET_LEGITIMATE_ADDRESS_P mmix_legitimate_address_p |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
255 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
256 #undef TARGET_FRAME_POINTER_REQUIRED |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
257 #define TARGET_FRAME_POINTER_REQUIRED mmix_frame_pointer_required |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
258 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
259 #undef TARGET_ASM_TRAMPOLINE_TEMPLATE |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
260 #define TARGET_ASM_TRAMPOLINE_TEMPLATE mmix_asm_trampoline_template |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
261 #undef TARGET_TRAMPOLINE_INIT |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
262 #define TARGET_TRAMPOLINE_INIT mmix_trampoline_init |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
263 |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
264 #undef TARGET_OPTION_OVERRIDE |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
265 #define TARGET_OPTION_OVERRIDE mmix_option_override |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
266 #undef TARGET_OPTION_OPTIMIZATION_TABLE |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
267 #define TARGET_OPTION_OPTIMIZATION_TABLE mmix_option_optimization_table |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
268 |
0 | 269 struct gcc_target targetm = TARGET_INITIALIZER; |
270 | |
271 /* Functions that are expansions for target macros. | |
272 See Target Macros in `Using and Porting GCC'. */ | |
273 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
274 /* TARGET_OPTION_OVERRIDE. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
275 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
276 static void |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
277 mmix_option_override (void) |
0 | 278 { |
279 /* Should we err or should we warn? Hmm. At least we must neutralize | |
280 it. For example the wrong kind of case-tables will be generated with | |
281 PIC; we use absolute address items for mmixal compatibility. FIXME: | |
282 They could be relative if we just elide them to after all pertinent | |
283 labels. */ | |
284 if (flag_pic) | |
285 { | |
286 warning (0, "-f%s not supported: ignored", (flag_pic > 1) ? "PIC" : "pic"); | |
287 flag_pic = 0; | |
288 } | |
289 } | |
290 | |
291 /* INIT_EXPANDERS. */ | |
292 | |
293 void | |
294 mmix_init_expanders (void) | |
295 { | |
296 init_machine_status = mmix_init_machine_status; | |
297 } | |
298 | |
299 /* Set the per-function data. */ | |
300 | |
301 static struct machine_function * | |
302 mmix_init_machine_status (void) | |
303 { | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
304 return ggc_alloc_cleared_machine_function (); |
0 | 305 } |
306 | |
307 /* DATA_ALIGNMENT. | |
308 We have trouble getting the address of stuff that is located at other | |
309 than 32-bit alignments (GETA requirements), so try to give everything | |
310 at least 32-bit alignment. */ | |
311 | |
312 int | |
313 mmix_data_alignment (tree type ATTRIBUTE_UNUSED, int basic_align) | |
314 { | |
315 if (basic_align < 32) | |
316 return 32; | |
317 | |
318 return basic_align; | |
319 } | |
320 | |
321 /* CONSTANT_ALIGNMENT. */ | |
322 | |
323 int | |
324 mmix_constant_alignment (tree constant ATTRIBUTE_UNUSED, int basic_align) | |
325 { | |
326 if (basic_align < 32) | |
327 return 32; | |
328 | |
329 return basic_align; | |
330 } | |
331 | |
332 /* LOCAL_ALIGNMENT. */ | |
333 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
334 unsigned |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
335 mmix_local_alignment (tree type ATTRIBUTE_UNUSED, unsigned basic_align) |
0 | 336 { |
337 if (basic_align < 32) | |
338 return 32; | |
339 | |
340 return basic_align; | |
341 } | |
342 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
343 /* TARGET_CONDITIONAL_REGISTER_USAGE. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
344 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
345 static void |
0 | 346 mmix_conditional_register_usage (void) |
347 { | |
348 int i; | |
349 | |
350 if (TARGET_ABI_GNU) | |
351 { | |
352 static const int gnu_abi_reg_alloc_order[] | |
353 = MMIX_GNU_ABI_REG_ALLOC_ORDER; | |
354 | |
355 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) | |
356 reg_alloc_order[i] = gnu_abi_reg_alloc_order[i]; | |
357 | |
358 /* Change the default from the mmixware ABI. For the GNU ABI, | |
359 $15..$30 are call-saved just as $0..$14. There must be one | |
360 call-clobbered local register for the "hole" that holds the | |
361 number of saved local registers saved by PUSHJ/PUSHGO during the | |
362 function call, receiving the return value at return. So best is | |
363 to use the highest, $31. It's already marked call-clobbered for | |
364 the mmixware ABI. */ | |
365 for (i = 15; i <= 30; i++) | |
366 call_used_regs[i] = 0; | |
367 | |
368 /* "Unfix" the parameter registers. */ | |
369 for (i = MMIX_RESERVED_GNU_ARG_0_REGNUM; | |
370 i < MMIX_RESERVED_GNU_ARG_0_REGNUM + MMIX_MAX_ARGS_IN_REGS; | |
371 i++) | |
372 fixed_regs[i] = 0; | |
373 } | |
374 | |
375 /* Step over the ":" in special register names. */ | |
376 if (! TARGET_TOPLEVEL_SYMBOLS) | |
377 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) | |
378 if (reg_names[i][0] == ':') | |
379 reg_names[i]++; | |
380 } | |
381 | |
382 /* INCOMING_REGNO and OUTGOING_REGNO worker function. | |
383 Those two macros must only be applied to function argument | |
384 registers. FIXME: for their current use in gcc, it'd be better | |
385 with an explicit specific additional FUNCTION_INCOMING_ARG_REGNO_P | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
386 a'la TARGET_FUNCTION_ARG / TARGET_FUNCTION_INCOMING_ARG instead of |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
387 forcing the target to commit to a fixed mapping and for any |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
388 unspecified register use. */ |
0 | 389 |
390 int | |
391 mmix_opposite_regno (int regno, int incoming) | |
392 { | |
393 if (!mmix_function_arg_regno_p (regno, incoming)) | |
394 return regno; | |
395 | |
396 return | |
397 regno - (incoming | |
398 ? MMIX_FIRST_INCOMING_ARG_REGNUM - MMIX_FIRST_ARG_REGNUM | |
399 : MMIX_FIRST_ARG_REGNUM - MMIX_FIRST_INCOMING_ARG_REGNUM); | |
400 } | |
401 | |
402 /* LOCAL_REGNO. | |
403 All registers that are part of the register stack and that will be | |
404 saved are local. */ | |
405 | |
406 int | |
407 mmix_local_regno (int regno) | |
408 { | |
409 return regno <= MMIX_LAST_STACK_REGISTER_REGNUM && !call_used_regs[regno]; | |
410 } | |
411 | |
412 /* PREFERRED_RELOAD_CLASS. | |
413 We need to extend the reload class of REMAINDER_REG and HIMULT_REG. */ | |
414 | |
415 enum reg_class | |
416 mmix_preferred_reload_class (rtx x ATTRIBUTE_UNUSED, enum reg_class rclass) | |
417 { | |
418 /* FIXME: Revisit. */ | |
419 return GET_CODE (x) == MOD && GET_MODE (x) == DImode | |
420 ? REMAINDER_REG : rclass; | |
421 } | |
422 | |
423 /* PREFERRED_OUTPUT_RELOAD_CLASS. | |
424 We need to extend the reload class of REMAINDER_REG and HIMULT_REG. */ | |
425 | |
426 enum reg_class | |
427 mmix_preferred_output_reload_class (rtx x ATTRIBUTE_UNUSED, | |
428 enum reg_class rclass) | |
429 { | |
430 /* FIXME: Revisit. */ | |
431 return GET_CODE (x) == MOD && GET_MODE (x) == DImode | |
432 ? REMAINDER_REG : rclass; | |
433 } | |
434 | |
435 /* SECONDARY_RELOAD_CLASS. | |
436 We need to reload regs of REMAINDER_REG and HIMULT_REG elsewhere. */ | |
437 | |
438 enum reg_class | |
439 mmix_secondary_reload_class (enum reg_class rclass, | |
440 enum machine_mode mode ATTRIBUTE_UNUSED, | |
441 rtx x ATTRIBUTE_UNUSED, | |
442 int in_p ATTRIBUTE_UNUSED) | |
443 { | |
444 if (rclass == REMAINDER_REG | |
445 || rclass == HIMULT_REG | |
446 || rclass == SYSTEM_REGS) | |
447 return GENERAL_REGS; | |
448 | |
449 return NO_REGS; | |
450 } | |
451 | |
452 /* CONST_OK_FOR_LETTER_P. */ | |
453 | |
454 int | |
455 mmix_const_ok_for_letter_p (HOST_WIDE_INT value, int c) | |
456 { | |
457 return | |
458 (c == 'I' ? value >= 0 && value <= 255 | |
459 : c == 'J' ? value >= 0 && value <= 65535 | |
460 : c == 'K' ? value <= 0 && value >= -255 | |
461 : c == 'L' ? mmix_shiftable_wyde_value (value) | |
462 : c == 'M' ? value == 0 | |
463 : c == 'N' ? mmix_shiftable_wyde_value (~value) | |
464 : c == 'O' ? (value == 3 || value == 5 || value == 9 | |
465 || value == 17) | |
466 : 0); | |
467 } | |
468 | |
469 /* CONST_DOUBLE_OK_FOR_LETTER_P. */ | |
470 | |
471 int | |
472 mmix_const_double_ok_for_letter_p (rtx value, int c) | |
473 { | |
474 return | |
475 (c == 'G' ? value == CONST0_RTX (GET_MODE (value)) | |
476 : 0); | |
477 } | |
478 | |
479 /* EXTRA_CONSTRAINT. | |
480 We need this since our constants are not always expressible as | |
481 CONST_INT:s, but rather often as CONST_DOUBLE:s. */ | |
482 | |
483 int | |
484 mmix_extra_constraint (rtx x, int c, int strict) | |
485 { | |
486 HOST_WIDEST_INT value; | |
487 | |
488 /* When checking for an address, we need to handle strict vs. non-strict | |
489 register checks. Don't use address_operand, but instead its | |
490 equivalent (its callee, which it is just a wrapper for), | |
491 memory_operand_p and the strict-equivalent strict_memory_address_p. */ | |
492 if (c == 'U') | |
493 return | |
494 strict | |
495 ? strict_memory_address_p (Pmode, x) | |
496 : memory_address_p (Pmode, x); | |
497 | |
498 /* R asks whether x is to be loaded with GETA or something else. Right | |
499 now, only a SYMBOL_REF and LABEL_REF can fit for | |
500 TARGET_BASE_ADDRESSES. | |
501 | |
502 Only constant symbolic addresses apply. With TARGET_BASE_ADDRESSES, | |
503 we just allow straight LABEL_REF or SYMBOL_REFs with SYMBOL_REF_FLAG | |
504 set right now; only function addresses and code labels. If we change | |
505 to let SYMBOL_REF_FLAG be set on other symbols, we have to check | |
506 inside CONST expressions. When TARGET_BASE_ADDRESSES is not in | |
507 effect, a "raw" constant check together with mmix_constant_address_p | |
508 is all that's needed; we want all constant addresses to be loaded | |
509 with GETA then. */ | |
510 if (c == 'R') | |
511 return | |
512 GET_CODE (x) != CONST_INT && GET_CODE (x) != CONST_DOUBLE | |
513 && mmix_constant_address_p (x) | |
514 && (! TARGET_BASE_ADDRESSES | |
515 || (GET_CODE (x) == LABEL_REF | |
516 || (GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_FLAG (x)))); | |
517 | |
518 if (GET_CODE (x) != CONST_DOUBLE || GET_MODE (x) != VOIDmode) | |
519 return 0; | |
520 | |
521 value = mmix_intval (x); | |
522 | |
523 /* We used to map Q->J, R->K, S->L, T->N, U->O, but we don't have to any | |
524 more ('U' taken for address_operand, 'R' similarly). Some letters map | |
525 outside of CONST_INT, though; we still use 'S' and 'T'. */ | |
526 if (c == 'S') | |
527 return mmix_shiftable_wyde_value (value); | |
528 else if (c == 'T') | |
529 return mmix_shiftable_wyde_value (~value); | |
530 return 0; | |
531 } | |
532 | |
533 /* DYNAMIC_CHAIN_ADDRESS. */ | |
534 | |
535 rtx | |
536 mmix_dynamic_chain_address (rtx frame) | |
537 { | |
538 /* FIXME: the frame-pointer is stored at offset -8 from the current | |
539 frame-pointer. Unfortunately, the caller assumes that a | |
540 frame-pointer is present for *all* previous frames. There should be | |
541 a way to say that that cannot be done, like for RETURN_ADDR_RTX. */ | |
542 return plus_constant (frame, -8); | |
543 } | |
544 | |
545 /* STARTING_FRAME_OFFSET. */ | |
546 | |
547 int | |
548 mmix_starting_frame_offset (void) | |
549 { | |
550 /* The old frame pointer is in the slot below the new one, so | |
551 FIRST_PARM_OFFSET does not need to depend on whether the | |
552 frame-pointer is needed or not. We have to adjust for the register | |
553 stack pointer being located below the saved frame pointer. | |
554 Similarly, we store the return address on the stack too, for | |
555 exception handling, and always if we save the register stack pointer. */ | |
556 return | |
557 (-8 | |
558 + (MMIX_CFUN_HAS_LANDING_PAD | |
559 ? -16 : (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS ? -8 : 0))); | |
560 } | |
561 | |
562 /* RETURN_ADDR_RTX. */ | |
563 | |
564 rtx | |
565 mmix_return_addr_rtx (int count, rtx frame ATTRIBUTE_UNUSED) | |
566 { | |
567 return count == 0 | |
568 ? (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS | |
569 /* FIXME: Set frame_alias_set on the following. (Why?) | |
570 See mmix_initial_elimination_offset for the reason we can't use | |
571 get_hard_reg_initial_val for both. Always using a stack slot | |
572 and not a register would be suboptimal. */ | |
573 ? validize_mem (gen_rtx_MEM (Pmode, plus_constant (frame_pointer_rtx, -16))) | |
574 : get_hard_reg_initial_val (Pmode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM)) | |
575 : NULL_RTX; | |
576 } | |
577 | |
578 /* SETUP_FRAME_ADDRESSES. */ | |
579 | |
580 void | |
581 mmix_setup_frame_addresses (void) | |
582 { | |
583 /* Nothing needed at the moment. */ | |
584 } | |
585 | |
586 /* The difference between the (imaginary) frame pointer and the stack | |
587 pointer. Used to eliminate the frame pointer. */ | |
588 | |
589 int | |
590 mmix_initial_elimination_offset (int fromreg, int toreg) | |
591 { | |
592 int regno; | |
593 int fp_sp_offset | |
594 = (get_frame_size () + crtl->outgoing_args_size + 7) & ~7; | |
595 | |
596 /* There is no actual offset between these two virtual values, but for | |
597 the frame-pointer, we have the old one in the stack position below | |
598 it, so the offset for the frame-pointer to the stack-pointer is one | |
599 octabyte larger. */ | |
600 if (fromreg == MMIX_ARG_POINTER_REGNUM | |
601 && toreg == MMIX_FRAME_POINTER_REGNUM) | |
602 return 0; | |
603 | |
604 /* The difference is the size of local variables plus the size of | |
605 outgoing function arguments that would normally be passed as | |
606 registers but must be passed on stack because we're out of | |
607 function-argument registers. Only global saved registers are | |
608 counted; the others go on the register stack. | |
609 | |
610 The frame-pointer is counted too if it is what is eliminated, as we | |
611 need to balance the offset for it from STARTING_FRAME_OFFSET. | |
612 | |
613 Also add in the slot for the register stack pointer we save if we | |
614 have a landing pad. | |
615 | |
616 Unfortunately, we can't access $0..$14, from unwinder code easily, so | |
617 store the return address in a frame slot too. FIXME: Only for | |
618 non-leaf functions. FIXME: Always with a landing pad, because it's | |
619 hard to know whether we need the other at the time we know we need | |
620 the offset for one (and have to state it). It's a kludge until we | |
621 can express the register stack in the EH frame info. | |
622 | |
623 We have to do alignment here; get_frame_size will not return a | |
624 multiple of STACK_BOUNDARY. FIXME: Add note in manual. */ | |
625 | |
626 for (regno = MMIX_FIRST_GLOBAL_REGNUM; | |
627 regno <= 255; | |
628 regno++) | |
629 if ((df_regs_ever_live_p (regno) && ! call_used_regs[regno]) | |
630 || IS_MMIX_EH_RETURN_DATA_REG (regno)) | |
631 fp_sp_offset += 8; | |
632 | |
633 return fp_sp_offset | |
634 + (MMIX_CFUN_HAS_LANDING_PAD | |
635 ? 16 : (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS ? 8 : 0)) | |
636 + (fromreg == MMIX_ARG_POINTER_REGNUM ? 0 : 8); | |
637 } | |
638 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
639 static void |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
640 mmix_function_arg_advance (CUMULATIVE_ARGS *argsp, enum machine_mode mode, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
641 const_tree type, bool named ATTRIBUTE_UNUSED) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
642 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
643 int arg_size = MMIX_FUNCTION_ARG_SIZE (mode, type); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
644 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
645 argsp->regs = ((targetm.calls.must_pass_in_stack (mode, type) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
646 || (arg_size > 8 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
647 && !TARGET_LIBFUNC |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
648 && !argsp->lib)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
649 ? (MMIX_MAX_ARGS_IN_REGS) + 1 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
650 : argsp->regs + (7 + arg_size) / 8); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
651 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
652 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
653 /* Helper function for mmix_function_arg and mmix_function_incoming_arg. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
654 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
655 static rtx |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
656 mmix_function_arg_1 (const CUMULATIVE_ARGS *argsp, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
657 enum machine_mode mode, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
658 const_tree type, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
659 bool named ATTRIBUTE_UNUSED, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
660 bool incoming) |
0 | 661 { |
662 /* Last-argument marker. */ | |
663 if (type == void_type_node) | |
664 return (argsp->regs < MMIX_MAX_ARGS_IN_REGS) | |
665 ? gen_rtx_REG (mode, | |
666 (incoming | |
667 ? MMIX_FIRST_INCOMING_ARG_REGNUM | |
668 : MMIX_FIRST_ARG_REGNUM) + argsp->regs) | |
669 : NULL_RTX; | |
670 | |
671 return (argsp->regs < MMIX_MAX_ARGS_IN_REGS | |
672 && !targetm.calls.must_pass_in_stack (mode, type) | |
673 && (GET_MODE_BITSIZE (mode) <= 64 | |
674 || argsp->lib | |
675 || TARGET_LIBFUNC)) | |
676 ? gen_rtx_REG (mode, | |
677 (incoming | |
678 ? MMIX_FIRST_INCOMING_ARG_REGNUM | |
679 : MMIX_FIRST_ARG_REGNUM) | |
680 + argsp->regs) | |
681 : NULL_RTX; | |
682 } | |
683 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
684 /* Return an rtx for a function argument to go in a register, and 0 for |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
685 one that must go on stack. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
686 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
687 static rtx |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
688 mmix_function_arg (CUMULATIVE_ARGS *argsp, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
689 enum machine_mode mode, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
690 const_tree type, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
691 bool named) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
692 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
693 return mmix_function_arg_1 (argsp, mode, type, named, false); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
694 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
695 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
696 static rtx |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
697 mmix_function_incoming_arg (CUMULATIVE_ARGS *argsp, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
698 enum machine_mode mode, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
699 const_tree type, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
700 bool named) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
701 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
702 return mmix_function_arg_1 (argsp, mode, type, named, true); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
703 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
704 |
0 | 705 /* Returns nonzero for everything that goes by reference, 0 for |
706 everything that goes by value. */ | |
707 | |
708 static bool | |
709 mmix_pass_by_reference (CUMULATIVE_ARGS *argsp, enum machine_mode mode, | |
710 const_tree type, bool named ATTRIBUTE_UNUSED) | |
711 { | |
712 /* FIXME: Check: I'm not sure the must_pass_in_stack check is | |
713 necessary. */ | |
714 if (targetm.calls.must_pass_in_stack (mode, type)) | |
715 return true; | |
716 | |
717 if (MMIX_FUNCTION_ARG_SIZE (mode, type) > 8 | |
718 && !TARGET_LIBFUNC | |
719 && (!argsp || !argsp->lib)) | |
720 return true; | |
721 | |
722 return false; | |
723 } | |
724 | |
725 /* Return nonzero if regno is a register number where a parameter is | |
726 passed, and 0 otherwise. */ | |
727 | |
728 int | |
729 mmix_function_arg_regno_p (int regno, int incoming) | |
730 { | |
731 int first_arg_regnum | |
732 = incoming ? MMIX_FIRST_INCOMING_ARG_REGNUM : MMIX_FIRST_ARG_REGNUM; | |
733 | |
734 return regno >= first_arg_regnum | |
735 && regno < first_arg_regnum + MMIX_MAX_ARGS_IN_REGS; | |
736 } | |
737 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
738 /* Implements TARGET_FUNCTION_VALUE. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
739 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
740 static rtx |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
741 mmix_function_value (const_tree valtype, |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
742 const_tree func ATTRIBUTE_UNUSED, |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
743 bool outgoing) |
0 | 744 { |
745 enum machine_mode mode = TYPE_MODE (valtype); | |
746 enum machine_mode cmode; | |
747 int first_val_regnum = MMIX_OUTGOING_RETURN_VALUE_REGNUM; | |
748 rtx vec[MMIX_MAX_REGS_FOR_VALUE]; | |
749 int i; | |
750 int nregs; | |
751 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
752 if (!outgoing) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
753 return gen_rtx_REG (mode, MMIX_RETURN_VALUE_REGNUM); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
754 |
0 | 755 /* Return values that fit in a register need no special handling. |
756 There's no register hole when parameters are passed in global | |
757 registers. */ | |
758 if (TARGET_ABI_GNU | |
759 || GET_MODE_BITSIZE (mode) <= BITS_PER_WORD) | |
760 return | |
761 gen_rtx_REG (mode, MMIX_OUTGOING_RETURN_VALUE_REGNUM); | |
762 | |
763 if (COMPLEX_MODE_P (mode)) | |
764 /* A complex type, made up of components. */ | |
765 cmode = TYPE_MODE (TREE_TYPE (valtype)); | |
766 else | |
767 { | |
768 /* Of the other larger-than-register modes, we only support | |
769 scalar mode TImode. (At least, that's the only one that's | |
770 been rudimentally tested.) Make sure we're alerted for | |
771 unexpected cases. */ | |
772 if (mode != TImode) | |
773 sorry ("support for mode %qs", GET_MODE_NAME (mode)); | |
774 | |
775 /* In any case, we will fill registers to the natural size. */ | |
776 cmode = DImode; | |
777 } | |
778 | |
779 nregs = ((GET_MODE_BITSIZE (mode) + BITS_PER_WORD - 1) / BITS_PER_WORD); | |
780 | |
781 /* We need to take care of the effect of the register hole on return | |
782 values of large sizes; the last register will appear as the first | |
783 register, with the rest shifted. (For complex modes, this is just | |
784 swapped registers.) */ | |
785 | |
786 if (nregs > MMIX_MAX_REGS_FOR_VALUE) | |
787 internal_error ("too large function value type, needs %d registers,\ | |
788 have only %d registers for this", nregs, MMIX_MAX_REGS_FOR_VALUE); | |
789 | |
790 /* FIXME: Maybe we should handle structure values like this too | |
791 (adjusted for BLKmode), perhaps for both ABI:s. */ | |
792 for (i = 0; i < nregs - 1; i++) | |
793 vec[i] | |
794 = gen_rtx_EXPR_LIST (VOIDmode, | |
795 gen_rtx_REG (cmode, first_val_regnum + i), | |
796 GEN_INT ((i + 1) * BITS_PER_UNIT)); | |
797 | |
798 vec[nregs - 1] | |
799 = gen_rtx_EXPR_LIST (VOIDmode, | |
800 gen_rtx_REG (cmode, first_val_regnum + nregs - 1), | |
801 const0_rtx); | |
802 | |
803 return gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (nregs, vec)); | |
804 } | |
805 | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
806 /* Implements TARGET_LIBCALL_VALUE. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
807 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
808 static rtx |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
809 mmix_libcall_value (enum machine_mode mode, |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
810 const_rtx fun ATTRIBUTE_UNUSED) |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
811 { |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
812 return gen_rtx_REG (mode, MMIX_RETURN_VALUE_REGNUM); |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
813 } |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
814 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
815 /* Implements TARGET_FUNCTION_VALUE_REGNO_P. */ |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
816 |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
817 static bool |
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
818 mmix_function_value_regno_p (const unsigned int regno) |
0 | 819 { |
820 return regno == MMIX_RETURN_VALUE_REGNUM; | |
821 } | |
822 | |
823 /* EH_RETURN_DATA_REGNO. */ | |
824 | |
825 int | |
826 mmix_eh_return_data_regno (int n) | |
827 { | |
828 if (n >= 0 && n < 4) | |
829 return MMIX_EH_RETURN_DATA_REGNO_START + n; | |
830 | |
831 return INVALID_REGNUM; | |
832 } | |
833 | |
834 /* EH_RETURN_STACKADJ_RTX. */ | |
835 | |
836 rtx | |
837 mmix_eh_return_stackadj_rtx (void) | |
838 { | |
839 return gen_rtx_REG (Pmode, MMIX_EH_RETURN_STACKADJ_REGNUM); | |
840 } | |
841 | |
842 /* EH_RETURN_HANDLER_RTX. */ | |
843 | |
844 rtx | |
845 mmix_eh_return_handler_rtx (void) | |
846 { | |
847 return gen_rtx_REG (Pmode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM); | |
848 } | |
849 | |
850 /* ASM_PREFERRED_EH_DATA_FORMAT. */ | |
851 | |
852 int | |
853 mmix_asm_preferred_eh_data_format (int code ATTRIBUTE_UNUSED, | |
854 int global ATTRIBUTE_UNUSED) | |
855 { | |
856 /* This is the default (was at 2001-07-20). Revisit when needed. */ | |
857 return DW_EH_PE_absptr; | |
858 } | |
859 | |
860 /* Make a note that we've seen the beginning of the prologue. This | |
861 matters to whether we'll translate register numbers as calculated by | |
862 mmix_reorg. */ | |
863 | |
864 static void | |
865 mmix_target_asm_function_prologue (FILE *stream ATTRIBUTE_UNUSED, | |
866 HOST_WIDE_INT framesize ATTRIBUTE_UNUSED) | |
867 { | |
868 cfun->machine->in_prologue = 1; | |
869 } | |
870 | |
871 /* Make a note that we've seen the end of the prologue. */ | |
872 | |
873 static void | |
874 mmix_target_asm_function_end_prologue (FILE *stream ATTRIBUTE_UNUSED) | |
875 { | |
876 cfun->machine->in_prologue = 0; | |
877 } | |
878 | |
879 /* Implement TARGET_MACHINE_DEPENDENT_REORG. No actual rearrangements | |
880 done here; just virtually by calculating the highest saved stack | |
881 register number used to modify the register numbers at output time. */ | |
882 | |
883 static void | |
884 mmix_reorg (void) | |
885 { | |
886 int regno; | |
887 | |
888 /* We put the number of the highest saved register-file register in a | |
889 location convenient for the call-patterns to output. Note that we | |
890 don't tell dwarf2 about these registers, since it can't restore them | |
891 anyway. */ | |
892 for (regno = MMIX_LAST_STACK_REGISTER_REGNUM; | |
893 regno >= 0; | |
894 regno--) | |
895 if ((df_regs_ever_live_p (regno) && !call_used_regs[regno]) | |
896 || (regno == MMIX_FRAME_POINTER_REGNUM && frame_pointer_needed)) | |
897 break; | |
898 | |
899 /* Regardless of whether they're saved (they might be just read), we | |
900 mustn't include registers that carry parameters. We could scan the | |
901 insns to see whether they're actually used (and indeed do other less | |
902 trivial register usage analysis and transformations), but it seems | |
903 wasteful to optimize for unused parameter registers. As of | |
904 2002-04-30, df_regs_ever_live_p (n) seems to be set for only-reads too, but | |
905 that might change. */ | |
906 if (!TARGET_ABI_GNU && regno < crtl->args.info.regs - 1) | |
907 { | |
908 regno = crtl->args.info.regs - 1; | |
909 | |
910 /* We don't want to let this cause us to go over the limit and make | |
911 incoming parameter registers be misnumbered and treating the last | |
912 parameter register and incoming return value register call-saved. | |
913 Stop things at the unmodified scheme. */ | |
914 if (regno > MMIX_RETURN_VALUE_REGNUM - 1) | |
915 regno = MMIX_RETURN_VALUE_REGNUM - 1; | |
916 } | |
917 | |
918 cfun->machine->highest_saved_stack_register = regno; | |
919 } | |
920 | |
921 /* TARGET_ASM_FUNCTION_EPILOGUE. */ | |
922 | |
923 static void | |
924 mmix_target_asm_function_epilogue (FILE *stream, | |
925 HOST_WIDE_INT locals_size ATTRIBUTE_UNUSED) | |
926 { | |
927 /* Emit an \n for readability of the generated assembly. */ | |
928 fputc ('\n', stream); | |
929 } | |
930 | |
931 /* TARGET_ASM_OUTPUT_MI_THUNK. */ | |
932 | |
933 static void | |
934 mmix_asm_output_mi_thunk (FILE *stream, | |
935 tree fndecl ATTRIBUTE_UNUSED, | |
936 HOST_WIDE_INT delta, | |
937 HOST_WIDE_INT vcall_offset ATTRIBUTE_UNUSED, | |
938 tree func) | |
939 { | |
940 /* If you define TARGET_STRUCT_VALUE_RTX that returns 0 (i.e. pass | |
941 location of structure to return as invisible first argument), you | |
942 need to tweak this code too. */ | |
943 const char *regname = reg_names[MMIX_FIRST_INCOMING_ARG_REGNUM]; | |
944 | |
945 if (delta >= 0 && delta < 65536) | |
946 fprintf (stream, "\tINCL %s,%d\n", regname, (int)delta); | |
947 else if (delta < 0 && delta >= -255) | |
948 fprintf (stream, "\tSUBU %s,%s,%d\n", regname, regname, (int)-delta); | |
949 else | |
950 { | |
951 mmix_output_register_setting (stream, 255, delta, 1); | |
952 fprintf (stream, "\tADDU %s,%s,$255\n", regname, regname); | |
953 } | |
954 | |
955 fprintf (stream, "\tJMP "); | |
956 assemble_name (stream, XSTR (XEXP (DECL_RTL (func), 0), 0)); | |
957 fprintf (stream, "\n"); | |
958 } | |
959 | |
960 /* FUNCTION_PROFILER. */ | |
961 | |
962 void | |
963 mmix_function_profiler (FILE *stream ATTRIBUTE_UNUSED, | |
964 int labelno ATTRIBUTE_UNUSED) | |
965 { | |
966 sorry ("function_profiler support for MMIX"); | |
967 } | |
968 | |
969 /* Worker function for TARGET_SETUP_INCOMING_VARARGS. For the moment, | |
970 let's stick to pushing argument registers on the stack. Later, we | |
971 can parse all arguments in registers, to improve performance. */ | |
972 | |
973 static void | |
974 mmix_setup_incoming_varargs (CUMULATIVE_ARGS *args_so_farp, | |
975 enum machine_mode mode, | |
976 tree vartype, | |
977 int *pretend_sizep, | |
978 int second_time ATTRIBUTE_UNUSED) | |
979 { | |
980 /* The last named variable has been handled, but | |
981 args_so_farp has not been advanced for it. */ | |
982 if (args_so_farp->regs + 1 < MMIX_MAX_ARGS_IN_REGS) | |
983 *pretend_sizep = (MMIX_MAX_ARGS_IN_REGS - (args_so_farp->regs + 1)) * 8; | |
984 | |
985 /* We assume that one argument takes up one register here. That should | |
986 be true until we start messing with multi-reg parameters. */ | |
987 if ((7 + (MMIX_FUNCTION_ARG_SIZE (mode, vartype))) / 8 != 1) | |
988 internal_error ("MMIX Internal: Last named vararg would not fit in a register"); | |
989 } | |
990 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
991 /* TARGET_ASM_TRAMPOLINE_TEMPLATE. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
992 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
993 static void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
994 mmix_asm_trampoline_template (FILE *stream) |
0 | 995 { |
996 /* Read a value into the static-chain register and jump somewhere. The | |
997 static chain is stored at offset 16, and the function address is | |
998 stored at offset 24. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
999 |
0 | 1000 fprintf (stream, "\tGETA $255,1F\n\t"); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1001 fprintf (stream, "LDOU %s,$255,0\n\t", reg_names[MMIX_STATIC_CHAIN_REGNUM]); |
0 | 1002 fprintf (stream, "LDOU $255,$255,8\n\t"); |
1003 fprintf (stream, "GO $255,$255,0\n"); | |
1004 fprintf (stream, "1H\tOCTA 0\n\t"); | |
1005 fprintf (stream, "OCTA 0\n"); | |
1006 } | |
1007 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1008 /* TARGET_TRAMPOLINE_INIT. */ |
0 | 1009 /* Set the static chain and function pointer field in the trampoline. |
1010 We also SYNCID here to be sure (doesn't matter in the simulator, but | |
1011 some day it will). */ | |
1012 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1013 static void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1014 mmix_trampoline_init (rtx m_tramp, tree fndecl, rtx static_chain) |
0 | 1015 { |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1016 rtx fnaddr = XEXP (DECL_RTL (fndecl), 0); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1017 rtx mem; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1018 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1019 emit_block_move (m_tramp, assemble_trampoline_template (), |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1020 GEN_INT (2*UNITS_PER_WORD), BLOCK_OP_NORMAL); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1021 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1022 mem = adjust_address (m_tramp, DImode, 2*UNITS_PER_WORD); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1023 emit_move_insn (mem, static_chain); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1024 mem = adjust_address (m_tramp, DImode, 3*UNITS_PER_WORD); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1025 emit_move_insn (mem, fnaddr); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1026 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1027 mem = adjust_address (m_tramp, DImode, 0); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1028 emit_insn (gen_sync_icache (mem, GEN_INT (TRAMPOLINE_SIZE - 1))); |
0 | 1029 } |
1030 | |
1031 /* We must exclude constant addresses that have an increment that is not a | |
1032 multiple of four bytes because of restrictions of the GETA | |
1033 instruction, unless TARGET_BASE_ADDRESSES. */ | |
1034 | |
1035 int | |
1036 mmix_constant_address_p (rtx x) | |
1037 { | |
1038 RTX_CODE code = GET_CODE (x); | |
1039 int addend = 0; | |
1040 /* When using "base addresses", anything constant goes. */ | |
1041 int constant_ok = TARGET_BASE_ADDRESSES != 0; | |
1042 | |
1043 switch (code) | |
1044 { | |
1045 case LABEL_REF: | |
1046 case SYMBOL_REF: | |
1047 return 1; | |
1048 | |
1049 case HIGH: | |
1050 /* FIXME: Don't know how to dissect these. Avoid them for now, | |
1051 except we know they're constants. */ | |
1052 return constant_ok; | |
1053 | |
1054 case CONST_INT: | |
1055 addend = INTVAL (x); | |
1056 break; | |
1057 | |
1058 case CONST_DOUBLE: | |
1059 if (GET_MODE (x) != VOIDmode) | |
1060 /* Strange that we got here. FIXME: Check if we do. */ | |
1061 return constant_ok; | |
1062 addend = CONST_DOUBLE_LOW (x); | |
1063 break; | |
1064 | |
1065 case CONST: | |
1066 /* Note that expressions with arithmetic on forward references don't | |
1067 work in mmixal. People using gcc assembly code with mmixal might | |
1068 need to move arrays and such to before the point of use. */ | |
1069 if (GET_CODE (XEXP (x, 0)) == PLUS) | |
1070 { | |
1071 rtx x0 = XEXP (XEXP (x, 0), 0); | |
1072 rtx x1 = XEXP (XEXP (x, 0), 1); | |
1073 | |
1074 if ((GET_CODE (x0) == SYMBOL_REF | |
1075 || GET_CODE (x0) == LABEL_REF) | |
1076 && (GET_CODE (x1) == CONST_INT | |
1077 || (GET_CODE (x1) == CONST_DOUBLE | |
1078 && GET_MODE (x1) == VOIDmode))) | |
1079 addend = mmix_intval (x1); | |
1080 else | |
1081 return constant_ok; | |
1082 } | |
1083 else | |
1084 return constant_ok; | |
1085 break; | |
1086 | |
1087 default: | |
1088 return 0; | |
1089 } | |
1090 | |
1091 return constant_ok || (addend & 3) == 0; | |
1092 } | |
1093 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1094 /* Return 1 if the address is OK, otherwise 0. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1095 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1096 bool |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1097 mmix_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1098 rtx x, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1099 bool strict_checking) |
0 | 1100 { |
1101 #define MMIX_REG_OK(X) \ | |
1102 ((strict_checking \ | |
1103 && (REGNO (X) <= MMIX_LAST_GENERAL_REGISTER \ | |
1104 || (reg_renumber[REGNO (X)] > 0 \ | |
1105 && reg_renumber[REGNO (X)] <= MMIX_LAST_GENERAL_REGISTER))) \ | |
1106 || (!strict_checking \ | |
1107 && (REGNO (X) <= MMIX_LAST_GENERAL_REGISTER \ | |
1108 || REGNO (X) >= FIRST_PSEUDO_REGISTER \ | |
1109 || REGNO (X) == ARG_POINTER_REGNUM))) | |
1110 | |
1111 /* We only accept: | |
1112 (mem reg) | |
1113 (mem (plus reg reg)) | |
1114 (mem (plus reg 0..255)). | |
1115 unless TARGET_BASE_ADDRESSES, in which case we accept all | |
1116 (mem constant_address) too. */ | |
1117 | |
1118 | |
1119 /* (mem reg) */ | |
1120 if (REG_P (x) && MMIX_REG_OK (x)) | |
1121 return 1; | |
1122 | |
1123 if (GET_CODE(x) == PLUS) | |
1124 { | |
1125 rtx x1 = XEXP (x, 0); | |
1126 rtx x2 = XEXP (x, 1); | |
1127 | |
1128 /* Try swapping the order. FIXME: Do we need this? */ | |
1129 if (! REG_P (x1)) | |
1130 { | |
1131 rtx tem = x1; | |
1132 x1 = x2; | |
1133 x2 = tem; | |
1134 } | |
1135 | |
1136 /* (mem (plus (reg?) (?))) */ | |
1137 if (!REG_P (x1) || !MMIX_REG_OK (x1)) | |
1138 return TARGET_BASE_ADDRESSES && mmix_constant_address_p (x); | |
1139 | |
1140 /* (mem (plus (reg) (reg?))) */ | |
1141 if (REG_P (x2) && MMIX_REG_OK (x2)) | |
1142 return 1; | |
1143 | |
1144 /* (mem (plus (reg) (0..255?))) */ | |
1145 if (GET_CODE (x2) == CONST_INT | |
1146 && CONST_OK_FOR_LETTER_P (INTVAL (x2), 'I')) | |
1147 return 1; | |
1148 | |
1149 return 0; | |
1150 } | |
1151 | |
1152 return TARGET_BASE_ADDRESSES && mmix_constant_address_p (x); | |
1153 } | |
1154 | |
1155 /* LEGITIMATE_CONSTANT_P. */ | |
1156 | |
1157 int | |
1158 mmix_legitimate_constant_p (rtx x) | |
1159 { | |
1160 RTX_CODE code = GET_CODE (x); | |
1161 | |
1162 /* We must allow any number due to the way the cse passes works; if we | |
1163 do not allow any number here, general_operand will fail, and insns | |
1164 will fatally fail recognition instead of "softly". */ | |
1165 if (code == CONST_INT || code == CONST_DOUBLE) | |
1166 return 1; | |
1167 | |
1168 return CONSTANT_ADDRESS_P (x); | |
1169 } | |
1170 | |
1171 /* SELECT_CC_MODE. */ | |
1172 | |
1173 enum machine_mode | |
1174 mmix_select_cc_mode (RTX_CODE op, rtx x, rtx y ATTRIBUTE_UNUSED) | |
1175 { | |
1176 /* We use CCmode, CC_UNSmode, CC_FPmode, CC_FPEQmode and CC_FUNmode to | |
1177 output different compare insns. Note that we do not check the | |
1178 validity of the comparison here. */ | |
1179 | |
1180 if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT) | |
1181 { | |
1182 if (op == ORDERED || op == UNORDERED || op == UNGE | |
1183 || op == UNGT || op == UNLE || op == UNLT) | |
1184 return CC_FUNmode; | |
1185 | |
1186 if (op == EQ || op == NE) | |
1187 return CC_FPEQmode; | |
1188 | |
1189 return CC_FPmode; | |
1190 } | |
1191 | |
1192 if (op == GTU || op == LTU || op == GEU || op == LEU) | |
1193 return CC_UNSmode; | |
1194 | |
1195 return CCmode; | |
1196 } | |
1197 | |
1198 /* REVERSIBLE_CC_MODE. */ | |
1199 | |
1200 int | |
1201 mmix_reversible_cc_mode (enum machine_mode mode) | |
1202 { | |
1203 /* That is, all integer and the EQ, NE, ORDERED and UNORDERED float | |
1204 compares. */ | |
1205 return mode != CC_FPmode; | |
1206 } | |
1207 | |
1208 /* TARGET_RTX_COSTS. */ | |
1209 | |
1210 static bool | |
1211 mmix_rtx_costs (rtx x ATTRIBUTE_UNUSED, | |
1212 int code ATTRIBUTE_UNUSED, | |
1213 int outer_code ATTRIBUTE_UNUSED, | |
1214 int *total ATTRIBUTE_UNUSED, | |
1215 bool speed ATTRIBUTE_UNUSED) | |
1216 { | |
1217 /* For the time being, this is just a stub and we'll accept the | |
1218 generic calculations, until we can do measurements, at least. | |
1219 Say we did not modify any calculated costs. */ | |
1220 return false; | |
1221 } | |
1222 | |
1223 /* REGISTER_MOVE_COST. */ | |
1224 | |
1225 int | |
1226 mmix_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED, | |
1227 enum reg_class from, | |
1228 enum reg_class to) | |
1229 { | |
1230 return (from == GENERAL_REGS && from == to) ? 2 : 3; | |
1231 } | |
1232 | |
1233 /* Note that we don't have a TEXT_SECTION_ASM_OP, because it has to be a | |
1234 compile-time constant; it's used in an asm in crtstuff.c, compiled for | |
1235 the target. */ | |
1236 | |
1237 /* DATA_SECTION_ASM_OP. */ | |
1238 | |
1239 const char * | |
1240 mmix_data_section_asm_op (void) | |
1241 { | |
1242 return "\t.data ! mmixal:= 8H LOC 9B"; | |
1243 } | |
1244 | |
1245 static void | |
1246 mmix_encode_section_info (tree decl, rtx rtl, int first) | |
1247 { | |
1248 /* Test for an external declaration, and do nothing if it is one. */ | |
1249 if ((TREE_CODE (decl) == VAR_DECL | |
1250 && (DECL_EXTERNAL (decl) || TREE_PUBLIC (decl))) | |
1251 || (TREE_CODE (decl) == FUNCTION_DECL && TREE_PUBLIC (decl))) | |
1252 ; | |
1253 else if (first && DECL_P (decl)) | |
1254 { | |
1255 /* For non-visible declarations, add a "@" prefix, which we skip | |
1256 when the label is output. If the label does not have this | |
1257 prefix, a ":" is output if -mtoplevel-symbols. | |
1258 | |
1259 Note that this does not work for data that is declared extern and | |
1260 later defined as static. If there's code in between, that code | |
1261 will refer to the extern declaration, and vice versa. This just | |
1262 means that when -mtoplevel-symbols is in use, we can just handle | |
1263 well-behaved ISO-compliant code. */ | |
1264 | |
1265 const char *str = XSTR (XEXP (rtl, 0), 0); | |
1266 int len = strlen (str); | |
1267 char *newstr = XALLOCAVEC (char, len + 2); | |
1268 newstr[0] = '@'; | |
1269 strcpy (newstr + 1, str); | |
1270 XSTR (XEXP (rtl, 0), 0) = ggc_alloc_string (newstr, len + 1); | |
1271 } | |
1272 | |
1273 /* Set SYMBOL_REF_FLAG for things that we want to access with GETA. We | |
1274 may need different options to reach for different things with GETA. | |
1275 For now, functions and things we know or have been told are constant. */ | |
1276 if (TREE_CODE (decl) == FUNCTION_DECL | |
1277 || TREE_CONSTANT (decl) | |
1278 || (TREE_CODE (decl) == VAR_DECL | |
1279 && TREE_READONLY (decl) | |
1280 && !TREE_SIDE_EFFECTS (decl) | |
1281 && (!DECL_INITIAL (decl) | |
1282 || TREE_CONSTANT (DECL_INITIAL (decl))))) | |
1283 SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1; | |
1284 } | |
1285 | |
1286 static const char * | |
1287 mmix_strip_name_encoding (const char *name) | |
1288 { | |
1289 for (; (*name == '@' || *name == '*'); name++) | |
1290 ; | |
1291 | |
1292 return name; | |
1293 } | |
1294 | |
1295 /* TARGET_ASM_FILE_START. | |
1296 We just emit a little comment for the time being. */ | |
1297 | |
1298 static void | |
1299 mmix_file_start (void) | |
1300 { | |
1301 default_file_start (); | |
1302 | |
1303 fputs ("! mmixal:= 8H LOC Data_Section\n", asm_out_file); | |
1304 | |
1305 /* Make sure each file starts with the text section. */ | |
1306 switch_to_section (text_section); | |
1307 } | |
1308 | |
1309 /* TARGET_ASM_FILE_END. */ | |
1310 | |
1311 static void | |
1312 mmix_file_end (void) | |
1313 { | |
1314 /* Make sure each file ends with the data section. */ | |
1315 switch_to_section (data_section); | |
1316 } | |
1317 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1318 /* TARGET_ASM_OUTPUT_SOURCE_FILENAME. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1319 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1320 static void |
0 | 1321 mmix_asm_output_source_filename (FILE *stream, const char *name) |
1322 { | |
1323 fprintf (stream, "# 1 "); | |
1324 OUTPUT_QUOTED_STRING (stream, name); | |
1325 fprintf (stream, "\n"); | |
1326 } | |
1327 | |
1328 /* OUTPUT_QUOTED_STRING. */ | |
1329 | |
1330 void | |
1331 mmix_output_quoted_string (FILE *stream, const char *string, int length) | |
1332 { | |
1333 const char * string_end = string + length; | |
1334 static const char *const unwanted_chars = "\"[]\\"; | |
1335 | |
1336 /* Output "any character except newline and double quote character". We | |
1337 play it safe and avoid all control characters too. We also do not | |
1338 want [] as characters, should input be passed through m4 with [] as | |
1339 quotes. Further, we avoid "\", because the GAS port handles it as a | |
1340 quoting character. */ | |
1341 while (string < string_end) | |
1342 { | |
1343 if (*string | |
1344 && (unsigned char) *string < 128 | |
1345 && !ISCNTRL (*string) | |
1346 && strchr (unwanted_chars, *string) == NULL) | |
1347 { | |
1348 fputc ('"', stream); | |
1349 while (*string | |
1350 && (unsigned char) *string < 128 | |
1351 && !ISCNTRL (*string) | |
1352 && strchr (unwanted_chars, *string) == NULL | |
1353 && string < string_end) | |
1354 { | |
1355 fputc (*string, stream); | |
1356 string++; | |
1357 } | |
1358 fputc ('"', stream); | |
1359 if (string < string_end) | |
1360 fprintf (stream, ","); | |
1361 } | |
1362 if (string < string_end) | |
1363 { | |
1364 fprintf (stream, "#%x", *string & 255); | |
1365 string++; | |
1366 if (string < string_end) | |
1367 fprintf (stream, ","); | |
1368 } | |
1369 } | |
1370 } | |
1371 | |
1372 /* Target hook for assembling integer objects. Use mmix_print_operand | |
1373 for WYDE and TETRA. Use mmix_output_octa to output 8-byte | |
1374 CONST_DOUBLEs. */ | |
1375 | |
1376 static bool | |
1377 mmix_assemble_integer (rtx x, unsigned int size, int aligned_p) | |
1378 { | |
1379 if (aligned_p) | |
1380 switch (size) | |
1381 { | |
1382 /* We handle a limited number of types of operands in here. But | |
1383 that's ok, because we can punt to generic functions. We then | |
1384 pretend that aligned data isn't needed, so the usual .<pseudo> | |
1385 syntax is used (which works for aligned data too). We actually | |
1386 *must* do that, since we say we don't have simple aligned | |
1387 pseudos, causing this function to be called. We just try and | |
1388 keep as much compatibility as possible with mmixal syntax for | |
1389 normal cases (i.e. without GNU extensions and C only). */ | |
1390 case 1: | |
1391 if (GET_CODE (x) != CONST_INT) | |
1392 { | |
1393 aligned_p = 0; | |
1394 break; | |
1395 } | |
1396 fputs ("\tBYTE\t", asm_out_file); | |
1397 mmix_print_operand (asm_out_file, x, 'B'); | |
1398 fputc ('\n', asm_out_file); | |
1399 return true; | |
1400 | |
1401 case 2: | |
1402 if (GET_CODE (x) != CONST_INT) | |
1403 { | |
1404 aligned_p = 0; | |
1405 break; | |
1406 } | |
1407 fputs ("\tWYDE\t", asm_out_file); | |
1408 mmix_print_operand (asm_out_file, x, 'W'); | |
1409 fputc ('\n', asm_out_file); | |
1410 return true; | |
1411 | |
1412 case 4: | |
1413 if (GET_CODE (x) != CONST_INT) | |
1414 { | |
1415 aligned_p = 0; | |
1416 break; | |
1417 } | |
1418 fputs ("\tTETRA\t", asm_out_file); | |
1419 mmix_print_operand (asm_out_file, x, 'L'); | |
1420 fputc ('\n', asm_out_file); | |
1421 return true; | |
1422 | |
1423 case 8: | |
1424 /* We don't get here anymore for CONST_DOUBLE, because DImode | |
1425 isn't expressed as CONST_DOUBLE, and DFmode is handled | |
1426 elsewhere. */ | |
1427 gcc_assert (GET_CODE (x) != CONST_DOUBLE); | |
1428 assemble_integer_with_op ("\tOCTA\t", x); | |
1429 return true; | |
1430 } | |
1431 return default_assemble_integer (x, size, aligned_p); | |
1432 } | |
1433 | |
1434 /* ASM_OUTPUT_ASCII. */ | |
1435 | |
1436 void | |
1437 mmix_asm_output_ascii (FILE *stream, const char *string, int length) | |
1438 { | |
1439 while (length > 0) | |
1440 { | |
1441 int chunk_size = length > 60 ? 60 : length; | |
1442 fprintf (stream, "\tBYTE "); | |
1443 mmix_output_quoted_string (stream, string, chunk_size); | |
1444 string += chunk_size; | |
1445 length -= chunk_size; | |
1446 fprintf (stream, "\n"); | |
1447 } | |
1448 } | |
1449 | |
1450 /* ASM_OUTPUT_ALIGNED_COMMON. */ | |
1451 | |
1452 void | |
1453 mmix_asm_output_aligned_common (FILE *stream, | |
1454 const char *name, | |
1455 int size, | |
1456 int align) | |
1457 { | |
1458 /* This is mostly the elfos.h one. There doesn't seem to be a way to | |
1459 express this in a mmixal-compatible way. */ | |
1460 fprintf (stream, "\t.comm\t"); | |
1461 assemble_name (stream, name); | |
1462 fprintf (stream, ",%u,%u ! mmixal-incompatible COMMON\n", | |
1463 size, align / BITS_PER_UNIT); | |
1464 } | |
1465 | |
1466 /* ASM_OUTPUT_ALIGNED_LOCAL. */ | |
1467 | |
1468 void | |
1469 mmix_asm_output_aligned_local (FILE *stream, | |
1470 const char *name, | |
1471 int size, | |
1472 int align) | |
1473 { | |
1474 switch_to_section (data_section); | |
1475 | |
1476 ASM_OUTPUT_ALIGN (stream, exact_log2 (align/BITS_PER_UNIT)); | |
1477 assemble_name (stream, name); | |
1478 fprintf (stream, "\tLOC @+%d\n", size); | |
1479 } | |
1480 | |
1481 /* ASM_OUTPUT_LABEL. */ | |
1482 | |
1483 void | |
1484 mmix_asm_output_label (FILE *stream, const char *name) | |
1485 { | |
1486 assemble_name (stream, name); | |
1487 fprintf (stream, "\tIS @\n"); | |
1488 } | |
1489 | |
1490 /* ASM_OUTPUT_INTERNAL_LABEL. */ | |
1491 | |
1492 void | |
1493 mmix_asm_output_internal_label (FILE *stream, const char *name) | |
1494 { | |
1495 assemble_name_raw (stream, name); | |
1496 fprintf (stream, "\tIS @\n"); | |
1497 } | |
1498 | |
1499 /* ASM_DECLARE_REGISTER_GLOBAL. */ | |
1500 | |
1501 void | |
1502 mmix_asm_declare_register_global (FILE *stream ATTRIBUTE_UNUSED, | |
1503 tree decl ATTRIBUTE_UNUSED, | |
1504 int regno ATTRIBUTE_UNUSED, | |
1505 const char *name ATTRIBUTE_UNUSED) | |
1506 { | |
1507 /* Nothing to do here, but there *will* be, therefore the framework is | |
1508 here. */ | |
1509 } | |
1510 | |
1511 /* ASM_WEAKEN_LABEL. */ | |
1512 | |
1513 void | |
1514 mmix_asm_weaken_label (FILE *stream ATTRIBUTE_UNUSED, | |
1515 const char *name ATTRIBUTE_UNUSED) | |
1516 { | |
1517 fprintf (stream, "\t.weak "); | |
1518 assemble_name (stream, name); | |
1519 fprintf (stream, " ! mmixal-incompatible\n"); | |
1520 } | |
1521 | |
1522 /* MAKE_DECL_ONE_ONLY. */ | |
1523 | |
1524 void | |
1525 mmix_make_decl_one_only (tree decl) | |
1526 { | |
1527 DECL_WEAK (decl) = 1; | |
1528 } | |
1529 | |
1530 /* ASM_OUTPUT_LABELREF. | |
1531 Strip GCC's '*' and our own '@'. No order is assumed. */ | |
1532 | |
1533 void | |
1534 mmix_asm_output_labelref (FILE *stream, const char *name) | |
1535 { | |
1536 int is_extern = 1; | |
1537 | |
1538 for (; (*name == '@' || *name == '*'); name++) | |
1539 if (*name == '@') | |
1540 is_extern = 0; | |
1541 | |
1542 asm_fprintf (stream, "%s%U%s", | |
1543 is_extern && TARGET_TOPLEVEL_SYMBOLS ? ":" : "", | |
1544 name); | |
1545 } | |
1546 | |
1547 /* ASM_OUTPUT_DEF. */ | |
1548 | |
1549 void | |
1550 mmix_asm_output_def (FILE *stream, const char *name, const char *value) | |
1551 { | |
1552 assemble_name (stream, name); | |
1553 fprintf (stream, "\tIS "); | |
1554 assemble_name (stream, value); | |
1555 fputc ('\n', stream); | |
1556 } | |
1557 | |
1558 /* PRINT_OPERAND. */ | |
1559 | |
1560 void | |
1561 mmix_print_operand (FILE *stream, rtx x, int code) | |
1562 { | |
1563 /* When we add support for different codes later, we can, when needed, | |
1564 drop through to the main handler with a modified operand. */ | |
1565 rtx modified_x = x; | |
1566 int regno = x != NULL_RTX && REG_P (x) ? REGNO (x) : 0; | |
1567 | |
1568 switch (code) | |
1569 { | |
1570 /* Unrelated codes are in alphabetic order. */ | |
1571 | |
1572 case '+': | |
1573 /* For conditional branches, output "P" for a probable branch. */ | |
1574 if (TARGET_BRANCH_PREDICT) | |
1575 { | |
1576 x = find_reg_note (current_output_insn, REG_BR_PROB, 0); | |
1577 if (x && INTVAL (XEXP (x, 0)) > REG_BR_PROB_BASE / 2) | |
1578 putc ('P', stream); | |
1579 } | |
1580 return; | |
1581 | |
1582 case '.': | |
1583 /* For the %d in POP %d,0. */ | |
1584 fprintf (stream, "%d", MMIX_POP_ARGUMENT ()); | |
1585 return; | |
1586 | |
1587 case 'B': | |
1588 if (GET_CODE (x) != CONST_INT) | |
1589 fatal_insn ("MMIX Internal: Expected a CONST_INT, not this", x); | |
1590 fprintf (stream, "%d", (int) (INTVAL (x) & 0xff)); | |
1591 return; | |
1592 | |
1593 case 'H': | |
1594 /* Highpart. Must be general register, and not the last one, as | |
1595 that one cannot be part of a consecutive register pair. */ | |
1596 if (regno > MMIX_LAST_GENERAL_REGISTER - 1) | |
1597 internal_error ("MMIX Internal: Bad register: %d", regno); | |
1598 | |
1599 /* This is big-endian, so the high-part is the first one. */ | |
1600 fprintf (stream, "%s", reg_names[MMIX_OUTPUT_REGNO (regno)]); | |
1601 return; | |
1602 | |
1603 case 'L': | |
1604 /* Lowpart. Must be CONST_INT or general register, and not the last | |
1605 one, as that one cannot be part of a consecutive register pair. */ | |
1606 if (GET_CODE (x) == CONST_INT) | |
1607 { | |
1608 fprintf (stream, "#%lx", | |
1609 (unsigned long) (INTVAL (x) | |
1610 & ((unsigned int) 0x7fffffff * 2 + 1))); | |
1611 return; | |
1612 } | |
1613 | |
1614 if (GET_CODE (x) == SYMBOL_REF) | |
1615 { | |
1616 output_addr_const (stream, x); | |
1617 return; | |
1618 } | |
1619 | |
1620 if (regno > MMIX_LAST_GENERAL_REGISTER - 1) | |
1621 internal_error ("MMIX Internal: Bad register: %d", regno); | |
1622 | |
1623 /* This is big-endian, so the low-part is + 1. */ | |
1624 fprintf (stream, "%s", reg_names[MMIX_OUTPUT_REGNO (regno) + 1]); | |
1625 return; | |
1626 | |
1627 /* Can't use 'a' because that's a generic modifier for address | |
1628 output. */ | |
1629 case 'A': | |
1630 mmix_output_shiftvalue_op_from_str (stream, "ANDN", | |
1631 ~(unsigned HOST_WIDEST_INT) | |
1632 mmix_intval (x)); | |
1633 return; | |
1634 | |
1635 case 'i': | |
1636 mmix_output_shiftvalue_op_from_str (stream, "INC", | |
1637 (unsigned HOST_WIDEST_INT) | |
1638 mmix_intval (x)); | |
1639 return; | |
1640 | |
1641 case 'o': | |
1642 mmix_output_shiftvalue_op_from_str (stream, "OR", | |
1643 (unsigned HOST_WIDEST_INT) | |
1644 mmix_intval (x)); | |
1645 return; | |
1646 | |
1647 case 's': | |
1648 mmix_output_shiftvalue_op_from_str (stream, "SET", | |
1649 (unsigned HOST_WIDEST_INT) | |
1650 mmix_intval (x)); | |
1651 return; | |
1652 | |
1653 case 'd': | |
1654 case 'D': | |
1655 mmix_output_condition (stream, x, (code == 'D')); | |
1656 return; | |
1657 | |
1658 case 'e': | |
1659 /* Output an extra "e" to make fcmpe, fune. */ | |
1660 if (TARGET_FCMP_EPSILON) | |
1661 fprintf (stream, "e"); | |
1662 return; | |
1663 | |
1664 case 'm': | |
1665 /* Output the number minus 1. */ | |
1666 if (GET_CODE (x) != CONST_INT) | |
1667 { | |
1668 fatal_insn ("MMIX Internal: Bad value for 'm', not a CONST_INT", | |
1669 x); | |
1670 } | |
1671 fprintf (stream, HOST_WIDEST_INT_PRINT_DEC, | |
1672 (HOST_WIDEST_INT) (mmix_intval (x) - 1)); | |
1673 return; | |
1674 | |
1675 case 'p': | |
1676 /* Store the number of registers we want to save. This was setup | |
1677 by the prologue. The actual operand contains the number of | |
1678 registers to pass, but we don't use it currently. Anyway, we | |
1679 need to output the number of saved registers here. */ | |
1680 fprintf (stream, "%d", | |
1681 cfun->machine->highest_saved_stack_register + 1); | |
1682 return; | |
1683 | |
1684 case 'r': | |
1685 /* Store the register to output a constant to. */ | |
1686 if (! REG_P (x)) | |
1687 fatal_insn ("MMIX Internal: Expected a register, not this", x); | |
1688 mmix_output_destination_register = MMIX_OUTPUT_REGNO (regno); | |
1689 return; | |
1690 | |
1691 case 'I': | |
1692 /* Output the constant. Note that we use this for floats as well. */ | |
1693 if (GET_CODE (x) != CONST_INT | |
1694 && (GET_CODE (x) != CONST_DOUBLE | |
1695 || (GET_MODE (x) != VOIDmode && GET_MODE (x) != DFmode | |
1696 && GET_MODE (x) != SFmode))) | |
1697 fatal_insn ("MMIX Internal: Expected a constant, not this", x); | |
1698 mmix_output_register_setting (stream, | |
1699 mmix_output_destination_register, | |
1700 mmix_intval (x), 0); | |
1701 return; | |
1702 | |
1703 case 'U': | |
1704 /* An U for unsigned, if TARGET_ZERO_EXTEND. Ignore the operand. */ | |
1705 if (TARGET_ZERO_EXTEND) | |
1706 putc ('U', stream); | |
1707 return; | |
1708 | |
1709 case 'v': | |
1710 mmix_output_shifted_value (stream, (HOST_WIDEST_INT) mmix_intval (x)); | |
1711 return; | |
1712 | |
1713 case 'V': | |
1714 mmix_output_shifted_value (stream, (HOST_WIDEST_INT) ~mmix_intval (x)); | |
1715 return; | |
1716 | |
1717 case 'W': | |
1718 if (GET_CODE (x) != CONST_INT) | |
1719 fatal_insn ("MMIX Internal: Expected a CONST_INT, not this", x); | |
1720 fprintf (stream, "#%x", (int) (INTVAL (x) & 0xffff)); | |
1721 return; | |
1722 | |
1723 case 0: | |
1724 /* Nothing to do. */ | |
1725 break; | |
1726 | |
1727 default: | |
1728 /* Presumably there's a missing case above if we get here. */ | |
1729 internal_error ("MMIX Internal: Missing %qc case in mmix_print_operand", code); | |
1730 } | |
1731 | |
1732 switch (GET_CODE (modified_x)) | |
1733 { | |
1734 case REG: | |
1735 regno = REGNO (modified_x); | |
1736 if (regno >= FIRST_PSEUDO_REGISTER) | |
1737 internal_error ("MMIX Internal: Bad register: %d", regno); | |
1738 fprintf (stream, "%s", reg_names[MMIX_OUTPUT_REGNO (regno)]); | |
1739 return; | |
1740 | |
1741 case MEM: | |
1742 output_address (XEXP (modified_x, 0)); | |
1743 return; | |
1744 | |
1745 case CONST_INT: | |
1746 /* For -2147483648, mmixal complains that the constant does not fit | |
1747 in 4 bytes, so let's output it as hex. Take care to handle hosts | |
1748 where HOST_WIDE_INT is longer than an int. | |
1749 | |
1750 Print small constants +-255 using decimal. */ | |
1751 | |
1752 if (INTVAL (modified_x) > -256 && INTVAL (modified_x) < 256) | |
1753 fprintf (stream, "%d", (int) (INTVAL (modified_x))); | |
1754 else | |
1755 fprintf (stream, "#%x", | |
1756 (int) (INTVAL (modified_x)) & (unsigned int) ~0); | |
1757 return; | |
1758 | |
1759 case CONST_DOUBLE: | |
1760 /* Do somewhat as CONST_INT. */ | |
1761 mmix_output_octa (stream, mmix_intval (modified_x), 0); | |
1762 return; | |
1763 | |
1764 case CONST: | |
1765 output_addr_const (stream, modified_x); | |
1766 return; | |
1767 | |
1768 default: | |
1769 /* No need to test for all strange things. Let output_addr_const do | |
1770 it for us. */ | |
1771 if (CONSTANT_P (modified_x) | |
1772 /* Strangely enough, this is not included in CONSTANT_P. | |
1773 FIXME: Ask/check about sanity here. */ | |
1774 || GET_CODE (modified_x) == CODE_LABEL) | |
1775 { | |
1776 output_addr_const (stream, modified_x); | |
1777 return; | |
1778 } | |
1779 | |
1780 /* We need the original here. */ | |
1781 fatal_insn ("MMIX Internal: Cannot decode this operand", x); | |
1782 } | |
1783 } | |
1784 | |
1785 /* PRINT_OPERAND_PUNCT_VALID_P. */ | |
1786 | |
1787 int | |
1788 mmix_print_operand_punct_valid_p (int code ATTRIBUTE_UNUSED) | |
1789 { | |
1790 /* A '+' is used for branch prediction, similar to other ports. */ | |
1791 return code == '+' | |
1792 /* A '.' is used for the %d in the POP %d,0 return insn. */ | |
1793 || code == '.'; | |
1794 } | |
1795 | |
1796 /* PRINT_OPERAND_ADDRESS. */ | |
1797 | |
1798 void | |
1799 mmix_print_operand_address (FILE *stream, rtx x) | |
1800 { | |
1801 if (REG_P (x)) | |
1802 { | |
1803 /* I find the generated assembly code harder to read without | |
1804 the ",0". */ | |
1805 fprintf (stream, "%s,0", reg_names[MMIX_OUTPUT_REGNO (REGNO (x))]); | |
1806 return; | |
1807 } | |
1808 else if (GET_CODE (x) == PLUS) | |
1809 { | |
1810 rtx x1 = XEXP (x, 0); | |
1811 rtx x2 = XEXP (x, 1); | |
1812 | |
1813 if (REG_P (x1)) | |
1814 { | |
1815 fprintf (stream, "%s,", reg_names[MMIX_OUTPUT_REGNO (REGNO (x1))]); | |
1816 | |
1817 if (REG_P (x2)) | |
1818 { | |
1819 fprintf (stream, "%s", | |
1820 reg_names[MMIX_OUTPUT_REGNO (REGNO (x2))]); | |
1821 return; | |
1822 } | |
1823 else if (GET_CODE (x2) == CONST_INT | |
1824 && CONST_OK_FOR_LETTER_P (INTVAL (x2), 'I')) | |
1825 { | |
1826 output_addr_const (stream, x2); | |
1827 return; | |
1828 } | |
1829 } | |
1830 } | |
1831 | |
1832 if (TARGET_BASE_ADDRESSES && mmix_legitimate_constant_p (x)) | |
1833 { | |
1834 output_addr_const (stream, x); | |
1835 return; | |
1836 } | |
1837 | |
1838 fatal_insn ("MMIX Internal: This is not a recognized address", x); | |
1839 } | |
1840 | |
1841 /* ASM_OUTPUT_REG_PUSH. */ | |
1842 | |
1843 void | |
1844 mmix_asm_output_reg_push (FILE *stream, int regno) | |
1845 { | |
1846 fprintf (stream, "\tSUBU %s,%s,8\n\tSTOU %s,%s,0\n", | |
1847 reg_names[MMIX_STACK_POINTER_REGNUM], | |
1848 reg_names[MMIX_STACK_POINTER_REGNUM], | |
1849 reg_names[MMIX_OUTPUT_REGNO (regno)], | |
1850 reg_names[MMIX_STACK_POINTER_REGNUM]); | |
1851 } | |
1852 | |
1853 /* ASM_OUTPUT_REG_POP. */ | |
1854 | |
1855 void | |
1856 mmix_asm_output_reg_pop (FILE *stream, int regno) | |
1857 { | |
1858 fprintf (stream, "\tLDOU %s,%s,0\n\tINCL %s,8\n", | |
1859 reg_names[MMIX_OUTPUT_REGNO (regno)], | |
1860 reg_names[MMIX_STACK_POINTER_REGNUM], | |
1861 reg_names[MMIX_STACK_POINTER_REGNUM]); | |
1862 } | |
1863 | |
1864 /* ASM_OUTPUT_ADDR_DIFF_ELT. */ | |
1865 | |
1866 void | |
1867 mmix_asm_output_addr_diff_elt (FILE *stream, | |
1868 rtx body ATTRIBUTE_UNUSED, | |
1869 int value, | |
1870 int rel) | |
1871 { | |
1872 fprintf (stream, "\tTETRA L%d-L%d\n", value, rel); | |
1873 } | |
1874 | |
1875 /* ASM_OUTPUT_ADDR_VEC_ELT. */ | |
1876 | |
1877 void | |
1878 mmix_asm_output_addr_vec_elt (FILE *stream, int value) | |
1879 { | |
1880 fprintf (stream, "\tOCTA L:%d\n", value); | |
1881 } | |
1882 | |
1883 /* ASM_OUTPUT_SKIP. */ | |
1884 | |
1885 void | |
1886 mmix_asm_output_skip (FILE *stream, int nbytes) | |
1887 { | |
1888 fprintf (stream, "\tLOC @+%d\n", nbytes); | |
1889 } | |
1890 | |
1891 /* ASM_OUTPUT_ALIGN. */ | |
1892 | |
1893 void | |
1894 mmix_asm_output_align (FILE *stream, int power) | |
1895 { | |
1896 /* We need to record the needed alignment of this section in the object, | |
1897 so we have to output an alignment directive. Use a .p2align (not | |
1898 .align) so people will never have to wonder about whether the | |
1899 argument is in number of bytes or the log2 thereof. We do it in | |
1900 addition to the LOC directive, so nothing needs tweaking when | |
1901 copy-pasting assembly into mmixal. */ | |
1902 fprintf (stream, "\t.p2align %d\n", power); | |
1903 fprintf (stream, "\tLOC @+(%d-@)&%d\n", 1 << power, (1 << power) - 1); | |
1904 } | |
1905 | |
1906 /* DBX_REGISTER_NUMBER. */ | |
1907 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1908 unsigned |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
1909 mmix_dbx_register_number (unsigned regno) |
0 | 1910 { |
1911 /* Adjust the register number to the one it will be output as, dammit. | |
1912 It'd be nice if we could check the assumption that we're filling a | |
1913 gap, but every register between the last saved register and parameter | |
1914 registers might be a valid parameter register. */ | |
1915 regno = MMIX_OUTPUT_REGNO (regno); | |
1916 | |
1917 /* We need to renumber registers to get the number of the return address | |
1918 register in the range 0..255. It is also space-saving if registers | |
1919 mentioned in the call-frame information (which uses this function by | |
1920 defaulting DWARF_FRAME_REGNUM to DBX_REGISTER_NUMBER) are numbered | |
1921 0 .. 63. So map 224 .. 256+15 -> 0 .. 47 and 0 .. 223 -> 48..223+48. */ | |
1922 return regno >= 224 ? (regno - 224) : (regno + 48); | |
1923 } | |
1924 | |
1925 /* End of target macro support functions. | |
1926 | |
1927 Now the MMIX port's own functions. First the exported ones. */ | |
1928 | |
1929 /* Wrapper for get_hard_reg_initial_val since integrate.h isn't included | |
1930 from insn-emit.c. */ | |
1931 | |
1932 rtx | |
1933 mmix_get_hard_reg_initial_val (enum machine_mode mode, int regno) | |
1934 { | |
1935 return get_hard_reg_initial_val (mode, regno); | |
1936 } | |
1937 | |
1938 /* Nonzero when the function epilogue is simple enough that a single | |
1939 "POP %d,0" should be used even within the function. */ | |
1940 | |
1941 int | |
1942 mmix_use_simple_return (void) | |
1943 { | |
1944 int regno; | |
1945 | |
1946 int stack_space_to_allocate | |
1947 = (crtl->outgoing_args_size | |
1948 + crtl->args.pretend_args_size | |
1949 + get_frame_size () + 7) & ~7; | |
1950 | |
1951 if (!TARGET_USE_RETURN_INSN || !reload_completed) | |
1952 return 0; | |
1953 | |
1954 for (regno = 255; | |
1955 regno >= MMIX_FIRST_GLOBAL_REGNUM; | |
1956 regno--) | |
1957 /* Note that we assume that the frame-pointer-register is one of these | |
1958 registers, in which case we don't count it here. */ | |
1959 if ((((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed) | |
1960 && df_regs_ever_live_p (regno) && !call_used_regs[regno])) | |
1961 || IS_MMIX_EH_RETURN_DATA_REG (regno)) | |
1962 return 0; | |
1963 | |
1964 if (frame_pointer_needed) | |
1965 stack_space_to_allocate += 8; | |
1966 | |
1967 if (MMIX_CFUN_HAS_LANDING_PAD) | |
1968 stack_space_to_allocate += 16; | |
1969 else if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS) | |
1970 stack_space_to_allocate += 8; | |
1971 | |
1972 return stack_space_to_allocate == 0; | |
1973 } | |
1974 | |
1975 | |
1976 /* Expands the function prologue into RTX. */ | |
1977 | |
1978 void | |
1979 mmix_expand_prologue (void) | |
1980 { | |
1981 HOST_WIDE_INT locals_size = get_frame_size (); | |
1982 int regno; | |
1983 HOST_WIDE_INT stack_space_to_allocate | |
1984 = (crtl->outgoing_args_size | |
1985 + crtl->args.pretend_args_size | |
1986 + locals_size + 7) & ~7; | |
1987 HOST_WIDE_INT offset = -8; | |
1988 | |
1989 /* Add room needed to save global non-register-stack registers. */ | |
1990 for (regno = 255; | |
1991 regno >= MMIX_FIRST_GLOBAL_REGNUM; | |
1992 regno--) | |
1993 /* Note that we assume that the frame-pointer-register is one of these | |
1994 registers, in which case we don't count it here. */ | |
1995 if ((((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed) | |
1996 && df_regs_ever_live_p (regno) && !call_used_regs[regno])) | |
1997 || IS_MMIX_EH_RETURN_DATA_REG (regno)) | |
1998 stack_space_to_allocate += 8; | |
1999 | |
2000 /* If we do have a frame-pointer, add room for it. */ | |
2001 if (frame_pointer_needed) | |
2002 stack_space_to_allocate += 8; | |
2003 | |
2004 /* If we have a non-local label, we need to be able to unwind to it, so | |
2005 store the current register stack pointer. Also store the return | |
2006 address if we do that. */ | |
2007 if (MMIX_CFUN_HAS_LANDING_PAD) | |
2008 stack_space_to_allocate += 16; | |
2009 else if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS) | |
2010 /* If we do have a saved return-address slot, add room for it. */ | |
2011 stack_space_to_allocate += 8; | |
2012 | |
2013 /* Make sure we don't get an unaligned stack. */ | |
2014 if ((stack_space_to_allocate % 8) != 0) | |
2015 internal_error ("stack frame not a multiple of 8 bytes: %wd", | |
2016 stack_space_to_allocate); | |
2017 | |
2018 if (crtl->args.pretend_args_size) | |
2019 { | |
2020 int mmix_first_vararg_reg | |
2021 = (MMIX_FIRST_INCOMING_ARG_REGNUM | |
2022 + (MMIX_MAX_ARGS_IN_REGS | |
2023 - crtl->args.pretend_args_size / 8)); | |
2024 | |
2025 for (regno | |
2026 = MMIX_FIRST_INCOMING_ARG_REGNUM + MMIX_MAX_ARGS_IN_REGS - 1; | |
2027 regno >= mmix_first_vararg_reg; | |
2028 regno--) | |
2029 { | |
2030 if (offset < 0) | |
2031 { | |
2032 HOST_WIDE_INT stack_chunk | |
2033 = stack_space_to_allocate > (256 - 8) | |
2034 ? (256 - 8) : stack_space_to_allocate; | |
2035 | |
2036 mmix_emit_sp_add (-stack_chunk); | |
2037 offset += stack_chunk; | |
2038 stack_space_to_allocate -= stack_chunk; | |
2039 } | |
2040 | |
2041 /* These registers aren't actually saved (as in "will be | |
2042 restored"), so don't tell DWARF2 they're saved. */ | |
2043 emit_move_insn (gen_rtx_MEM (DImode, | |
2044 plus_constant (stack_pointer_rtx, | |
2045 offset)), | |
2046 gen_rtx_REG (DImode, regno)); | |
2047 offset -= 8; | |
2048 } | |
2049 } | |
2050 | |
2051 /* Store the frame-pointer. */ | |
2052 | |
2053 if (frame_pointer_needed) | |
2054 { | |
2055 rtx insn; | |
2056 | |
2057 if (offset < 0) | |
2058 { | |
2059 /* Get 8 less than otherwise, since we need to reach offset + 8. */ | |
2060 HOST_WIDE_INT stack_chunk | |
2061 = stack_space_to_allocate > (256 - 8 - 8) | |
2062 ? (256 - 8 - 8) : stack_space_to_allocate; | |
2063 | |
2064 mmix_emit_sp_add (-stack_chunk); | |
2065 | |
2066 offset += stack_chunk; | |
2067 stack_space_to_allocate -= stack_chunk; | |
2068 } | |
2069 | |
2070 insn = emit_move_insn (gen_rtx_MEM (DImode, | |
2071 plus_constant (stack_pointer_rtx, | |
2072 offset)), | |
2073 hard_frame_pointer_rtx); | |
2074 RTX_FRAME_RELATED_P (insn) = 1; | |
2075 insn = emit_insn (gen_adddi3 (hard_frame_pointer_rtx, | |
2076 stack_pointer_rtx, | |
2077 GEN_INT (offset + 8))); | |
2078 RTX_FRAME_RELATED_P (insn) = 1; | |
2079 offset -= 8; | |
2080 } | |
2081 | |
2082 if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS) | |
2083 { | |
2084 rtx tmpreg, retreg; | |
2085 rtx insn; | |
2086 | |
2087 /* Store the return-address, if one is needed on the stack. We | |
2088 usually store it in a register when needed, but that doesn't work | |
2089 with -fexceptions. */ | |
2090 | |
2091 if (offset < 0) | |
2092 { | |
2093 /* Get 8 less than otherwise, since we need to reach offset + 8. */ | |
2094 HOST_WIDE_INT stack_chunk | |
2095 = stack_space_to_allocate > (256 - 8 - 8) | |
2096 ? (256 - 8 - 8) : stack_space_to_allocate; | |
2097 | |
2098 mmix_emit_sp_add (-stack_chunk); | |
2099 | |
2100 offset += stack_chunk; | |
2101 stack_space_to_allocate -= stack_chunk; | |
2102 } | |
2103 | |
2104 tmpreg = gen_rtx_REG (DImode, 255); | |
2105 retreg = gen_rtx_REG (DImode, MMIX_rJ_REGNUM); | |
2106 | |
2107 /* Dwarf2 code is confused by the use of a temporary register for | |
2108 storing the return address, so we have to express it as a note, | |
2109 which we attach to the actual store insn. */ | |
2110 emit_move_insn (tmpreg, retreg); | |
2111 | |
2112 insn = emit_move_insn (gen_rtx_MEM (DImode, | |
2113 plus_constant (stack_pointer_rtx, | |
2114 offset)), | |
2115 tmpreg); | |
2116 RTX_FRAME_RELATED_P (insn) = 1; | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2117 add_reg_note (insn, REG_FRAME_RELATED_EXPR, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2118 gen_rtx_SET (VOIDmode, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2119 gen_rtx_MEM (DImode, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2120 plus_constant (stack_pointer_rtx, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2121 offset)), |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2122 retreg)); |
0 | 2123 |
2124 offset -= 8; | |
2125 } | |
2126 else if (MMIX_CFUN_HAS_LANDING_PAD) | |
2127 offset -= 8; | |
2128 | |
2129 if (MMIX_CFUN_HAS_LANDING_PAD) | |
2130 { | |
2131 /* Store the register defining the numbering of local registers, so | |
2132 we know how long to unwind the register stack. */ | |
2133 | |
2134 if (offset < 0) | |
2135 { | |
2136 /* Get 8 less than otherwise, since we need to reach offset + 8. */ | |
2137 HOST_WIDE_INT stack_chunk | |
2138 = stack_space_to_allocate > (256 - 8 - 8) | |
2139 ? (256 - 8 - 8) : stack_space_to_allocate; | |
2140 | |
2141 mmix_emit_sp_add (-stack_chunk); | |
2142 | |
2143 offset += stack_chunk; | |
2144 stack_space_to_allocate -= stack_chunk; | |
2145 } | |
2146 | |
2147 /* We don't tell dwarf2 about this one; we just have it to unwind | |
2148 the register stack at landing pads. FIXME: It's a kludge because | |
2149 we can't describe the effect of the PUSHJ and PUSHGO insns on the | |
2150 register stack at the moment. Best thing would be to handle it | |
2151 like stack-pointer offsets. Better: some hook into dwarf2out.c | |
2152 to produce DW_CFA_expression:s that specify the increment of rO, | |
2153 and unwind it at eh_return (preferred) or at the landing pad. | |
2154 Then saves to $0..$G-1 could be specified through that register. */ | |
2155 | |
2156 emit_move_insn (gen_rtx_REG (DImode, 255), | |
2157 gen_rtx_REG (DImode, | |
2158 MMIX_rO_REGNUM)); | |
2159 emit_move_insn (gen_rtx_MEM (DImode, | |
2160 plus_constant (stack_pointer_rtx, offset)), | |
2161 gen_rtx_REG (DImode, 255)); | |
2162 offset -= 8; | |
2163 } | |
2164 | |
2165 /* After the return-address and the frame-pointer, we have the local | |
2166 variables. They're the ones that may have an "unaligned" size. */ | |
2167 offset -= (locals_size + 7) & ~7; | |
2168 | |
2169 /* Now store all registers that are global, i.e. not saved by the | |
2170 register file machinery. | |
2171 | |
2172 It is assumed that the frame-pointer is one of these registers, so it | |
2173 is explicitly excluded in the count. */ | |
2174 | |
2175 for (regno = 255; | |
2176 regno >= MMIX_FIRST_GLOBAL_REGNUM; | |
2177 regno--) | |
2178 if (((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed) | |
2179 && df_regs_ever_live_p (regno) && ! call_used_regs[regno]) | |
2180 || IS_MMIX_EH_RETURN_DATA_REG (regno)) | |
2181 { | |
2182 rtx insn; | |
2183 | |
2184 if (offset < 0) | |
2185 { | |
2186 HOST_WIDE_INT stack_chunk | |
2187 = (stack_space_to_allocate > (256 - offset - 8) | |
2188 ? (256 - offset - 8) : stack_space_to_allocate); | |
2189 | |
2190 mmix_emit_sp_add (-stack_chunk); | |
2191 offset += stack_chunk; | |
2192 stack_space_to_allocate -= stack_chunk; | |
2193 } | |
2194 | |
2195 insn = emit_move_insn (gen_rtx_MEM (DImode, | |
2196 plus_constant (stack_pointer_rtx, | |
2197 offset)), | |
2198 gen_rtx_REG (DImode, regno)); | |
2199 RTX_FRAME_RELATED_P (insn) = 1; | |
2200 offset -= 8; | |
2201 } | |
2202 | |
2203 /* Finally, allocate room for outgoing args and local vars if room | |
2204 wasn't allocated above. */ | |
2205 if (stack_space_to_allocate) | |
2206 mmix_emit_sp_add (-stack_space_to_allocate); | |
2207 } | |
2208 | |
2209 /* Expands the function epilogue into RTX. */ | |
2210 | |
2211 void | |
2212 mmix_expand_epilogue (void) | |
2213 { | |
2214 HOST_WIDE_INT locals_size = get_frame_size (); | |
2215 int regno; | |
2216 HOST_WIDE_INT stack_space_to_deallocate | |
2217 = (crtl->outgoing_args_size | |
2218 + crtl->args.pretend_args_size | |
2219 + locals_size + 7) & ~7; | |
2220 | |
2221 /* The first address to access is beyond the outgoing_args area. */ | |
2222 HOST_WIDE_INT offset = crtl->outgoing_args_size; | |
2223 | |
2224 /* Add the space for global non-register-stack registers. | |
2225 It is assumed that the frame-pointer register can be one of these | |
2226 registers, in which case it is excluded from the count when needed. */ | |
2227 for (regno = 255; | |
2228 regno >= MMIX_FIRST_GLOBAL_REGNUM; | |
2229 regno--) | |
2230 if (((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed) | |
2231 && df_regs_ever_live_p (regno) && !call_used_regs[regno]) | |
2232 || IS_MMIX_EH_RETURN_DATA_REG (regno)) | |
2233 stack_space_to_deallocate += 8; | |
2234 | |
2235 /* Add in the space for register stack-pointer. If so, always add room | |
2236 for the saved PC. */ | |
2237 if (MMIX_CFUN_HAS_LANDING_PAD) | |
2238 stack_space_to_deallocate += 16; | |
2239 else if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS) | |
2240 /* If we have a saved return-address slot, add it in. */ | |
2241 stack_space_to_deallocate += 8; | |
2242 | |
2243 /* Add in the frame-pointer. */ | |
2244 if (frame_pointer_needed) | |
2245 stack_space_to_deallocate += 8; | |
2246 | |
2247 /* Make sure we don't get an unaligned stack. */ | |
2248 if ((stack_space_to_deallocate % 8) != 0) | |
2249 internal_error ("stack frame not a multiple of octabyte: %wd", | |
2250 stack_space_to_deallocate); | |
2251 | |
2252 /* We will add back small offsets to the stack pointer as we go. | |
2253 First, we restore all registers that are global, i.e. not saved by | |
2254 the register file machinery. */ | |
2255 | |
2256 for (regno = MMIX_FIRST_GLOBAL_REGNUM; | |
2257 regno <= 255; | |
2258 regno++) | |
2259 if (((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed) | |
2260 && df_regs_ever_live_p (regno) && !call_used_regs[regno]) | |
2261 || IS_MMIX_EH_RETURN_DATA_REG (regno)) | |
2262 { | |
2263 if (offset > 255) | |
2264 { | |
2265 mmix_emit_sp_add (offset); | |
2266 stack_space_to_deallocate -= offset; | |
2267 offset = 0; | |
2268 } | |
2269 | |
2270 emit_move_insn (gen_rtx_REG (DImode, regno), | |
2271 gen_rtx_MEM (DImode, | |
2272 plus_constant (stack_pointer_rtx, | |
2273 offset))); | |
2274 offset += 8; | |
2275 } | |
2276 | |
2277 /* Here is where the local variables were. As in the prologue, they | |
2278 might be of an unaligned size. */ | |
2279 offset += (locals_size + 7) & ~7; | |
2280 | |
2281 /* The saved register stack pointer is just below the frame-pointer | |
2282 register. We don't need to restore it "manually"; the POP | |
2283 instruction does that. */ | |
2284 if (MMIX_CFUN_HAS_LANDING_PAD) | |
2285 offset += 16; | |
2286 else if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS) | |
2287 /* The return-address slot is just below the frame-pointer register. | |
2288 We don't need to restore it because we don't really use it. */ | |
2289 offset += 8; | |
2290 | |
2291 /* Get back the old frame-pointer-value. */ | |
2292 if (frame_pointer_needed) | |
2293 { | |
2294 if (offset > 255) | |
2295 { | |
2296 mmix_emit_sp_add (offset); | |
2297 | |
2298 stack_space_to_deallocate -= offset; | |
2299 offset = 0; | |
2300 } | |
2301 | |
2302 emit_move_insn (hard_frame_pointer_rtx, | |
2303 gen_rtx_MEM (DImode, | |
2304 plus_constant (stack_pointer_rtx, | |
2305 offset))); | |
2306 offset += 8; | |
2307 } | |
2308 | |
2309 /* We do not need to restore pretended incoming args, just add back | |
2310 offset to sp. */ | |
2311 if (stack_space_to_deallocate != 0) | |
2312 mmix_emit_sp_add (stack_space_to_deallocate); | |
2313 | |
2314 if (crtl->calls_eh_return) | |
2315 /* Adjust the (normal) stack-pointer to that of the receiver. | |
2316 FIXME: It would be nice if we could also adjust the register stack | |
2317 here, but we need to express it through DWARF 2 too. */ | |
2318 emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx, | |
2319 gen_rtx_REG (DImode, | |
2320 MMIX_EH_RETURN_STACKADJ_REGNUM))); | |
2321 } | |
2322 | |
2323 /* Output an optimal sequence for setting a register to a specific | |
2324 constant. Used in an alternative for const_ints in movdi, and when | |
2325 using large stack-frame offsets. | |
2326 | |
2327 Use do_begin_end to say if a line-starting TAB and newline before the | |
2328 first insn and after the last insn is wanted. */ | |
2329 | |
2330 void | |
2331 mmix_output_register_setting (FILE *stream, | |
2332 int regno, | |
2333 HOST_WIDEST_INT value, | |
2334 int do_begin_end) | |
2335 { | |
2336 if (do_begin_end) | |
2337 fprintf (stream, "\t"); | |
2338 | |
2339 if (mmix_shiftable_wyde_value ((unsigned HOST_WIDEST_INT) value)) | |
2340 { | |
2341 /* First, the one-insn cases. */ | |
2342 mmix_output_shiftvalue_op_from_str (stream, "SET", | |
2343 (unsigned HOST_WIDEST_INT) | |
2344 value); | |
2345 fprintf (stream, " %s,", reg_names[regno]); | |
2346 mmix_output_shifted_value (stream, (unsigned HOST_WIDEST_INT) value); | |
2347 } | |
2348 else if (mmix_shiftable_wyde_value (-(unsigned HOST_WIDEST_INT) value)) | |
2349 { | |
2350 /* We do this to get a bit more legible assembly code. The next | |
2351 alternative is mostly redundant with this. */ | |
2352 | |
2353 mmix_output_shiftvalue_op_from_str (stream, "SET", | |
2354 -(unsigned HOST_WIDEST_INT) | |
2355 value); | |
2356 fprintf (stream, " %s,", reg_names[regno]); | |
2357 mmix_output_shifted_value (stream, -(unsigned HOST_WIDEST_INT) value); | |
2358 fprintf (stream, "\n\tNEGU %s,0,%s", reg_names[regno], | |
2359 reg_names[regno]); | |
2360 } | |
2361 else if (mmix_shiftable_wyde_value (~(unsigned HOST_WIDEST_INT) value)) | |
2362 { | |
2363 /* Slightly more expensive, the two-insn cases. */ | |
2364 | |
2365 /* FIXME: We could of course also test if 0..255-N or ~(N | 1..255) | |
2366 is shiftable, or any other one-insn transformation of the value. | |
2367 FIXME: Check first if the value is "shiftable" by two loading | |
2368 with two insns, since it makes more readable assembly code (if | |
2369 anyone else cares). */ | |
2370 | |
2371 mmix_output_shiftvalue_op_from_str (stream, "SET", | |
2372 ~(unsigned HOST_WIDEST_INT) | |
2373 value); | |
2374 fprintf (stream, " %s,", reg_names[regno]); | |
2375 mmix_output_shifted_value (stream, ~(unsigned HOST_WIDEST_INT) value); | |
2376 fprintf (stream, "\n\tNOR %s,%s,0", reg_names[regno], | |
2377 reg_names[regno]); | |
2378 } | |
2379 else | |
2380 { | |
2381 /* The generic case. 2..4 insns. */ | |
2382 static const char *const higher_parts[] = {"L", "ML", "MH", "H"}; | |
2383 const char *op = "SET"; | |
2384 const char *line_begin = ""; | |
2385 int insns = 0; | |
2386 int i; | |
2387 HOST_WIDEST_INT tmpvalue = value; | |
2388 | |
2389 /* Compute the number of insns needed to output this constant. */ | |
2390 for (i = 0; i < 4 && tmpvalue != 0; i++) | |
2391 { | |
2392 if (tmpvalue & 65535) | |
2393 insns++; | |
2394 tmpvalue >>= 16; | |
2395 } | |
2396 if (TARGET_BASE_ADDRESSES && insns == 3) | |
2397 { | |
2398 /* The number three is based on a static observation on | |
2399 ghostscript-6.52. Two and four are excluded because there | |
2400 are too many such constants, and each unique constant (maybe | |
2401 offset by 1..255) were used few times compared to other uses, | |
2402 e.g. addresses. | |
2403 | |
2404 We use base-plus-offset addressing to force it into a global | |
2405 register; we just use a "LDA reg,VALUE", which will cause the | |
2406 assembler and linker to DTRT (for constants as well as | |
2407 addresses). */ | |
2408 fprintf (stream, "LDA %s,", reg_names[regno]); | |
2409 mmix_output_octa (stream, value, 0); | |
2410 } | |
2411 else | |
2412 { | |
2413 /* Output pertinent parts of the 4-wyde sequence. | |
2414 Still more to do if we want this to be optimal, but hey... | |
2415 Note that the zero case has been handled above. */ | |
2416 for (i = 0; i < 4 && value != 0; i++) | |
2417 { | |
2418 if (value & 65535) | |
2419 { | |
2420 fprintf (stream, "%s%s%s %s,#%x", line_begin, op, | |
2421 higher_parts[i], reg_names[regno], | |
2422 (int) (value & 65535)); | |
2423 /* The first one sets the rest of the bits to 0, the next | |
2424 ones add set bits. */ | |
2425 op = "INC"; | |
2426 line_begin = "\n\t"; | |
2427 } | |
2428 | |
2429 value >>= 16; | |
2430 } | |
2431 } | |
2432 } | |
2433 | |
2434 if (do_begin_end) | |
2435 fprintf (stream, "\n"); | |
2436 } | |
2437 | |
2438 /* Return 1 if value is 0..65535*2**(16*N) for N=0..3. | |
2439 else return 0. */ | |
2440 | |
2441 int | |
2442 mmix_shiftable_wyde_value (unsigned HOST_WIDEST_INT value) | |
2443 { | |
2444 /* Shift by 16 bits per group, stop when we've found two groups with | |
2445 nonzero bits. */ | |
2446 int i; | |
2447 int has_candidate = 0; | |
2448 | |
2449 for (i = 0; i < 4; i++) | |
2450 { | |
2451 if (value & 65535) | |
2452 { | |
2453 if (has_candidate) | |
2454 return 0; | |
2455 else | |
2456 has_candidate = 1; | |
2457 } | |
2458 | |
2459 value >>= 16; | |
2460 } | |
2461 | |
2462 return 1; | |
2463 } | |
2464 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2465 /* X and Y are two things to compare using CODE. Return the rtx for |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2466 the cc-reg in the proper mode. */ |
0 | 2467 |
2468 rtx | |
2469 mmix_gen_compare_reg (RTX_CODE code, rtx x, rtx y) | |
2470 { | |
2471 enum machine_mode ccmode = SELECT_CC_MODE (code, x, y); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2472 return gen_reg_rtx (ccmode); |
0 | 2473 } |
2474 | |
2475 /* Local (static) helper functions. */ | |
2476 | |
2477 static void | |
2478 mmix_emit_sp_add (HOST_WIDE_INT offset) | |
2479 { | |
2480 rtx insn; | |
2481 | |
2482 if (offset < 0) | |
2483 { | |
2484 /* Negative stack-pointer adjustments are allocations and appear in | |
2485 the prologue only. We mark them as frame-related so unwind and | |
2486 debug info is properly emitted for them. */ | |
2487 if (offset > -255) | |
2488 insn = emit_insn (gen_adddi3 (stack_pointer_rtx, | |
2489 stack_pointer_rtx, | |
2490 GEN_INT (offset))); | |
2491 else | |
2492 { | |
2493 rtx tmpr = gen_rtx_REG (DImode, 255); | |
2494 RTX_FRAME_RELATED_P (emit_move_insn (tmpr, GEN_INT (offset))) = 1; | |
2495 insn = emit_insn (gen_adddi3 (stack_pointer_rtx, | |
2496 stack_pointer_rtx, tmpr)); | |
2497 } | |
2498 RTX_FRAME_RELATED_P (insn) = 1; | |
2499 } | |
2500 else | |
2501 { | |
2502 /* Positive adjustments are in the epilogue only. Don't mark them | |
2503 as "frame-related" for unwind info. */ | |
2504 if (CONST_OK_FOR_LETTER_P (offset, 'L')) | |
2505 emit_insn (gen_adddi3 (stack_pointer_rtx, | |
2506 stack_pointer_rtx, | |
2507 GEN_INT (offset))); | |
2508 else | |
2509 { | |
2510 rtx tmpr = gen_rtx_REG (DImode, 255); | |
2511 emit_move_insn (tmpr, GEN_INT (offset)); | |
2512 insn = emit_insn (gen_adddi3 (stack_pointer_rtx, | |
2513 stack_pointer_rtx, tmpr)); | |
2514 } | |
2515 } | |
2516 } | |
2517 | |
2518 /* Print operator suitable for doing something with a shiftable | |
2519 wyde. The type of operator is passed as an asm output modifier. */ | |
2520 | |
2521 static void | |
2522 mmix_output_shiftvalue_op_from_str (FILE *stream, | |
2523 const char *mainop, | |
2524 HOST_WIDEST_INT value) | |
2525 { | |
2526 static const char *const op_part[] = {"L", "ML", "MH", "H"}; | |
2527 int i; | |
2528 | |
2529 if (! mmix_shiftable_wyde_value (value)) | |
2530 { | |
2531 char s[sizeof ("0xffffffffffffffff")]; | |
2532 sprintf (s, HOST_WIDEST_INT_PRINT_HEX, value); | |
2533 internal_error ("MMIX Internal: %s is not a shiftable int", s); | |
2534 } | |
2535 | |
2536 for (i = 0; i < 4; i++) | |
2537 { | |
2538 /* We know we're through when we find one-bits in the low | |
2539 16 bits. */ | |
2540 if (value & 0xffff) | |
2541 { | |
2542 fprintf (stream, "%s%s", mainop, op_part[i]); | |
2543 return; | |
2544 } | |
2545 value >>= 16; | |
2546 } | |
2547 | |
2548 /* No bits set? Then it must have been zero. */ | |
2549 fprintf (stream, "%sL", mainop); | |
2550 } | |
2551 | |
2552 /* Print a 64-bit value, optionally prefixed by assembly pseudo. */ | |
2553 | |
2554 static void | |
2555 mmix_output_octa (FILE *stream, HOST_WIDEST_INT value, int do_begin_end) | |
2556 { | |
2557 /* Snipped from final.c:output_addr_const. We need to avoid the | |
2558 presumed universal "0x" prefix. We can do it by replacing "0x" with | |
2559 "#0" here; we must avoid a space in the operands and no, the zero | |
2560 won't cause the number to be assumed in octal format. */ | |
2561 char hex_format[sizeof (HOST_WIDEST_INT_PRINT_HEX)]; | |
2562 | |
2563 if (do_begin_end) | |
2564 fprintf (stream, "\tOCTA "); | |
2565 | |
2566 strcpy (hex_format, HOST_WIDEST_INT_PRINT_HEX); | |
2567 hex_format[0] = '#'; | |
2568 hex_format[1] = '0'; | |
2569 | |
2570 /* Provide a few alternative output formats depending on the number, to | |
2571 improve legibility of assembler output. */ | |
2572 if ((value < (HOST_WIDEST_INT) 0 && value > (HOST_WIDEST_INT) -10000) | |
2573 || (value >= (HOST_WIDEST_INT) 0 && value <= (HOST_WIDEST_INT) 16384)) | |
2574 fprintf (stream, "%d", (int) value); | |
2575 else if (value > (HOST_WIDEST_INT) 0 | |
2576 && value < ((HOST_WIDEST_INT) 1 << 31) * 2) | |
2577 fprintf (stream, "#%x", (unsigned int) value); | |
2578 else | |
2579 fprintf (stream, hex_format, value); | |
2580 | |
2581 if (do_begin_end) | |
2582 fprintf (stream, "\n"); | |
2583 } | |
2584 | |
2585 /* Print the presumed shiftable wyde argument shifted into place (to | |
2586 be output with an operand). */ | |
2587 | |
2588 static void | |
2589 mmix_output_shifted_value (FILE *stream, HOST_WIDEST_INT value) | |
2590 { | |
2591 int i; | |
2592 | |
2593 if (! mmix_shiftable_wyde_value (value)) | |
2594 { | |
2595 char s[16+2+1]; | |
2596 sprintf (s, HOST_WIDEST_INT_PRINT_HEX, value); | |
2597 internal_error ("MMIX Internal: %s is not a shiftable int", s); | |
2598 } | |
2599 | |
2600 for (i = 0; i < 4; i++) | |
2601 { | |
2602 /* We know we're through when we find one-bits in the low 16 bits. */ | |
2603 if (value & 0xffff) | |
2604 { | |
2605 fprintf (stream, "#%x", (int) (value & 0xffff)); | |
2606 return; | |
2607 } | |
2608 | |
2609 value >>= 16; | |
2610 } | |
2611 | |
2612 /* No bits set? Then it must have been zero. */ | |
2613 fprintf (stream, "0"); | |
2614 } | |
2615 | |
2616 /* Output an MMIX condition name corresponding to an operator | |
2617 and operands: | |
2618 (comparison_operator [(comparison_operator ...) (const_int 0)]) | |
2619 which means we have to look at *two* operators. | |
2620 | |
2621 The argument "reversed" refers to reversal of the condition (not the | |
2622 same as swapping the arguments). */ | |
2623 | |
2624 static void | |
2625 mmix_output_condition (FILE *stream, rtx x, int reversed) | |
2626 { | |
2627 struct cc_conv | |
2628 { | |
2629 RTX_CODE cc; | |
2630 | |
2631 /* The normal output cc-code. */ | |
2632 const char *const normal; | |
2633 | |
2634 /* The reversed cc-code, or NULL if invalid. */ | |
2635 const char *const reversed; | |
2636 }; | |
2637 | |
2638 struct cc_type_conv | |
2639 { | |
2640 enum machine_mode cc_mode; | |
2641 | |
2642 /* Terminated with {UNKNOWN, NULL, NULL} */ | |
2643 const struct cc_conv *const convs; | |
2644 }; | |
2645 | |
2646 #undef CCEND | |
2647 #define CCEND {UNKNOWN, NULL, NULL} | |
2648 | |
2649 static const struct cc_conv cc_fun_convs[] | |
2650 = {{ORDERED, "Z", "P"}, | |
2651 {UNORDERED, "P", "Z"}, | |
2652 CCEND}; | |
2653 static const struct cc_conv cc_fp_convs[] | |
2654 = {{GT, "P", NULL}, | |
2655 {LT, "N", NULL}, | |
2656 CCEND}; | |
2657 static const struct cc_conv cc_fpeq_convs[] | |
2658 = {{NE, "Z", "P"}, | |
2659 {EQ, "P", "Z"}, | |
2660 CCEND}; | |
2661 static const struct cc_conv cc_uns_convs[] | |
2662 = {{GEU, "NN", "N"}, | |
2663 {GTU, "P", "NP"}, | |
2664 {LEU, "NP", "P"}, | |
2665 {LTU, "N", "NN"}, | |
2666 CCEND}; | |
2667 static const struct cc_conv cc_signed_convs[] | |
2668 = {{NE, "NZ", "Z"}, | |
2669 {EQ, "Z", "NZ"}, | |
2670 {GE, "NN", "N"}, | |
2671 {GT, "P", "NP"}, | |
2672 {LE, "NP", "P"}, | |
2673 {LT, "N", "NN"}, | |
2674 CCEND}; | |
2675 static const struct cc_conv cc_di_convs[] | |
2676 = {{NE, "NZ", "Z"}, | |
2677 {EQ, "Z", "NZ"}, | |
2678 {GE, "NN", "N"}, | |
2679 {GT, "P", "NP"}, | |
2680 {LE, "NP", "P"}, | |
2681 {LT, "N", "NN"}, | |
2682 {GTU, "NZ", "Z"}, | |
2683 {LEU, "Z", "NZ"}, | |
2684 CCEND}; | |
2685 #undef CCEND | |
2686 | |
2687 static const struct cc_type_conv cc_convs[] | |
2688 = {{CC_FUNmode, cc_fun_convs}, | |
2689 {CC_FPmode, cc_fp_convs}, | |
2690 {CC_FPEQmode, cc_fpeq_convs}, | |
2691 {CC_UNSmode, cc_uns_convs}, | |
2692 {CCmode, cc_signed_convs}, | |
2693 {DImode, cc_di_convs}}; | |
2694 | |
2695 size_t i; | |
2696 int j; | |
2697 | |
2698 enum machine_mode mode = GET_MODE (XEXP (x, 0)); | |
2699 RTX_CODE cc = GET_CODE (x); | |
2700 | |
2701 for (i = 0; i < ARRAY_SIZE (cc_convs); i++) | |
2702 { | |
2703 if (mode == cc_convs[i].cc_mode) | |
2704 { | |
2705 for (j = 0; cc_convs[i].convs[j].cc != UNKNOWN; j++) | |
2706 if (cc == cc_convs[i].convs[j].cc) | |
2707 { | |
2708 const char *mmix_cc | |
2709 = (reversed ? cc_convs[i].convs[j].reversed | |
2710 : cc_convs[i].convs[j].normal); | |
2711 | |
2712 if (mmix_cc == NULL) | |
2713 fatal_insn ("MMIX Internal: Trying to output invalidly\ | |
2714 reversed condition:", x); | |
2715 | |
2716 fprintf (stream, "%s", mmix_cc); | |
2717 return; | |
2718 } | |
2719 | |
2720 fatal_insn ("MMIX Internal: What's the CC of this?", x); | |
2721 } | |
2722 } | |
2723 | |
2724 fatal_insn ("MMIX Internal: What is the CC of this?", x); | |
2725 } | |
2726 | |
2727 /* Return the bit-value for a const_int or const_double. */ | |
2728 | |
2729 static HOST_WIDEST_INT | |
2730 mmix_intval (rtx x) | |
2731 { | |
2732 unsigned HOST_WIDEST_INT retval; | |
2733 | |
2734 if (GET_CODE (x) == CONST_INT) | |
2735 return INTVAL (x); | |
2736 | |
2737 /* We make a little song and dance because converting to long long in | |
2738 gcc-2.7.2 is broken. I still want people to be able to use it for | |
2739 cross-compilation to MMIX. */ | |
2740 if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) == VOIDmode) | |
2741 { | |
2742 if (sizeof (HOST_WIDE_INT) < sizeof (HOST_WIDEST_INT)) | |
2743 { | |
2744 retval = (unsigned) CONST_DOUBLE_LOW (x) / 2; | |
2745 retval *= 2; | |
2746 retval |= CONST_DOUBLE_LOW (x) & 1; | |
2747 | |
2748 retval |= | |
2749 (unsigned HOST_WIDEST_INT) CONST_DOUBLE_HIGH (x) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
2750 << (HOST_BITS_PER_LONG)/2 << (HOST_BITS_PER_LONG)/2; |
0 | 2751 } |
2752 else | |
2753 retval = CONST_DOUBLE_HIGH (x); | |
2754 | |
2755 return retval; | |
2756 } | |
2757 | |
2758 if (GET_CODE (x) == CONST_DOUBLE) | |
2759 { | |
2760 REAL_VALUE_TYPE value; | |
2761 | |
2762 /* FIXME: This macro is not in the manual but should be. */ | |
2763 REAL_VALUE_FROM_CONST_DOUBLE (value, x); | |
2764 | |
2765 if (GET_MODE (x) == DFmode) | |
2766 { | |
2767 long bits[2]; | |
2768 | |
2769 REAL_VALUE_TO_TARGET_DOUBLE (value, bits); | |
2770 | |
2771 /* The double cast is necessary to avoid getting the long | |
2772 sign-extended to unsigned long long(!) when they're of | |
2773 different size (usually 32-bit hosts). */ | |
2774 return | |
2775 ((unsigned HOST_WIDEST_INT) (unsigned long) bits[0] | |
2776 << (unsigned HOST_WIDEST_INT) 32U) | |
2777 | (unsigned HOST_WIDEST_INT) (unsigned long) bits[1]; | |
2778 } | |
2779 else if (GET_MODE (x) == SFmode) | |
2780 { | |
2781 long bits; | |
2782 REAL_VALUE_TO_TARGET_SINGLE (value, bits); | |
2783 | |
2784 return (unsigned long) bits; | |
2785 } | |
2786 } | |
2787 | |
2788 fatal_insn ("MMIX Internal: This is not a constant:", x); | |
2789 } | |
2790 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2791 /* Worker function for TARGET_PROMOTE_FUNCTION_MODE. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2792 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2793 enum machine_mode |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2794 mmix_promote_function_mode (const_tree type ATTRIBUTE_UNUSED, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2795 enum machine_mode mode, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2796 int *punsignedp ATTRIBUTE_UNUSED, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2797 const_tree fntype ATTRIBUTE_UNUSED, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2798 int for_return) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2799 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2800 /* Apparently not doing TRT if int < register-size. FIXME: Perhaps |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2801 FUNCTION_VALUE and LIBCALL_VALUE needs tweaking as some ports say. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2802 if (for_return == 1) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2803 return mode; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2804 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2805 /* Promotion of modes currently generates slow code, extending before |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2806 operation, so we do it only for arguments. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2807 if (GET_MODE_CLASS (mode) == MODE_INT |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2808 && GET_MODE_SIZE (mode) < 8) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2809 return DImode; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2810 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2811 return mode; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2812 } |
0 | 2813 /* Worker function for TARGET_STRUCT_VALUE_RTX. */ |
2814 | |
2815 static rtx | |
2816 mmix_struct_value_rtx (tree fntype ATTRIBUTE_UNUSED, | |
2817 int incoming ATTRIBUTE_UNUSED) | |
2818 { | |
2819 return gen_rtx_REG (Pmode, MMIX_STRUCT_VALUE_REGNUM); | |
2820 } | |
2821 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2822 /* Worker function for TARGET_FRAME_POINTER_REQUIRED. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2823 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2824 FIXME: Is this requirement built-in? Anyway, we should try to get rid |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2825 of it; we can deduce the value. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2826 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2827 bool |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2828 mmix_frame_pointer_required (void) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2829 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2830 return (cfun->has_nonlocal_label); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2831 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2832 |
0 | 2833 /* |
2834 * Local variables: | |
2835 * eval: (c-set-style "gnu") | |
2836 * indent-tabs-mode: t | |
2837 * End: | |
2838 */ |