Commit b8ce4e94 by Kai Tietz Committed by Kai Tietz

re PR target/9601 (-mrtd switch/stdcall attribute raises warnings for __buitltin functions)

2011-04-11  Kai Tietz  <ktietz@redhat.com>

	PR target/9601
	PR target/11772
	* config/i386/i386-protos.h (ix86_get_callcvt): New prototype.
	* config/i386/i386.c (ix86_handle_cconv_attribute): Adjust
	comment.
	(ix86_is_msabi_thiscall): Removed.
	(ix86_is_type_thiscall): Likewise.
	(ix86_get_callcvt): New function.
	(ix86_comp_type_attributes): Simplify check.
	(ix86_function_regparm): Use ix86_get_callcvt for calling
	convention attribute checks.
	(ix86_return_pops_args): Likewise.
	(ix86_static_chain): Likewise.
	(x86_this_parameter): Likewise.
	(x86_output_mi_thunk): Likewise.
	(ix86_function_type_abi): Optimize check for types without attributes.
	* config/i386/i386.h (IX86_CALLCVT_CDECL, IX86_CALLCVT_STDCALL,
	IX86_CALLCVT_FASTCALL, IX86_CALLCVT_THISCALL, IX86_CALLCVT_REGPARM,
	IX86_CALLCVT_SSEREGPARM): New macros to represent calling convention
	by flag-values.
	(IX86_BASE_CALLCVT): Helper macro.
	* config/i386/netware.c (i386_nlm_maybe_mangle_decl_assembler_name):
	Use ix86_get_callcvt for calling convention attribute checks and avoid
	symbol-decoration for stdcall in TARGET_RTD case.
	* config/i386/winnt.c (i386_pe_maybe_mangle_decl_assembler_name):
	Likewise.
	(gen_stdcall_or_fastcall_suffix): Adjust ident and use DECL_ORIGIN
	for declaration.

