]>
Commit | Line | Data |
---|---|---|
3dcdeeb2 | 1 | /* go-backend.c -- Go frontend interface to gcc backend. |
3dac68b9 | 2 | Copyright (C) 2010, 2011 Free Software Foundation, Inc. |
3dcdeeb2 ILT |
3 | |
4 | This file is part of GCC. | |
5 | ||
6 | GCC is free software; you can redistribute it and/or modify it under | |
7 | the terms of the GNU General Public License as published by the Free | |
8 | Software Foundation; either version 3, or (at your option) any later | |
9 | version. | |
10 | ||
11 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 | for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GCC; see the file COPYING3. If not see | |
18 | <http://www.gnu.org/licenses/>. */ | |
19 | ||
20 | #include "config.h" | |
21 | #include "system.h" | |
22 | #include "coretypes.h" | |
3dcdeeb2 | 23 | #include "tm.h" |
3dac68b9 ILT |
24 | #include "rtl.h" |
25 | #include "tree.h" | |
3dcdeeb2 | 26 | #include "tm_p.h" |
3dac68b9 | 27 | #include "target.h" |
3dcdeeb2 ILT |
28 | |
29 | #include "go-c.h" | |
30 | ||
31 | /* This file holds all the cases where the Go frontend needs | |
32 | information from gcc's backend. */ | |
33 | ||
34 | /* Return the alignment in bytes of a value of type T. */ | |
35 | ||
36 | unsigned int | |
37 | go_type_alignment (tree t) | |
38 | { | |
39 | return TYPE_ALIGN_UNIT (t); | |
40 | } | |
41 | ||
42 | /* Return the alignment in bytes of a struct field of type T. */ | |
43 | ||
44 | unsigned int | |
45 | go_field_alignment (tree t) | |
46 | { | |
47 | unsigned int v; | |
48 | ||
49 | v = TYPE_ALIGN (t); | |
50 | ||
51 | #ifdef BIGGEST_FIELD_ALIGNMENT | |
52 | if (v > BIGGEST_FIELD_ALIGNMENT) | |
53 | v = BIGGEST_FIELD_ALIGNMENT; | |
54 | #endif | |
55 | ||
56 | #ifdef ADJUST_FIELD_ALIGN | |
57 | { | |
efdfdfa7 | 58 | tree field ATTRIBUTE_UNUSED; |
3dcdeeb2 ILT |
59 | field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL, t); |
60 | v = ADJUST_FIELD_ALIGN (field, v); | |
61 | } | |
62 | #endif | |
63 | ||
64 | return v / BITS_PER_UNIT; | |
65 | } | |
66 | ||
67 | /* Return the size and alignment of a trampoline. */ | |
68 | ||
69 | void | |
70 | go_trampoline_info (unsigned int *size, unsigned int *alignment) | |
71 | { | |
72 | *size = TRAMPOLINE_SIZE; | |
73 | *alignment = TRAMPOLINE_ALIGNMENT; | |
74 | } | |
3dac68b9 ILT |
75 | |
76 | /* This is called by the Go frontend proper if the unsafe package was | |
77 | imported. When that happens we can not do type-based alias | |
78 | analysis. */ | |
79 | ||
80 | void | |
81 | go_imported_unsafe (void) | |
82 | { | |
83 | flag_strict_aliasing = false; | |
84 | ||
85 | /* This is a real hack. init_varasm_once has already grabbed an | |
86 | alias set, which we don't want when we aren't doing strict | |
87 | aliasing. We reinitialize to make it do it again. This should | |
88 | be OK in practice since we haven't really done anything yet. */ | |
89 | init_varasm_once (); | |
90 | ||
91 | /* Let the backend know that the options have changed. */ | |
92 | targetm.override_options_after_change (); | |
93 | } |