i960.h (i960_maxbitalignment, [...]): Declare.
[gcc.git] / gcc / config / i960 / i960-c.c
1 /* Intel 80960 specific, C compiler specific functions.
2 Copyright (C) 1992, 1995, 1996, 1997, 1998, 1999, 2000
3 Free Software Foundation, Inc.
4 Contributed by Steven McGeady, Intel Corp.
5 Additional Work by Glenn Colon-Bonet, Jonathan Shapiro, Andy Wilson
6 Converted to GCC 2.0 by Jim Wilson and Michael Tiemann, Cygnus Support.
7
8 This file is part of GNU CC.
9
10 GNU CC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
14
15 GNU CC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with GNU CC; see the file COPYING. If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
24
25 #include "config.h"
26 #include "system.h"
27 #include "cpplib.h"
28 #include "tree.h"
29 #include "c-pragma.h"
30 #include "c-lex.h"
31 #include "toplev.h"
32 #include "ggc.h"
33 #include "tm_p.h"
34
35 /* Handle pragmas for compatibility with Intel's compilers. */
36
37 /* NOTE: ic960 R3.0 pragma align definition:
38
39 #pragma align [(size)] | (identifier=size[,...])
40 #pragma noalign [(identifier)[,...]]
41
42 (all parens are optional)
43
44 - size is [1,2,4,8,16]
45 - noalign means size==1
46 - applies only to component elements of a struct (and union?)
47 - identifier applies to structure tag (only)
48 - missing identifier means next struct
49
50 - alignment rules for bitfields need more investigation.
51
52 This implementation only handles the case of no identifiers. */
53
54 void
55 i960_pr_align (pfile)
56 cpp_reader *pfile ATTRIBUTE_UNUSED;
57 {
58 tree number;
59 enum cpp_ttype type;
60 int align;
61
62 type = c_lex (&number);
63 if (type == CPP_OPEN_PAREN)
64 type = c_lex (&number);
65 if (type == CPP_NAME)
66 {
67 warning ("sorry, not implemented: #pragma align NAME=SIZE");
68 return;
69 }
70 if (type != CPP_NUMBER)
71 {
72 warning ("malformed #pragma align - ignored");
73 return;
74 }
75
76 align = TREE_INT_CST_LOW (number);
77 switch (align)
78 {
79 case 0:
80 /* Return to last alignment. */
81 align = i960_last_maxbitalignment / 8;
82 /* Fall through. */
83 case 16:
84 case 8:
85 case 4:
86 case 2:
87 case 1:
88 i960_last_maxbitalignment = i960_maxbitalignment;
89 i960_maxbitalignment = align * 8;
90 break;
91
92 default:
93 /* Silently ignore bad values. */
94 break;
95 }
96 }
97
98 void
99 i960_pr_noalign (pfile)
100 cpp_reader *pfile ATTRIBUTE_UNUSED;
101 {
102 enum cpp_ttype type;
103 tree number;
104
105 type = c_lex (&number);
106 if (type == CPP_OPEN_PAREN)
107 type = c_lex (&number);
108 if (type == CPP_NAME)
109 {
110 warning ("sorry, not implemented: #pragma noalign NAME");
111 return;
112 }
113
114 i960_last_maxbitalignment = i960_maxbitalignment;
115 i960_maxbitalignment = 8;
116 }