Skip to content

Commit

Permalink
OS/2: Fix passing more than 2 arguments to _Optlink functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy Kuminov committed Dec 21, 2011
1 parent b7d6c60 commit d5fe6e4
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions gcc/config/i386/i386.c
Expand Up @@ -4485,6 +4485,18 @@ ix86_comp_type_attributes (const_tree type1, const_tree type2)
!= ix86_function_regparm (type2, NULL)))
return 0;

#ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
if (!lookup_attribute ("system", TYPE_ATTRIBUTES (type1))
!= !lookup_attribute ("system", TYPE_ATTRIBUTES (type2)))
return 0;
#endif

#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
if (!lookup_attribute ("optlink", TYPE_ATTRIBUTES (type1))
!= !lookup_attribute ("optlink", TYPE_ATTRIBUTES (type2)))
return 0;
#endif

/* Check for mismatched sseregparm types. */
if (!lookup_attribute ("sseregparm", TYPE_ATTRIBUTES (type1))
!= !lookup_attribute ("sseregparm", TYPE_ATTRIBUTES (type2)))
Expand Down Expand Up @@ -4541,6 +4553,27 @@ ix86_function_regparm (const_tree type, const_tree decl)
if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (type)))
return 2;

#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
if (lookup_attribute ("optlink", TYPE_ATTRIBUTES (type)))
{
if (decl && TREE_CODE (decl) == FUNCTION_DECL)
{
/* We can't use _Optlink for nested functions as it may use
up to 3 regparms (see above about regparm(3)). */
if (!error_issued
&& decl_function_context (decl)
&& !DECL_NO_STATIC_CHAIN (decl))
{
error ("nested functions cannot use optlink attribute");
error_issued = true;
return 0;
}
}

return 3;
}
#endif

/* Use register calling convention for local functions when possible. */
if (decl
&& TREE_CODE (decl) == FUNCTION_DECL
Expand Down Expand Up @@ -5767,7 +5800,7 @@ function_arg_advance_32 (CUMULATIVE_ARGS *cum, enum machine_mode mode,
{
/* If out of eyecatcher slots, do nothing */
if (!cum->ec_slots)
return;
break;

if (INTEGRAL_TYPE_P (type)
|| POINTER_TYPE_P (type))
Expand All @@ -5793,15 +5826,15 @@ function_arg_advance_32 (CUMULATIVE_ARGS *cum, enum machine_mode mode,

/* The case with ec_slots <= 0 will be catched a little lates */
if (cum->ec_slots > 0)
return;
break;
}
else
{
/* This is nor a integer, address or float parameter.
Pass it on the stack but count its size in eyecatcher. */
cum->ec_slots -= words;
if (cum->ec_slots > 0)
return;
break;
}

/* If we're out of eyecatcher slots, pass the arg on the stack */
Expand All @@ -5810,7 +5843,7 @@ function_arg_advance_32 (CUMULATIVE_ARGS *cum, enum machine_mode mode,
cum->ec_slots = 0;
cum->nregs = 0;
cum->fpu_nregs = 0;
return;
break;
}
}
#endif
Expand Down

0 comments on commit d5fe6e4

Please sign in to comment.