OSDN Git Service

2002-07-24 Aldy Hernandez <aldyh@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / rs6000-c.c
1 /* Subroutines for the C front end on the POWER and PowerPC architectures.
2    Copyright (C) 2002
3    Free Software Foundation, Inc.
4
5    Contributed by Zack Weinberg <zack@codesourcery.com>
6
7 This file is part of GNU CC.
8
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING.  If not, write to
21 the Free Software Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA.  */
23
24 #include "config.h"
25 #include "system.h"
26 #include "cpplib.h"
27 #include "tree.h"
28 #include "c-pragma.h"
29 #include "errors.h"
30 #include "tm_p.h"
31
32 /* Handle the machine specific pragma longcall.  Its syntax is
33
34    # pragma longcall ( TOGGLE )
35
36    where TOGGLE is either 0 or 1.
37
38    rs6000_default_long_calls is set to the value of TOGGLE, changing
39    whether or not new function declarations receive a longcall
40    attribute by default.  */
41
42 #define SYNTAX_ERROR(msgid) do {                                        \
43   warning (msgid);                                      \
44   warning ("ignoring malformed #pragma longcall");      \
45   return;                                               \
46 } while (0)
47
48 void
49 rs6000_pragma_longcall (pfile)
50      cpp_reader *pfile ATTRIBUTE_UNUSED;
51 {
52   tree x, n;
53
54   /* If we get here, generic code has already scanned the directive
55      leader and the word "longcall".  */
56
57   if (c_lex (&x) != CPP_OPEN_PAREN)
58     SYNTAX_ERROR ("missing open paren");
59   if (c_lex (&n) != CPP_NUMBER)
60     SYNTAX_ERROR ("missing number");
61   if (c_lex (&x) != CPP_CLOSE_PAREN)
62     SYNTAX_ERROR ("missing close paren");
63
64   if (n != integer_zero_node && n != integer_one_node)
65     SYNTAX_ERROR ("number must be 0 or 1");
66
67   if (c_lex (&x) != CPP_EOF)
68     warning ("junk at end of #pragma longcall");
69
70   rs6000_default_long_calls = (n == integer_one_node);
71 }
72
73 /* Handle defining many CPP flags based on TARGET_xxx.  As a general
74    policy, rather than trying to guess what flags a user might want a
75    #define for, it's better to define a flag for everything.  */
76
77 #define builtin_define(TXT) cpp_define (pfile, TXT)
78 #define builtin_assert(TXT) cpp_assert (pfile, TXT)
79
80 void
81 rs6000_cpu_cpp_builtins (pfile)
82      cpp_reader *pfile;
83 {
84   if (TARGET_POWER2)
85     builtin_define ("_ARCH_PWR2");
86   else if (TARGET_POWER)
87     builtin_define ("_ARCH_PWR");
88   if (TARGET_POWERPC)
89     builtin_define ("_ARCH_PPC");
90   if (TARGET_POWERPC64)
91     builtin_define ("_ARCH_PPC64");
92   if (! TARGET_POWER && ! TARGET_POWER2 && ! TARGET_POWERPC)
93     builtin_define ("_ARCH_COM");
94   if (TARGET_ALTIVEC)
95     builtin_define ("__ALTIVEC__");
96   if (TARGET_SPE)
97     builtin_define ("__SPE__");
98   if (TARGET_SOFT_FLOAT)
99     builtin_define ("_SOFT_FLOAT");
100   if (BYTES_BIG_ENDIAN)
101     {
102       builtin_define ("__BIG_ENDIAN__");
103       builtin_define ("_BIG_ENDIAN");
104       builtin_assert ("machine=bigendian");
105     }
106   else
107     {
108       builtin_define ("__LITTLE_ENDIAN__");
109       builtin_define ("_LITTLE_ENDIAN");
110       builtin_assert ("machine=littleendian");
111     }
112   if (TARGET_LONG_DOUBLE_128)
113     builtin_define ("__LONG_DOUBLE_128__");
114
115   switch (rs6000_current_abi)
116     {
117     case ABI_V4:
118       builtin_define ("_CALL_SYSV");
119       break;
120     case ABI_AIX_NODESC:
121       builtin_define ("_CALL_AIX");
122       break;
123     case ABI_AIX:
124       builtin_define ("_CALL_AIXDESC");
125       builtin_define ("_CALL_AIX");
126       break;
127     case ABI_DARWIN:
128       builtin_define ("_CALL_DARWIN");
129       break;
130     }
131 }