Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/mmix/mmix.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Definitions of target machine for GNU compiler, for MMIX. | 1 /* Definitions of target machine for GNU compiler, for MMIX. |
2 Copyright (C) 2000-2017 Free Software Foundation, Inc. | 2 Copyright (C) 2000-2018 Free Software Foundation, Inc. |
3 Contributed by Hans-Peter Nilsson (hp@bitrange.com) | 3 Contributed by Hans-Peter Nilsson (hp@bitrange.com) |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify | 7 GCC is free software; you can redistribute it and/or modify |
15 GNU General Public License for more details. | 15 GNU General Public License for more details. |
16 | 16 |
17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
18 along with GCC; see the file COPYING3. If not see | 18 along with GCC; see the file COPYING3. If not see |
19 <http://www.gnu.org/licenses/>. */ | 19 <http://www.gnu.org/licenses/>. */ |
20 | |
21 #define IN_TARGET_CODE 1 | |
20 | 22 |
21 #include "config.h" | 23 #include "config.h" |
22 #include "system.h" | 24 #include "system.h" |
23 #include "coretypes.h" | 25 #include "coretypes.h" |
24 #include "backend.h" | 26 #include "backend.h" |
29 #include "attribs.h" | 31 #include "attribs.h" |
30 #include "df.h" | 32 #include "df.h" |
31 #include "memmodel.h" | 33 #include "memmodel.h" |
32 #include "tm_p.h" | 34 #include "tm_p.h" |
33 #include "insn-config.h" | 35 #include "insn-config.h" |
36 #include "optabs.h" | |
34 #include "regs.h" | 37 #include "regs.h" |
35 #include "emit-rtl.h" | 38 #include "emit-rtl.h" |
36 #include "recog.h" | 39 #include "recog.h" |
37 #include "diagnostic-core.h" | 40 #include "diagnostic-core.h" |
38 #include "output.h" | 41 #include "output.h" |
56 mostly. */ | 59 mostly. */ |
57 #define MMIX_CFUN_HAS_LANDING_PAD (cfun->machine->has_landing_pad != 0) | 60 #define MMIX_CFUN_HAS_LANDING_PAD (cfun->machine->has_landing_pad != 0) |
58 | 61 |
59 /* We have no means to tell DWARF 2 about the register stack, so we need | 62 /* We have no means to tell DWARF 2 about the register stack, so we need |
60 to store the return address on the stack if an exception can get into | 63 to store the return address on the stack if an exception can get into |
61 this function. FIXME: Narrow condition. Before any whole-function | 64 this function. We'll have an "initial value" recorded for the |
62 analysis, df_regs_ever_live_p () isn't initialized. We know it's up-to-date | 65 return-register if we've seen a call instruction emitted. This note |
63 after reload_completed; it may contain incorrect information some time | 66 will be inaccurate before instructions are emitted, but the only caller |
64 before that. Within a RTL sequence (after a call to start_sequence, | 67 at that time is looking for modulo from stack-boundary, to which the |
65 such as in RTL expanders), leaf_function_p doesn't see all insns | 68 return-address does not contribute, and which is always 0 for MMIX |
66 (perhaps any insn). But regs_ever_live is up-to-date when | 69 anyway. Beware of calling leaf_function_p here, as it'll abort if |
67 leaf_function_p () isn't, so we "or" them together to get accurate | 70 called within a sequence. */ |
68 information. FIXME: Some tweak to leaf_function_p might be | |
69 preferable. */ | |
70 #define MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS \ | 71 #define MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS \ |
71 (flag_exceptions \ | 72 (flag_exceptions \ |
72 && ((reload_completed && df_regs_ever_live_p (MMIX_rJ_REGNUM)) \ | 73 && has_hard_reg_initial_val (Pmode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM)) |
73 || !leaf_function_p ())) | |
74 | 74 |
75 #define IS_MMIX_EH_RETURN_DATA_REG(REGNO) \ | 75 #define IS_MMIX_EH_RETURN_DATA_REG(REGNO) \ |
76 (crtl->calls_eh_return \ | 76 (crtl->calls_eh_return \ |
77 && (EH_RETURN_DATA_REGNO (0) == REGNO \ | 77 && (EH_RETURN_DATA_REGNO (0) == REGNO \ |
78 || EH_RETURN_DATA_REGNO (1) == REGNO \ | 78 || EH_RETURN_DATA_REGNO (1) == REGNO \ |
139 (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree); | 139 (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree); |
140 static void mmix_setup_incoming_varargs | 140 static void mmix_setup_incoming_varargs |
141 (cumulative_args_t, machine_mode, tree, int *, int); | 141 (cumulative_args_t, machine_mode, tree, int *, int); |
142 static void mmix_file_start (void); | 142 static void mmix_file_start (void); |
143 static void mmix_file_end (void); | 143 static void mmix_file_end (void); |
144 static void mmix_init_libfuncs (void); | |
144 static bool mmix_rtx_costs (rtx, machine_mode, int, int, int *, bool); | 145 static bool mmix_rtx_costs (rtx, machine_mode, int, int, int *, bool); |
145 static int mmix_register_move_cost (machine_mode, | 146 static int mmix_register_move_cost (machine_mode, |
146 reg_class_t, reg_class_t); | 147 reg_class_t, reg_class_t); |
147 static rtx mmix_struct_value_rtx (tree, int); | 148 static rtx mmix_struct_value_rtx (tree, int); |
148 static machine_mode mmix_promote_function_mode (const_tree, | 149 static machine_mode mmix_promote_function_mode (const_tree, |
220 #undef TARGET_ASM_FILE_END | 221 #undef TARGET_ASM_FILE_END |
221 #define TARGET_ASM_FILE_END mmix_file_end | 222 #define TARGET_ASM_FILE_END mmix_file_end |
222 #undef TARGET_ASM_OUTPUT_SOURCE_FILENAME | 223 #undef TARGET_ASM_OUTPUT_SOURCE_FILENAME |
223 #define TARGET_ASM_OUTPUT_SOURCE_FILENAME mmix_asm_output_source_filename | 224 #define TARGET_ASM_OUTPUT_SOURCE_FILENAME mmix_asm_output_source_filename |
224 | 225 |
226 #undef TARGET_INIT_LIBFUNCS | |
227 #define TARGET_INIT_LIBFUNCS mmix_init_libfuncs | |
228 | |
225 #undef TARGET_CONDITIONAL_REGISTER_USAGE | 229 #undef TARGET_CONDITIONAL_REGISTER_USAGE |
226 #define TARGET_CONDITIONAL_REGISTER_USAGE mmix_conditional_register_usage | 230 #define TARGET_CONDITIONAL_REGISTER_USAGE mmix_conditional_register_usage |
231 | |
232 #undef TARGET_HAVE_SPECULATION_SAFE_VALUE | |
233 #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed | |
227 | 234 |
228 #undef TARGET_RTX_COSTS | 235 #undef TARGET_RTX_COSTS |
229 #define TARGET_RTX_COSTS mmix_rtx_costs | 236 #define TARGET_RTX_COSTS mmix_rtx_costs |
230 #undef TARGET_ADDRESS_COST | 237 #undef TARGET_ADDRESS_COST |
231 #define TARGET_ADDRESS_COST hook_int_rtx_mode_as_bool_0 | 238 #define TARGET_ADDRESS_COST hook_int_rtx_mode_as_bool_0 |
1302 mmix_asm_output_source_filename (FILE *stream, const char *name) | 1309 mmix_asm_output_source_filename (FILE *stream, const char *name) |
1303 { | 1310 { |
1304 fprintf (stream, "# 1 "); | 1311 fprintf (stream, "# 1 "); |
1305 OUTPUT_QUOTED_STRING (stream, name); | 1312 OUTPUT_QUOTED_STRING (stream, name); |
1306 fprintf (stream, "\n"); | 1313 fprintf (stream, "\n"); |
1314 } | |
1315 | |
1316 /* Unfortunately, by default __builtin_ffs is expanded to ffs for | |
1317 targets where INT_TYPE_SIZE < BITS_PER_WORD. That together with | |
1318 newlib since 2017-07-04 implementing ffs as __builtin_ffs leads to | |
1319 (newlib) ffs recursively calling itself. But, because of argument | |
1320 promotion, and with ffs we're counting from the least bit, the | |
1321 libgcc equivalent for ffsl works equally well for int arguments, so | |
1322 just use that. */ | |
1323 | |
1324 static void | |
1325 mmix_init_libfuncs (void) | |
1326 { | |
1327 set_optab_libfunc (ffs_optab, SImode, "__ffsdi2"); | |
1307 } | 1328 } |
1308 | 1329 |
1309 /* OUTPUT_QUOTED_STRING. */ | 1330 /* OUTPUT_QUOTED_STRING. */ |
1310 | 1331 |
1311 void | 1332 void |
1369 keep as much compatibility as possible with mmixal syntax for | 1390 keep as much compatibility as possible with mmixal syntax for |
1370 normal cases (i.e. without GNU extensions and C only). */ | 1391 normal cases (i.e. without GNU extensions and C only). */ |
1371 case 1: | 1392 case 1: |
1372 if (GET_CODE (x) != CONST_INT) | 1393 if (GET_CODE (x) != CONST_INT) |
1373 { | 1394 { |
1374 aligned_p = 0; | 1395 /* There is no "unaligned byte" op or generic function to |
1375 break; | 1396 which we can punt, so we have to handle this here. As |
1397 the expression isn't a plain literal, the generated | |
1398 assembly-code can't be mmixal-equivalent (i.e. "BYTE" | |
1399 won't work) and thus it's ok to emit the default op | |
1400 ".byte". */ | |
1401 assemble_integer_with_op ("\t.byte\t", x); | |
1402 return true; | |
1376 } | 1403 } |
1377 fputs ("\tBYTE\t", asm_out_file); | 1404 fputs ("\tBYTE\t", asm_out_file); |
1378 mmix_print_operand (asm_out_file, x, 'B'); | 1405 mmix_print_operand (asm_out_file, x, 'B'); |
1379 fputc ('\n', asm_out_file); | 1406 fputc ('\n', asm_out_file); |
1380 return true; | 1407 return true; |