* dwarf2out.c (compare_loc_descriptor, scompare_loc_descriptor,
[official-gcc.git] / gcc / go / go-backend.c
blob60a97db7df4e295ce7f391d33c67d2897773bed1
1 /* go-backend.c -- Go frontend interface to gcc backend.
2 Copyright (C) 2010, 2011 Free Software Foundation, Inc.
4 This file is part of GCC.
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.
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.
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/>. */
20 #include "config.h"
21 #include "system.h"
22 #include "coretypes.h"
23 #include "tm.h"
24 #include "rtl.h"
25 #include "tree.h"
26 #include "tm_p.h"
27 #include "output.h"
28 #include "target.h"
30 #include "go-c.h"
32 /* This file holds all the cases where the Go frontend needs
33 information from gcc's backend. */
35 /* Return the alignment in bytes of a value of type T. */
37 unsigned int
38 go_type_alignment (tree t)
40 return TYPE_ALIGN_UNIT (t);
43 /* Return the alignment in bytes of a struct field of type T. */
45 unsigned int
46 go_field_alignment (tree t)
48 unsigned int v;
50 v = TYPE_ALIGN (t);
52 #ifdef BIGGEST_FIELD_ALIGNMENT
53 if (v > BIGGEST_FIELD_ALIGNMENT)
54 v = BIGGEST_FIELD_ALIGNMENT;
55 #endif
57 #ifdef ADJUST_FIELD_ALIGN
59 tree field ATTRIBUTE_UNUSED;
60 field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL, t);
61 v = ADJUST_FIELD_ALIGN (field, v);
63 #endif
65 return v / BITS_PER_UNIT;
68 /* Return the size and alignment of a trampoline. */
70 void
71 go_trampoline_info (unsigned int *size, unsigned int *alignment)
73 *size = TRAMPOLINE_SIZE;
74 *alignment = TRAMPOLINE_ALIGNMENT;
77 /* This is called by the Go frontend proper if the unsafe package was
78 imported. When that happens we can not do type-based alias
79 analysis. */
81 void
82 go_imported_unsafe (void)
84 flag_strict_aliasing = false;
86 /* This is a real hack. init_varasm_once has already grabbed an
87 alias set, which we don't want when we aren't doing strict
88 aliasing. We reinitialize to make it do it again. This should
89 be OK in practice since we haven't really done anything yet. */
90 init_varasm_once ();
92 /* Let the backend know that the options have changed. */
93 targetm.override_options_after_change ();
96 /* This is called by the Go frontend proper to add data to the
97 .go_export section. */
99 void
100 go_write_export_data (const char *bytes, unsigned int size)
102 static section* sec;
104 if (sec == NULL)
106 gcc_assert (targetm.have_named_sections);
107 sec = get_section (".go_export", SECTION_DEBUG, NULL);
110 switch_to_section (sec);
111 assemble_string (bytes, size);