OSDN Git Service

9ffe38a02fbd97016222e7eccb0201c5d97d38e3
[pf3gnuchains/gcc-fork.git] / gcc / go / go-backend.c
1 /* go-backend.c -- Go frontend interface to gcc backend.
2    Copyright (C) 2010 Free Software Foundation, Inc.
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"
23 #include "tree.h"
24 #include "tm.h"
25 #include "tm_p.h"
26
27 #include "go-c.h"
28
29 /* This file holds all the cases where the Go frontend needs
30    information from gcc's backend.  */
31
32 /* Return the alignment in bytes of a value of type T.  */
33
34 unsigned int
35 go_type_alignment (tree t)
36 {
37   return TYPE_ALIGN_UNIT (t);
38 }
39
40 /* Return the alignment in bytes of a struct field of type T.  */
41
42 unsigned int
43 go_field_alignment (tree t)
44 {
45   unsigned int v;
46
47   v = TYPE_ALIGN (t);
48
49 #ifdef BIGGEST_FIELD_ALIGNMENT
50   if (v > BIGGEST_FIELD_ALIGNMENT)
51     v = BIGGEST_FIELD_ALIGNMENT;
52 #endif
53
54 #ifdef ADJUST_FIELD_ALIGN
55   {
56     tree field ATTRIBUTE_UNUSED;
57     field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL, t);
58     v = ADJUST_FIELD_ALIGN (field, v);
59   }
60 #endif
61
62   return v / BITS_PER_UNIT;
63 }
64
65 /* Return the size and alignment of a trampoline.  */
66
67 void
68 go_trampoline_info (unsigned int *size, unsigned int *alignment)
69 {
70   *size = TRAMPOLINE_SIZE;
71   *alignment = TRAMPOLINE_ALIGNMENT;
72 }