xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/common/config/s390/s390-common.c (revision d909946ca08dceb44d7d0f22ec9488679695d976)
1 /* Common hooks for IBM S/390 and zSeries.
2    Copyright (C) 1999-2013 Free Software Foundation, Inc.
3 
4 This file is part of GCC.
5 
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
10 
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3.  If not see
18 <http://www.gnu.org/licenses/>.  */
19 
20 #include "config.h"
21 #include "system.h"
22 #include "coretypes.h"
23 #include "diagnostic-core.h"
24 #include "tm.h"
25 #include "common/common-target.h"
26 #include "common/common-target-def.h"
27 #include "opts.h"
28 #include "flags.h"
29 
30 EXPORTED_CONST int processor_flags_table[] =
31   {
32     /* g5 */     PF_IEEE_FLOAT,
33     /* g6 */     PF_IEEE_FLOAT,
34     /* z900 */   PF_IEEE_FLOAT | PF_ZARCH,
35     /* z990 */   PF_IEEE_FLOAT | PF_ZARCH | PF_LONG_DISPLACEMENT,
36     /* z9-109 */ PF_IEEE_FLOAT | PF_ZARCH | PF_LONG_DISPLACEMENT
37                  | PF_EXTIMM,
38     /* z9-ec */  PF_IEEE_FLOAT | PF_ZARCH | PF_LONG_DISPLACEMENT
39                  | PF_EXTIMM | PF_DFP,
40     /* z10 */    PF_IEEE_FLOAT | PF_ZARCH | PF_LONG_DISPLACEMENT
41                  | PF_EXTIMM | PF_DFP | PF_Z10,
42     /* z196 */   PF_IEEE_FLOAT | PF_ZARCH | PF_LONG_DISPLACEMENT
43                  | PF_EXTIMM | PF_DFP | PF_Z10 | PF_Z196,
44     /* zEC12 */  PF_IEEE_FLOAT | PF_ZARCH | PF_LONG_DISPLACEMENT
45                  | PF_EXTIMM | PF_DFP | PF_Z10 | PF_Z196 | PF_ZEC12 | PF_TX
46   };
47 
48 /* Change optimizations to be performed, depending on the
49    optimization level.  */
50 
51 static const struct default_options s390_option_optimization_table[] =
52   {
53     { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
54 
55     /* Enable -fsched-pressure by default when optimizing.  */
56     { OPT_LEVELS_1_PLUS, OPT_fsched_pressure, NULL, 1 },
57 
58     /* ??? There are apparently still problems with -fcaller-saves.  */
59     { OPT_LEVELS_ALL, OPT_fcaller_saves, NULL, 0 },
60 
61     /* Use MVCLE instructions to decrease code size if requested.  */
62     { OPT_LEVELS_SIZE, OPT_mmvcle, NULL, 1 },
63 
64     { OPT_LEVELS_NONE, 0, NULL, 0 }
65   };
66 
67 /* Implement TARGET_OPTION_INIT_STRUCT.  */
68 
69 static void
70 s390_option_init_struct (struct gcc_options *opts)
71 {
72   /* By default, always emit DWARF-2 unwind info.  This allows debugging
73      without maintaining a stack frame back-chain.  */
74   opts->x_flag_asynchronous_unwind_tables = 1;
75 }
76 
77 /* Implement TARGET_HANDLE_OPTION.  */
78 
79 static bool
80 s390_handle_option (struct gcc_options *opts,
81 		    struct gcc_options *opts_set ATTRIBUTE_UNUSED,
82   		    const struct cl_decoded_option *decoded,
83 		    location_t loc)
84 {
85   size_t code = decoded->opt_index;
86   const char *arg = decoded->arg;
87   int value = decoded->value;
88 
89   switch (code)
90     {
91     case OPT_march_:
92       opts->x_s390_arch_flags = processor_flags_table[value];
93       opts->x_s390_arch_string = arg;
94       return true;
95 
96     case OPT_mstack_guard_:
97       if (exact_log2 (value) == -1)
98 	error_at (loc, "stack guard value must be an exact power of 2");
99       return true;
100 
101     case OPT_mstack_size_:
102       if (exact_log2 (value) == -1)
103 	error_at (loc, "stack size must be an exact power of 2");
104       return true;
105 
106     case OPT_mtune_:
107       opts->x_s390_tune_flags = processor_flags_table[value];
108       return true;
109 
110     case OPT_mwarn_framesize_:
111       return sscanf (arg, HOST_WIDE_INT_PRINT_DEC,
112 		     &opts->x_s390_warn_framesize) == 1;
113 
114     default:
115       return true;
116     }
117 }
118 
119 #undef TARGET_DEFAULT_TARGET_FLAGS
120 #define TARGET_DEFAULT_TARGET_FLAGS (TARGET_DEFAULT)
121 
122 #undef TARGET_HANDLE_OPTION
123 #define TARGET_HANDLE_OPTION s390_handle_option
124 
125 #undef TARGET_OPTION_OPTIMIZATION_TABLE
126 #define TARGET_OPTION_OPTIMIZATION_TABLE s390_option_optimization_table
127 
128 #undef TARGET_OPTION_INIT_STRUCT
129 #define TARGET_OPTION_INIT_STRUCT s390_option_init_struct
130 
131 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
132