* pt.c (lookup_template_class_1): Splice out abi_tag attribute if
[official-gcc.git] / gcc / config / vxworks.c
blobbd5e735bf1474f9886db7c467ee6b079e38f5530
1 /* Common VxWorks target definitions for GNU compiler.
2 Copyright (C) 2007-2014 Free Software Foundation, Inc.
3 Contributed by CodeSourcery, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "target.h"
25 #include "diagnostic-core.h"
26 #include "output.h"
27 #include "tm.h"
28 #include "tree.h"
29 #include "stringpool.h"
31 /* Like default_named_section_asm_out_constructor, except that even
32 constructors with DEFAULT_INIT_PRIORITY must go in a numbered
33 section on VxWorks. The VxWorks runtime uses a clever trick to get
34 the sentinel entry (-1) inserted at the beginning of the .ctors
35 segment. This trick will not work if we ever generate any entries
36 in plain .ctors sections; we must always use .ctors.PRIORITY. */
38 void
39 vxworks_asm_out_constructor (rtx symbol, int priority)
41 section *sec;
43 sec = get_cdtor_priority_section (priority,
44 /*constructor_p=*/true);
45 assemble_addr_to_section (symbol, sec);
48 /* See comment for vxworks_asm_out_constructor. */
50 void
51 vxworks_asm_out_destructor (rtx symbol, int priority)
53 section *sec;
55 sec = get_cdtor_priority_section (priority,
56 /*constructor_p=*/false);
57 assemble_addr_to_section (symbol, sec);
60 /* Return the list of FIELD_DECLs that make up an emulated TLS
61 variable's control object. TYPE is the structure these are fields
62 of and *NAME will be filled in with the structure tag that should
63 be used. */
65 static tree
66 vxworks_emutls_var_fields (tree type, tree *name)
68 tree field, next_field;
70 *name = get_identifier ("__tls_var");
72 field = build_decl (BUILTINS_LOCATION, FIELD_DECL,
73 get_identifier ("size"), unsigned_type_node);
74 DECL_CONTEXT (field) = type;
75 next_field = field;
77 field = build_decl (BUILTINS_LOCATION, FIELD_DECL,
78 get_identifier ("module_id"), unsigned_type_node);
79 DECL_CONTEXT (field) = type;
80 DECL_CHAIN (field) = next_field;
81 next_field = field;
83 field = build_decl (BUILTINS_LOCATION, FIELD_DECL,
84 get_identifier ("offset"), unsigned_type_node);
85 DECL_CONTEXT (field) = type;
86 DECL_CHAIN (field) = next_field;
88 return field;
91 /* Return the CONSTRUCTOR to initialize an emulated TLS control
92 object. VAR is the control object. DECL is the TLS object itself
93 and TMPL_ADDR is the address (an ADDR_EXPR) of the initializer for
94 that object. */
96 static tree
97 vxworks_emutls_var_init (tree var, tree decl, tree tmpl_addr)
99 vec<constructor_elt, va_gc> *v;
100 vec_alloc (v, 3);
102 tree type = TREE_TYPE (var);
103 tree field = TYPE_FIELDS (type);
105 constructor_elt elt = {field, fold_convert (TREE_TYPE (field), tmpl_addr)};
106 v->quick_push (elt);
108 field = DECL_CHAIN (field);
109 elt.index = field;
110 elt.value = build_int_cst (TREE_TYPE (field), 0);
111 v->quick_push (elt);
113 field = DECL_CHAIN (field);
114 elt.index = field;
115 elt.value = fold_convert (TREE_TYPE (field), DECL_SIZE_UNIT (decl));
116 v->quick_push (elt);
118 return build_constructor (type, v);
121 /* Do VxWorks-specific parts of TARGET_OPTION_OVERRIDE. */
123 void
124 vxworks_override_options (void)
126 /* We don't support __thread via target hooks. */
127 targetm.have_tls = false;
129 targetm.emutls.get_address = "__builtin___tls_lookup";
130 targetm.emutls.register_common = NULL;
131 targetm.emutls.var_section = ".tls_vars";
132 targetm.emutls.tmpl_section = ".tls_data";
133 targetm.emutls.var_prefix = "__tls__";
134 targetm.emutls.tmpl_prefix = "";
135 targetm.emutls.var_fields = vxworks_emutls_var_fields;
136 targetm.emutls.var_init = vxworks_emutls_var_init;
137 targetm.emutls.var_align_fixed = true;
138 targetm.emutls.debug_form_tls_address = true;
140 /* We can use .ctors/.dtors sections only in RTP mode. */
141 targetm.have_ctors_dtors = TARGET_VXWORKS_RTP;
143 /* PIC is only supported for RTPs. */
144 if (flag_pic && !TARGET_VXWORKS_RTP)
145 error ("PIC is only supported for RTPs");
147 /* Default to strict dwarf-2 to prevent potential difficulties observed with
148 non-gdb debuggers on extensions > 2. */
149 if (!global_options_set.x_dwarf_strict)
150 dwarf_strict = 1;
152 if (!global_options_set.x_dwarf_version)
153 dwarf_version = 2;