OSDN Git Service

gcc:
[pf3gnuchains/gcc-fork.git] / gcc / target.h
1 /* Data structure definitions for a generic GCC target.
2    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3    Free Software Foundation, Inc.
4
5    This program is free software; you can redistribute it and/or modify it
6    under the terms of the GNU General Public License as published by the
7    Free Software Foundation; either version 3, or (at your option) any
8    later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; see the file COPYING3.  If not see
17    <http://www.gnu.org/licenses/>.
18
19    In other words, you are welcome to use, share and improve this program.
20    You are forbidden to forbid anyone else to use, share and improve
21    what you give them.   Help stamp out software-hoarding!  */
22
23
24 /* This file contains a data structure that describes a GCC target.
25    At present it is incomplete, but in future it should grow to
26    contain most or all target machine and target O/S specific
27    information.
28
29    This structure has its initializer declared in target-def.h in the
30    form of large macro TARGET_INITIALIZER that expands to many smaller
31    macros.
32
33    The smaller macros each initialize one component of the structure,
34    and each has a default.  Each target should have a file that
35    includes target.h and target-def.h, and overrides any inappropriate
36    defaults by undefining the relevant macro and defining a suitable
37    replacement.  That file should then contain the definition of
38    "targetm" like so:
39
40    struct gcc_target targetm = TARGET_INITIALIZER;
41
42    Doing things this way allows us to bring together everything that
43    defines a GCC target.  By supplying a default that is appropriate
44    to most targets, we can easily add new items without needing to
45    edit dozens of target configuration files.  It should also allow us
46    to gradually reduce the amount of conditional compilation that is
47    scattered throughout GCC.  */
48
49 #ifndef GCC_TARGET_H
50 #define GCC_TARGET_H
51
52 #include "tm.h"
53 #include "insn-modes.h"
54
55 /* Types used by the record_gcc_switches() target function.  */
56 typedef enum
57 {
58   SWITCH_TYPE_PASSED,           /* A switch passed on the command line.  */
59   SWITCH_TYPE_ENABLED,          /* An option that is currently enabled.  */
60   SWITCH_TYPE_DESCRIPTIVE,      /* Descriptive text, not a switch or option.  */
61   SWITCH_TYPE_LINE_START,       /* Please emit any necessary text at the start of a line.  */
62   SWITCH_TYPE_LINE_END          /* Please emit a line terminator.  */
63 }
64 print_switch_type;
65
66 typedef int (* print_switch_fn_type) (print_switch_type, const char *);
67
68 /* An example implementation for ELF targets.  Defined in varasm.c  */
69 extern int elf_record_gcc_switches (print_switch_type type, const char *);
70
71 /* Some places still assume that all pointer or address modes are the
72    standard Pmode and ptr_mode.  These optimizations become invalid if
73    the target actually supports multiple different modes.  For now,
74    we disable such optimizations on such targets, using this function.  */
75 extern bool target_default_pointer_address_modes_p (void);
76
77 struct stdarg_info;
78 struct spec_info_def;
79
80 /* The struct used by the secondary_reload target hook.  */
81 typedef struct secondary_reload_info
82 {
83   /* icode is actually an enum insn_code, but we don't want to force every
84      file that includes target.h to include optabs.h .  */
85   int icode;
86   int extra_cost; /* Cost for using (a) scratch register(s) to be taken
87                      into account by copy_cost.  */
88   /* The next two members are for the use of the backward
89      compatibility hook.  */
90   struct secondary_reload_info *prev_sri;
91   int t_icode; /* Actually an enum insn_code - see above.  */
92 } secondary_reload_info;
93
94 /* This is defined in sched-int.h .  */
95 struct _dep;
96
97 /* This is defined in ddg.h .  */
98 struct ddg;
99
100 /* This is defined in cfgloop.h .  */
101 struct loop;
102
103 /* Assembler instructions for creating various kinds of integer object.  */
104
105 struct asm_int_op
106 {
107   const char *hi;
108   const char *si;
109   const char *di;
110   const char *ti;
111 };
112
113 /* Types of costs for vectorizer cost model.  */
114 enum vect_cost_for_stmt
115 {
116   scalar_stmt,
117   scalar_load,
118   scalar_store,
119   vector_stmt,
120   vector_load,
121   unaligned_load,
122   unaligned_store,
123   vector_store,
124   vec_to_scalar,
125   scalar_to_vec,
126   cond_branch_not_taken,
127   cond_branch_taken,
128   vec_perm
129 };
130
131 /* Sets of optimization levels at which an option may be enabled by
132    default_options_optimization.  */
133 enum opt_levels
134 {
135   OPT_LEVELS_NONE, /* No levels (mark end of array).  */
136   OPT_LEVELS_ALL, /* All levels (used by targets to disable options
137                      enabled in target-independent code).  */
138   OPT_LEVELS_0_ONLY, /* -O0 only.  */
139   OPT_LEVELS_1_PLUS, /* -O1 and above, including -Os.  */
140   OPT_LEVELS_1_PLUS_SPEED_ONLY, /* -O1 and above, but not -Os.  */
141   OPT_LEVELS_2_PLUS, /* -O2 and above, including -Os.  */
142   OPT_LEVELS_2_PLUS_SPEED_ONLY, /* -O2 and above, but not -Os.  */
143   OPT_LEVELS_3_PLUS, /* -O3 and above.  */
144   OPT_LEVELS_3_PLUS_AND_SIZE, /* -O3 and above and -Os.  */
145   OPT_LEVELS_SIZE, /* -Os only.  */
146   OPT_LEVELS_FAST /* -Ofast only.  */
147 };
148
149 /* Description of options to enable by default at given levels.  */
150 struct default_options
151 {
152   /* The levels at which to enable the option.  */
153   enum opt_levels levels;
154
155   /* The option index and argument or enabled/disabled sense of the
156      option, as passed to handle_generated_option.  If ARG is NULL and
157      the option allows a negative form, the option is considered to be
158      passed in negative form when the optimization level is not one of
159      those in LEVELS (in order to handle changes to the optimization
160      level with the "optimize" attribute).  */
161   size_t opt_index;
162   const char *arg;
163   int value;
164 };
165
166 /* The target structure.  This holds all the backend hooks.  */
167 #define DEFHOOKPOD(NAME, DOC, TYPE, INIT) TYPE NAME;
168 #define DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT) TYPE (* NAME) PARAMS;
169 #define DEFHOOK_UNDOC DEFHOOK
170 #define HOOKSTRUCT(FRAGMENT) FRAGMENT
171
172 #include "target.def"
173
174 extern struct gcc_target targetm;
175
176 /* Each target can provide their own.  */
177 extern struct gcc_targetcm targetcm;
178
179 #endif /* GCC_TARGET_H */