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.  */
56typedef 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}
64print_switch_type;
65
66typedef int (* print_switch_fn_type) (print_switch_type, const char *);
67
68/* An example implementation for ELF targets.  Defined in varasm.c  */
69extern 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.  */
75extern bool target_default_pointer_address_modes_p (void);
76
77struct stdarg_info;
78struct spec_info_def;
79
80/* The struct used by the secondary_reload target hook.  */
81typedef 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 .  */
95struct _dep;
96
97/* This is defined in ddg.h .  */
98struct ddg;
99
100/* This is defined in cfgloop.h .  */
101struct loop;
102
103/* This is defined in tree-ssa-alias.h.  */
104struct ao_ref_s;
105
106/* Assembler instructions for creating various kinds of integer object.  */
107
108struct asm_int_op
109{
110  const char *hi;
111  const char *si;
112  const char *di;
113  const char *ti;
114};
115
116/* Types of costs for vectorizer cost model.  */
117enum vect_cost_for_stmt
118{
119  scalar_stmt,
120  scalar_load,
121  scalar_store,
122  vector_stmt,
123  vector_load,
124  unaligned_load,
125  unaligned_store,
126  vector_store,
127  vec_to_scalar,
128  scalar_to_vec,
129  cond_branch_not_taken,
130  cond_branch_taken,
131  vec_perm
132};
133
134/* Sets of optimization levels at which an option may be enabled by
135   default_options_optimization.  */
136enum opt_levels
137{
138  OPT_LEVELS_NONE, /* No levels (mark end of array).  */
139  OPT_LEVELS_ALL, /* All levels (used by targets to disable options
140		     enabled in target-independent code).  */
141  OPT_LEVELS_0_ONLY, /* -O0 only.  */
142  OPT_LEVELS_1_PLUS, /* -O1 and above, including -Os.  */
143  OPT_LEVELS_1_PLUS_SPEED_ONLY, /* -O1 and above, but not -Os.  */
144  OPT_LEVELS_2_PLUS, /* -O2 and above, including -Os.  */
145  OPT_LEVELS_2_PLUS_SPEED_ONLY, /* -O2 and above, but not -Os.  */
146  OPT_LEVELS_3_PLUS, /* -O3 and above.  */
147  OPT_LEVELS_3_PLUS_AND_SIZE, /* -O3 and above and -Os.  */
148  OPT_LEVELS_SIZE, /* -Os only.  */
149  OPT_LEVELS_FAST /* -Ofast only.  */
150};
151
152/* Description of options to enable by default at given levels.  */
153struct default_options
154{
155  /* The levels at which to enable the option.  */
156  enum opt_levels levels;
157
158  /* The option index and argument or enabled/disabled sense of the
159     option, as passed to handle_generated_option.  If ARG is NULL and
160     the option allows a negative form, the option is considered to be
161     passed in negative form when the optimization level is not one of
162     those in LEVELS (in order to handle changes to the optimization
163     level with the "optimize" attribute).  */
164  size_t opt_index;
165  const char *arg;
166  int value;
167};
168
169/* The target structure.  This holds all the backend hooks.  */
170#define DEFHOOKPOD(NAME, DOC, TYPE, INIT) TYPE NAME;
171#define DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT) TYPE (* NAME) PARAMS;
172#define DEFHOOK_UNDOC DEFHOOK
173#define HOOKSTRUCT(FRAGMENT) FRAGMENT
174
175#include "target.def"
176
177extern struct gcc_target targetm;
178
179/* Each target can provide their own.  */
180extern struct gcc_targetcm targetcm;
181
182#endif /* GCC_TARGET_H */
183