target.h revision 96263
1139825Simp/* Data structure definitions for a generic GCC target.
286227Stmm   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
3128776Stmm
4167308SmariusThis program is free software; you can redistribute it and/or modify it
5128776Stmmunder the terms of the GNU General Public License as published by the
686227StmmFree Software Foundation; either version 2, or (at your option) any
786227Stmmlater version.
886227Stmm
986227StmmThis program is distributed in the hope that it will be useful,
1086227Stmmbut WITHOUT ANY WARRANTY; without even the implied warranty of
1186227StmmMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1286227StmmGNU General Public License for more details.
1386227Stmm
1486227StmmYou should have received a copy of the GNU General Public License
1586227Stmmalong with this program; if not, write to the Free Software
1686227StmmFoundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1786227Stmm
18128776Stmm In other words, you are welcome to use, share and improve this program.
1986227Stmm You are forbidden to forbid anyone else to use, share and improve
2086227Stmm what you give them.   Help stamp out software-hoarding!  */
2186227Stmm
2286227Stmm/* This file contains a data structure that describes a GCC target.
2386227Stmm   At present it is incomplete, but in future it should grow to
2486227Stmm   contain most or all target machine and target O/S specific
2586227Stmm   information.
2686227Stmm
2786227Stmm   This structure has its initializer declared in target-def.h in the
2886227Stmm   form of large macro TARGET_INITIALIZER that expands to many smaller
2986227Stmm   macros.
3086227Stmm
3186227Stmm   The smaller macros each initialize one component of the structure,
3286227Stmm   and each has a default.  Each target should have a file that
3386227Stmm   includes target.h and target-def.h, and overrides any inappropriate
3486227Stmm   defaults by undefining the relevant macro and defining a suitable
35146474Smarius   replacement.  That file should then contain the definition of
36146474Smarius   "targetm" like so:
37146474Smarius
3886227Stmm   struct gcc_target targetm = TARGET_INITIALIZER;
3986227Stmm
4086227Stmm   Doing things this way allows us to bring together everything that
4186227Stmm   defines a GCC target.  By supplying a default that is appropriate
4286227Stmm   to most targets, we can easily add new items without needing to
43130068Sphk   edit dozens of target configuration files.  It should also allow us
4486227Stmm   to gradually reduce the amount of conditional compilation that is
45167308Smarius   scattered throughout GCC.  */
46167308Smarius
4786227Stmmstruct gcc_target
4886227Stmm{
4986227Stmm  /* Functions that output assembler for the target.  */
50167308Smarius  struct asm_out
5186227Stmm  {
52167308Smarius    /* Opening and closing parentheses for asm expression grouping.  */
5386227Stmm    const char *open_paren, *close_paren;
54167308Smarius
5586227Stmm    /* Assembler instructions for creating various kinds of integer object.  */
5686227Stmm    const char *byte_op;
5786227Stmm    struct asm_int_op
5886227Stmm    {
5986227Stmm      const char *hi;
60133862Smarius      const char *si;
6186227Stmm      const char *di;
62128776Stmm      const char *ti;
6386227Stmm    } aligned_op, unaligned_op;
6486227Stmm
6586227Stmm    /* Try to output the assembler code for an integer object whose
6686227Stmm       value is given by X.  SIZE is the size of the object in bytes and
6786227Stmm       ALIGNED_P indicates whether it is aligned.  Return true if
68133862Smarius       successful.  Only handles cases for which BYTE_OP, ALIGNED_OP
6986227Stmm       and UNALIGNED_OP are NULL.  */
7086227Stmm    bool (* integer) PARAMS ((rtx x, unsigned int size, int aligned_p));
7186227Stmm
72167308Smarius    /* Output the assembler code for entry to a function.  */
73167308Smarius    void (* function_prologue) PARAMS ((FILE *, HOST_WIDE_INT));
7486227Stmm
7586227Stmm    /* Output the assembler code for end of prologue.  */
7688823Stmm    void (* function_end_prologue) PARAMS ((FILE *));
7788823Stmm
7888823Stmm    /* Output the assembler code for start of epilogue.  */
7988823Stmm    void (* function_begin_epilogue) PARAMS ((FILE *));
8088823Stmm
81128776Stmm    /* Output the assembler code for function exit.  */
82128776Stmm    void (* function_epilogue) PARAMS ((FILE *, HOST_WIDE_INT));
83167308Smarius
84146474Smarius    /* Switch to an arbitrary section NAME with attributes as
85128776Stmm       specified by FLAGS.  */
86128776Stmm    void (* named_section) PARAMS ((const char *, unsigned int));
87128776Stmm
88128776Stmm    /* Switch to the section that holds the exception table.  */
89128776Stmm    void (* exception_section) PARAMS ((void));
90128776Stmm
91128776Stmm    /* Switch to the section that holds the exception frames.  */
92167308Smarius    void (* eh_frame_section) PARAMS ((void));
93200948Smarius
94200948Smarius    /* Output a constructor for a symbol with a given priority.  */
95200948Smarius    void (* constructor) PARAMS ((rtx, int));
96200948Smarius
97167308Smarius    /* Output a destructor for a symbol with a given priority.  */
98167308Smarius    void (* destructor) PARAMS ((rtx, int));
9986227Stmm  } asm_out;
100185133Smarius
101167308Smarius  /* Functions relating to instruction scheduling.  */
102167308Smarius  struct sched
103167308Smarius  {
104167308Smarius    /* Given the current cost, COST, of an insn, INSN, calculate and
10586227Stmm       return a new cost based on its relationship to DEP_INSN through
10686227Stmm       the dependence LINK.  The default is to make no adjustment.  */
10786227Stmm    int (* adjust_cost) PARAMS ((rtx insn, rtx link, rtx def_insn, int cost));
108128776Stmm
10986227Stmm    /* Adjust the priority of an insn as you see fit.  Returns the new
11086227Stmm       priority.  */
11186227Stmm    int (* adjust_priority) PARAMS ((rtx, int));
11286227Stmm
11386227Stmm    /* Function which returns the maximum number of insns that can be
114167308Smarius       scheduled in the same machine cycle.  This must be constant
115167308Smarius       over an entire compilation.  The default is 1.  */
116167308Smarius    int (* issue_rate) PARAMS ((void));
117167308Smarius
118167308Smarius    /* Calculate how much this insn affects how many more insns we
119146474Smarius       can emit this cycle.  Default is they all cost the same.  */
12086227Stmm    int (* variable_issue) PARAMS ((FILE *, int, rtx, int));
12186227Stmm
12286227Stmm    /* Initialize machine-dependent scheduling code.  */
12386227Stmm    void (* md_init) PARAMS ((FILE *, int, int));
124167308Smarius
125167308Smarius    /* Finalize machine-dependent scheduling code.  */
126190099Smarius    void (* md_finish) PARAMS ((FILE *, int));
127190099Smarius
128190099Smarius    /* Reorder insns in a machine-dependent fashion, in two different
129178443Smarius       places.  Default does nothing.  */
130178443Smarius    int (* reorder)  PARAMS ((FILE *, int, rtx *, int *, int));
131178443Smarius    int (* reorder2) PARAMS ((FILE *, int, rtx *, int *, int));
132200948Smarius
133167308Smarius    /* cycle_display is a pointer to a function which can emit
13486227Stmm       data into the assembly stream about the current cycle.
135167308Smarius       Arguments are CLOCK, the data to emit, and LAST, the last
136167308Smarius       insn in the new chain we're building.  Returns a new LAST.
137167308Smarius       The default is to do nothing.  */
138167308Smarius    rtx (* cycle_display) PARAMS ((int clock, rtx last));
139167308Smarius  } sched;
140167308Smarius
141167308Smarius  /* Given two decls, merge their attributes and return the result.  */
142167308Smarius  tree (* merge_decl_attributes) PARAMS ((tree, tree));
143190099Smarius
14486227Stmm  /* Given two types, merge their attributes and return the result.  */
14586227Stmm  tree (* merge_type_attributes) PARAMS ((tree, tree));
14686227Stmm
14786227Stmm  /* Table of machine attributes and functions to handle them.  */
148167308Smarius  const struct attribute_spec *attribute_table;
149200874Smarius
150200874Smarius  /* Return zero if the attributes on TYPE1 and TYPE2 are incompatible,
151200815Smarius     one if they are compatible and two if they are nearly compatible
15286227Stmm     (which causes a warning to be generated).  */
153185133Smarius  int (* comp_type_attributes) PARAMS ((tree type1, tree type2));
15490622Stmm
155167308Smarius  /* Assign default attributes to the newly defined TYPE.  */
15690622Stmm  void (* set_default_type_attributes) PARAMS ((tree type));
15790622Stmm
15886227Stmm  /* Insert attributes on the newly created DECL.  */
15990622Stmm  void (* insert_attributes) PARAMS ((tree decl, tree *attributes));
16086227Stmm
16186227Stmm  /* Return true if FNDECL (which has at least one machine attribute)
162167308Smarius     can be inlined despite its machine attributes, false otherwise.  */
16390622Stmm  bool (* function_attribute_inlinable_p) PARAMS ((tree fndecl));
16486227Stmm
16586227Stmm  /* Return true if bitfields in RECORD_TYPE should follow the
16686227Stmm     Microsoft Visual C++ bitfield layout rules.  */
167185133Smarius  bool (* ms_bitfield_layout_p) PARAMS ((tree record_type));
16886227Stmm
16986227Stmm  /* Set up target-specific built-in functions.  */
17086227Stmm  void (* init_builtins) PARAMS ((void));
17186227Stmm
17286227Stmm  /* Expand a target-specific builtin.  */
17386227Stmm  rtx (* expand_builtin) PARAMS ((tree exp, rtx target, rtx subtarget,
17486227Stmm				  enum machine_mode mode, int ignore));
17586227Stmm
176185133Smarius  /* Given a decl, a section name, and whether the decl initializer
17786227Stmm     has relocs, choose attributes for the section.  */
17886227Stmm  /* ??? Should be merged with SELECT_SECTION and UNIQUE_SECTION.  */
17986227Stmm  unsigned int (* section_type_flags) PARAMS ((tree, const char *, int));
180167308Smarius
181167308Smarius  /* True if arbitrary sections are supported.  */
18286227Stmm  bool have_named_sections;
18386227Stmm
18486227Stmm  /* True if "native" constructors and destructors are supported,
18586227Stmm     false if we're using collect2 for the job.  */
18686227Stmm  bool have_ctors_dtors;
18786227Stmm
18886227Stmm  /* True if new jumps cannot be created, to replace existing ones or
18986227Stmm     not, at the current point in the compilation.  */
19086227Stmm  bool (* cannot_modify_jumps_p) PARAMS ((void));
19186227Stmm};
19286227Stmm
19386227Stmmextern struct gcc_target targetm;
19486227Stmm