From-SVN: r172268
parent a1b01a84
2011-04-11 Kai Tietz <ktietz@redhat.com>
PR target/9601
PR target/11772
* config/i386/i386-protos.h (ix86_get_callcvt): New prototype.
* config/i386/i386.c (ix86_handle_cconv_attribute): Adjust
comment.
(ix86_is_msabi_thiscall): Removed.
(ix86_is_type_thiscall): Likewise.
(ix86_get_callcvt): New function.
(ix86_comp_type_attributes): Simplify check.
(ix86_function_regparm): Use ix86_get_callcvt for calling
convention attribute checks.
(ix86_return_pops_args): Likewise.
(ix86_static_chain): Likewise.
(x86_this_parameter): Likewise.
(x86_output_mi_thunk): Likewise.
(ix86_function_type_abi): Optimize check for types without attributes.
* config/i386/i386.h (IX86_CALLCVT_CDECL, IX86_CALLCVT_STDCALL,
IX86_CALLCVT_FASTCALL, IX86_CALLCVT_THISCALL, IX86_CALLCVT_REGPARM,
IX86_CALLCVT_SSEREGPARM): New macros to represent calling convention
by flag-values.
(IX86_BASE_CALLCVT): Helper macro.
* config/i386/netware.c (i386_nlm_maybe_mangle_decl_assembler_name):
Use ix86_get_callcvt for calling convention attribute checks and avoid
symbol-decoration for stdcall in TARGET_RTD case.
* config/i386/winnt.c (i386_pe_maybe_mangle_decl_assembler_name):
Likewise.
(gen_stdcall_or_fastcall_suffix): Adjust ident and use DECL_ORIGIN
for declaration.
2011-04-11 Uros Bizjak <ubizjak@gmail.com> 2011-04-11 Uros Bizjak <ubizjak@gmail.com>
* config/i386/sse.md (VI_128): New mode iterator. * config/i386/sse.md (VI_128): New mode iterator.
......
...@@ -191,6 +191,8 @@ extern tree ix86_handle_shared_attribute (tree *, tree, tree, int, bool *); ...@@ -191,6 +191,8 @@ extern tree ix86_handle_shared_attribute (tree *, tree, tree, int, bool *);
extern tree ix86_handle_selectany_attribute (tree *, tree, tree, int, bool *); extern tree ix86_handle_selectany_attribute (tree *, tree, tree, int, bool *);
extern int x86_field_alignment (tree, int); extern int x86_field_alignment (tree, int);
extern tree ix86_valid_target_attribute_tree (tree); extern tree ix86_valid_target_attribute_tree (tree);
extern unsigned int ix86_get_callcvt (const_tree);
#endif #endif
extern rtx ix86_tls_get_addr (void); extern rtx ix86_tls_get_addr (void);
......
...@@ -2368,6 +2368,18 @@ extern void debug_dispatch_window (int); ...@@ -2368,6 +2368,18 @@ extern void debug_dispatch_window (int);
((VALUE) = GET_MODE_BITSIZE (MODE), TARGET_BMI) ((VALUE) = GET_MODE_BITSIZE (MODE), TARGET_BMI)
/* Flags returned by ix86_get_callcvt (). */
#define IX86_CALLCVT_CDECL 0x1
#define IX86_CALLCVT_STDCALL 0x2
#define IX86_CALLCVT_FASTCALL 0x4
#define IX86_CALLCVT_THISCALL 0x8
#define IX86_CALLCVT_REGPARM 0x10
#define IX86_CALLCVT_SSEREGPARM 0x20
#define IX86_BASE_CALLCVT(FLAGS) \
((FLAGS) & (IX86_CALLCVT_CDECL | IX86_CALLCVT_STDCALL \
| IX86_CALLCVT_FASTCALL | IX86_CALLCVT_THISCALL))
/* /*
Local variables: Local variables:
version-control: t version-control: t
......
...@@ -148,12 +148,20 @@ i386_nlm_maybe_mangle_decl_assembler_name (tree decl, tree id) ...@@ -148,12 +148,20 @@ i386_nlm_maybe_mangle_decl_assembler_name (tree decl, tree id)
{ {
tree type_attributes = TYPE_ATTRIBUTES (TREE_TYPE (decl)); tree type_attributes = TYPE_ATTRIBUTES (TREE_TYPE (decl));
tree new_id; tree new_id;
unsigned int ccvt = ix86_get_callcvt (TREE_TYPE (decl));
if (lookup_attribute ("stdcall", type_attributes)) if ((ccvt & IX86_CALLCVT_STDCALL) != 0)
new_id = gen_stdcall_or_fastcall_decoration (decl, id, '_'); {
else if (lookup_attribute ("fastcall", type_attributes)) if (TARGET_RTD)
/* If we are using -mrtd emit undecorated symbol and let linker
do the proper resolving. */
return NULL_TREE;
new_id = gen_stdcall_or_fastcall_decoration (decl, id, '_');
}
else if ((ccvt & IX86_CALLCVT_FASTCALL) != 0)
new_id = gen_stdcall_or_fastcall_decoration (decl, id, FASTCALL_PREFIX); new_id = gen_stdcall_or_fastcall_decoration (decl, id, FASTCALL_PREFIX);
else if ((new_id = lookup_attribute ("regparm", type_attributes))) else if ((cvt & IX86_CALLCVT_REGPARM) != 0
&& (new_id = lookup_attribute ("regparm", type_attributes)))
new_id = gen_regparm_prefix (decl, id, new_id = gen_regparm_prefix (decl, id,
TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (new_id)))); TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (new_id))));
else else
......
...@@ -170,7 +170,7 @@ gen_stdcall_or_fastcall_suffix (tree decl, tree id, bool fastcall) ...@@ -170,7 +170,7 @@ gen_stdcall_or_fastcall_suffix (tree decl, tree id, bool fastcall)
HOST_WIDE_INT total = 0; HOST_WIDE_INT total = 0;
const char *old_str = IDENTIFIER_POINTER (id != NULL_TREE ? id : DECL_NAME (decl)); const char *old_str = IDENTIFIER_POINTER (id != NULL_TREE ? id : DECL_NAME (decl));
char *new_str, *p; char *new_str, *p;
tree type = TREE_TYPE (decl); tree type = TREE_TYPE (DECL_ORIGIN (decl));
tree arg; tree arg;
function_args_iterator args_iter; function_args_iterator args_iter;
...@@ -202,7 +202,8 @@ gen_stdcall_or_fastcall_suffix (tree decl, tree id, bool fastcall) ...@@ -202,7 +202,8 @@ gen_stdcall_or_fastcall_suffix (tree decl, tree id, bool fastcall)
/ parm_boundary_bytes * parm_boundary_bytes); / parm_boundary_bytes * parm_boundary_bytes);
total += parm_size; total += parm_size;
} }
} }
/* Assume max of 8 base 10 digits in the suffix. */ /* Assume max of 8 base 10 digits in the suffix. */
p = new_str = XALLOCAVEC (char, 1 + strlen (old_str) + 1 + 8 + 1); p = new_str = XALLOCAVEC (char, 1 + strlen (old_str) + 1 + 8 + 1);
if (fastcall) if (fastcall)
...@@ -222,10 +223,16 @@ i386_pe_maybe_mangle_decl_assembler_name (tree decl, tree id) ...@@ -222,10 +223,16 @@ i386_pe_maybe_mangle_decl_assembler_name (tree decl, tree id)
if (TREE_CODE (decl) == FUNCTION_DECL) if (TREE_CODE (decl) == FUNCTION_DECL)
{ {
tree type_attributes = TYPE_ATTRIBUTES (TREE_TYPE (decl)); unsigned int ccvt = ix86_get_callcvt (TREE_TYPE (decl));
if (lookup_attribute ("stdcall", type_attributes)) if ((ccvt & IX86_CALLCVT_STDCALL) != 0)
new_id = gen_stdcall_or_fastcall_suffix (decl, id, false); {
else if (lookup_attribute ("fastcall", type_attributes)) if (TARGET_RTD)
/* If we are using -mrtd emit undecorated symbol and let linker
do the proper resolving. */
return NULL_TREE;
new_id = gen_stdcall_or_fastcall_suffix (decl, id, false);
}
else if ((ccvt & IX86_CALLCVT_FASTCALL) != 0)
new_id = gen_stdcall_or_fastcall_suffix (decl, id, true); new_id = gen_stdcall_or_fastcall_suffix (decl, id, true);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment