comparison gcc/config/spu/spu-c.c @ 55:77e2b8dfacca gcc-4.4.5

update it from 4.4.3 to 4.5.0
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Fri, 12 Feb 2010 23:39:51 +0900
parents 58ad6c70ea60
children b7f97abdc517
comparison
equal deleted inserted replaced
52:c156f1bd5cd9 55:77e2b8dfacca
1 /* Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. 1 /* Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
2 2
3 This file is free software; you can redistribute it and/or modify it under 3 This file is free software; you can redistribute it and/or modify it under
4 the terms of the GNU General Public License as published by the Free 4 the terms of the GNU General Public License as published by the Free
5 Software Foundation; either version 3 of the License, or (at your option) 5 Software Foundation; either version 3 of the License, or (at your option)
6 any later version. 6 any later version.
23 #include "c-tree.h" 23 #include "c-tree.h"
24 #include "c-pragma.h" 24 #include "c-pragma.h"
25 #include "function.h" 25 #include "function.h"
26 #include "rtl.h" 26 #include "rtl.h"
27 #include "expr.h" 27 #include "expr.h"
28 #include "errors.h"
29 #include "tm_p.h" 28 #include "tm_p.h"
30 #include "langhooks.h" 29 #include "langhooks.h"
31 #include "insn-config.h" 30 #include "insn-config.h"
32 #include "insn-codes.h" 31 #include "insn-codes.h"
33 #include "recog.h" 32 #include "recog.h"
41 static cpp_hashnode * 40 static cpp_hashnode *
42 spu_categorize_keyword (const cpp_token *tok) 41 spu_categorize_keyword (const cpp_token *tok)
43 { 42 {
44 if (tok->type == CPP_NAME) 43 if (tok->type == CPP_NAME)
45 { 44 {
46 cpp_hashnode *ident = tok->val.node; 45 cpp_hashnode *ident = tok->val.node.node;
47 46
48 if (ident == C_CPP_HASHNODE (vector_keyword) 47 if (ident == C_CPP_HASHNODE (vector_keyword)
49 || ident == C_CPP_HASHNODE (__vector_keyword)) 48 || ident == C_CPP_HASHNODE (__vector_keyword))
50 return C_CPP_HASHNODE (__vector_keyword); 49 return C_CPP_HASHNODE (__vector_keyword);
51 else 50 else
59 need to examine the 'tok' parameter. */ 58 need to examine the 'tok' parameter. */
60 59
61 static cpp_hashnode * 60 static cpp_hashnode *
62 spu_macro_to_expand (cpp_reader *pfile, const cpp_token *tok) 61 spu_macro_to_expand (cpp_reader *pfile, const cpp_token *tok)
63 { 62 {
64 cpp_hashnode *expand_this = tok->val.node; 63 cpp_hashnode *expand_this = tok->val.node.node;
65 cpp_hashnode *ident; 64 cpp_hashnode *ident;
66 65
67 ident = spu_categorize_keyword (tok); 66 ident = spu_categorize_keyword (tok);
68 if (ident == C_CPP_HASHNODE (__vector_keyword)) 67 if (ident == C_CPP_HASHNODE (__vector_keyword))
69 { 68 {
93 } 92 }
94 93
95 /* target hook for resolve_overloaded_builtin(). Returns a function call 94 /* target hook for resolve_overloaded_builtin(). Returns a function call
96 RTX if we can resolve the overloaded builtin */ 95 RTX if we can resolve the overloaded builtin */
97 tree 96 tree
98 spu_resolve_overloaded_builtin (tree fndecl, tree fnargs) 97 spu_resolve_overloaded_builtin (location_t loc, tree fndecl, void *passed_args)
99 { 98 {
100 #define SCALAR_TYPE_P(t) (INTEGRAL_TYPE_P (t) \ 99 #define SCALAR_TYPE_P(t) (INTEGRAL_TYPE_P (t) \
101 || SCALAR_FLOAT_TYPE_P (t) \ 100 || SCALAR_FLOAT_TYPE_P (t) \
102 || POINTER_TYPE_P (t)) 101 || POINTER_TYPE_P (t))
102 VEC(tree,gc) *fnargs = (VEC(tree,gc) *) passed_args;
103 unsigned int nargs = VEC_length (tree, fnargs);
103 int new_fcode, fcode = DECL_FUNCTION_CODE (fndecl) - END_BUILTINS; 104 int new_fcode, fcode = DECL_FUNCTION_CODE (fndecl) - END_BUILTINS;
104 struct spu_builtin_description *desc; 105 struct spu_builtin_description *desc;
105 tree match = NULL_TREE; 106 tree match = NULL_TREE;
106 107
107 /* The vector types are not available if the backend is not initialized. */ 108 /* The vector types are not available if the backend is not initialized. */
117 for (new_fcode = fcode + 1; spu_builtins[new_fcode].type == B_INTERNAL; 118 for (new_fcode = fcode + 1; spu_builtins[new_fcode].type == B_INTERNAL;
118 new_fcode++) 119 new_fcode++)
119 { 120 {
120 tree decl = spu_builtins[new_fcode].fndecl; 121 tree decl = spu_builtins[new_fcode].fndecl;
121 tree params = TYPE_ARG_TYPES (TREE_TYPE (decl)); 122 tree params = TYPE_ARG_TYPES (TREE_TYPE (decl));
122 tree arg, param; 123 tree param;
123 bool all_scalar; 124 bool all_scalar;
124 int p; 125 unsigned int p;
125 126
126 /* Check whether all parameters are scalar. */ 127 /* Check whether all parameters are scalar. */
127 all_scalar = true; 128 all_scalar = true;
128 for (param = params; param != void_list_node; param = TREE_CHAIN (param)) 129 for (param = params; param != void_list_node; param = TREE_CHAIN (param))
129 if (!SCALAR_TYPE_P (TREE_VALUE (param))) 130 if (!SCALAR_TYPE_P (TREE_VALUE (param)))
130 all_scalar = false; 131 all_scalar = false;
131 132
132 for (param = params, arg = fnargs, p = 0; 133 for (param = params, p = 0;
133 param != void_list_node; 134 param != void_list_node;
134 param = TREE_CHAIN (param), arg = TREE_CHAIN (arg), p++) 135 param = TREE_CHAIN (param), p++)
135 { 136 {
136 tree var, arg_type, param_type = TREE_VALUE (param); 137 tree var, arg_type, param_type = TREE_VALUE (param);
137 138
138 if (!arg) 139 if (p >= nargs)
139 { 140 {
140 error ("insufficient arguments to overloaded function %s", 141 error ("insufficient arguments to overloaded function %s",
141 desc->name); 142 desc->name);
142 return error_mark_node; 143 return error_mark_node;
143 } 144 }
144 145
145 var = TREE_VALUE (arg); 146 var = VEC_index (tree, fnargs, p);
146 147
147 if (TREE_CODE (var) == NON_LVALUE_EXPR) 148 if (TREE_CODE (var) == NON_LVALUE_EXPR)
148 var = TREE_OPERAND (var, 0); 149 var = TREE_OPERAND (var, 0);
149 150
150 if (TREE_CODE (var) == ERROR_MARK) 151 if (TREE_CODE (var) == ERROR_MARK)
165 TYPE_MAIN_VARIANT (arg_type))) 166 TYPE_MAIN_VARIANT (arg_type)))
166 break; 167 break;
167 } 168 }
168 if (param == void_list_node) 169 if (param == void_list_node)
169 { 170 {
170 if (arg) 171 if (p != nargs)
171 { 172 {
172 error ("too many arguments to overloaded function %s", 173 error ("too many arguments to overloaded function %s",
173 desc->name); 174 desc->name);
174 return error_mark_node; 175 return error_mark_node;
175 } 176 }
184 error ("parameter list does not match a valid signature for %s()", 185 error ("parameter list does not match a valid signature for %s()",
185 desc->name); 186 desc->name);
186 return error_mark_node; 187 return error_mark_node;
187 } 188 }
188 189
189 return build_function_call (match, fnargs); 190 return build_function_call_vec (loc, match, fnargs, NULL);
190 #undef SCALAR_TYPE_P 191 #undef SCALAR_TYPE_P
191 } 192 }
192 193
193 194
194 void 195 void
198 cpp_assert (pfile, "cpu=spu"); 199 cpp_assert (pfile, "cpu=spu");
199 cpp_assert (pfile, "machine=spu"); 200 cpp_assert (pfile, "machine=spu");
200 if (spu_arch == PROCESSOR_CELLEDP) 201 if (spu_arch == PROCESSOR_CELLEDP)
201 builtin_define_std ("__SPU_EDP__"); 202 builtin_define_std ("__SPU_EDP__");
202 builtin_define_std ("__vector=__attribute__((__spu_vector__))"); 203 builtin_define_std ("__vector=__attribute__((__spu_vector__))");
204 switch (spu_ea_model)
205 {
206 case 32:
207 builtin_define_std ("__EA32__");
208 break;
209 case 64:
210 builtin_define_std ("__EA64__");
211 break;
212 default:
213 gcc_unreachable ();
214 }
203 215
204 if (!flag_iso) 216 if (!flag_iso)
205 { 217 {
206 /* Define this when supporting context-sensitive keywords. */ 218 /* Define this when supporting context-sensitive keywords. */
207 cpp_define (pfile, "__VECTOR_KEYWORD_SUPPORTED__"); 219 cpp_define (pfile, "__VECTOR_KEYWORD_SUPPORTED__");