Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/vxworks.c @ 0:a06113de4d67
first commit
author | kent <kent@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 17 Jul 2009 14:47:48 +0900 |
parents | |
children | f6334be47118 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a06113de4d67 |
---|---|
1 /* Common VxWorks target definitions for GNU compiler. | |
2 Copyright (C) 2007, 2008 | |
3 Free Software Foundation, Inc. | |
4 Contributed by CodeSourcery, Inc. | |
5 | |
6 This file is part of GCC. | |
7 | |
8 GCC is free software; you can redistribute it and/or modify it under | |
9 the terms of the GNU General Public License as published by the Free | |
10 Software Foundation; either version 3, or (at your option) any later | |
11 version. | |
12 | |
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with GCC; see the file COPYING3. If not see | |
20 <http://www.gnu.org/licenses/>. */ | |
21 | |
22 #include "config.h" | |
23 #include "system.h" | |
24 #include "coretypes.h" | |
25 #include "target.h" | |
26 #include "toplev.h" | |
27 #include "output.h" | |
28 #include "tm.h" | |
29 #include "tree.h" | |
30 | |
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. */ | |
37 | |
38 void | |
39 vxworks_asm_out_constructor (rtx symbol, int priority) | |
40 { | |
41 section *sec; | |
42 | |
43 sec = get_cdtor_priority_section (priority, | |
44 /*constructor_p=*/true); | |
45 assemble_addr_to_section (symbol, sec); | |
46 } | |
47 | |
48 /* See comment for vxworks_asm_out_constructor. */ | |
49 | |
50 void | |
51 vxworks_asm_out_destructor (rtx symbol, int priority) | |
52 { | |
53 section *sec; | |
54 | |
55 sec = get_cdtor_priority_section (priority, | |
56 /*constructor_p=*/false); | |
57 assemble_addr_to_section (symbol, sec); | |
58 } | |
59 | |
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. */ | |
64 | |
65 static tree | |
66 vxworks_emutls_var_fields (tree type, tree *name) | |
67 { | |
68 tree field, next_field; | |
69 | |
70 *name = get_identifier ("__tls_var"); | |
71 | |
72 field = build_decl (FIELD_DECL, get_identifier ("size"), | |
73 unsigned_type_node); | |
74 DECL_CONTEXT (field) = type; | |
75 next_field = field; | |
76 | |
77 field = build_decl (FIELD_DECL, get_identifier ("module_id"), | |
78 unsigned_type_node); | |
79 DECL_CONTEXT (field) = type; | |
80 TREE_CHAIN (field) = next_field; | |
81 next_field = field; | |
82 | |
83 field = build_decl (FIELD_DECL, get_identifier ("offset"), | |
84 unsigned_type_node); | |
85 DECL_CONTEXT (field) = type; | |
86 TREE_CHAIN (field) = next_field; | |
87 | |
88 return field; | |
89 } | |
90 | |
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. */ | |
95 | |
96 static tree | |
97 vxworks_emutls_var_init (tree var, tree decl, tree tmpl_addr) | |
98 { | |
99 VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, 3); | |
100 constructor_elt *elt; | |
101 | |
102 tree type = TREE_TYPE (var); | |
103 tree field = TYPE_FIELDS (type); | |
104 | |
105 elt = VEC_quick_push (constructor_elt, v, NULL); | |
106 elt->index = field; | |
107 elt->value = fold_convert (TREE_TYPE (field), tmpl_addr); | |
108 | |
109 elt = VEC_quick_push (constructor_elt, v, NULL); | |
110 field = TREE_CHAIN (field); | |
111 elt->index = field; | |
112 elt->value = build_int_cst (TREE_TYPE (field), 0); | |
113 | |
114 elt = VEC_quick_push (constructor_elt, v, NULL); | |
115 field = TREE_CHAIN (field); | |
116 elt->index = field; | |
117 elt->value = fold_convert (TREE_TYPE (field), DECL_SIZE_UNIT (decl)); | |
118 | |
119 return build_constructor (type, v); | |
120 } | |
121 | |
122 /* Do VxWorks-specific parts of OVERRIDE_OPTIONS. */ | |
123 | |
124 void | |
125 vxworks_override_options (void) | |
126 { | |
127 /* We don't support __thread via target hooks. */ | |
128 targetm.have_tls = false; | |
129 | |
130 targetm.emutls.get_address = "__builtin___tls_lookup"; | |
131 targetm.emutls.register_common = NULL; | |
132 targetm.emutls.var_section = ".tls_vars"; | |
133 targetm.emutls.tmpl_section = ".tls_data"; | |
134 targetm.emutls.var_prefix = "__tls__"; | |
135 targetm.emutls.tmpl_prefix = ""; | |
136 targetm.emutls.var_fields = vxworks_emutls_var_fields; | |
137 targetm.emutls.var_init = vxworks_emutls_var_init; | |
138 targetm.emutls.var_align_fixed = true; | |
139 targetm.emutls.debug_form_tls_address = true; | |
140 | |
141 /* We can use .ctors/.dtors sections only in RTP mode. */ | |
142 targetm.have_ctors_dtors = TARGET_VXWORKS_RTP; | |
143 | |
144 /* PIC is only supported for RTPs. */ | |
145 if (flag_pic && !TARGET_VXWORKS_RTP) | |
146 error ("PIC is only supported for RTPs"); | |
147 } |