rs6000_mangle_decl_assembler_name (tree decl, tree id)
{
if (TARGET_FLOAT128_TYPE && TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128
- && TREE_CODE (decl) == FUNCTION_DECL && DECL_IS_BUILTIN (decl) )
+ && TREE_CODE (decl) == FUNCTION_DECL
+ && fndecl_built_in_p (decl, BUILT_IN_NORMAL))
{
size_t len = IDENTIFIER_LENGTH (id);
const char *name = IDENTIFIER_POINTER (id);
+ const char *newname = NULL;
- /* Update the __builtin_*printf && __builtin_*scanf functions. */
- const size_t printf_len = sizeof ("printf") - 1;
- const size_t scanf_len = sizeof ("scanf") - 1;
- const size_t printf_extra = sizeof ("__") - 1 + sizeof ("ieee128") - 1;
- const size_t scanf_extra = sizeof ("__isoc99_") - 1 + sizeof ("ieee128") - 1;
-
- if (len >= printf_len
- && strcmp (name + len - printf_len, "printf") == 0)
- {
- char *newname = (char *) alloca (len + 1 + printf_extra);
- strcpy (newname, "__");
- memcpy (newname + 2, name, len);
- strcpy (newname + 2 + len, "ieee128");
- id = get_identifier (newname);
- }
-
- else if (len >= scanf_len
- && strcmp (name + len - scanf_len, "scanf") == 0)
+ /* See if it is one of the built-in functions with an unusual name. */
+ switch (DECL_FUNCTION_CODE (decl))
{
- char *newname = (char *) alloca (len + 1 + scanf_extra);
- strcpy (newname, "__isoc99_");
- memcpy (newname + sizeof ("__isoc99") - 1, name, len);
- strcpy (newname + sizeof ("__isoc99") - 1 + len, "ieee128");
- id = get_identifier (newname);
+ default:
+ break;
+
+ case BUILT_IN_GAMMAL_R:
+ case BUILT_IN_LGAMMAL_R:
+ newname = "__lgammaieee128_r";
+ break;
+
+ case BUILT_IN_NEXTTOWARD:
+ newname = "__nexttoward_to_ieee128";
+ break;
+
+ case BUILT_IN_NEXTTOWARDF:
+ newname = "__nexttowardf_to_ieee128";
+ break;
+
+ case BUILT_IN_NEXTTOWARDL:
+ newname = "__nexttowardieee128";
+ break;
}
- else if (name[len - 1] == 'l')
+ /* Update the __builtin_*printf && __builtin_*scanf functions. */
+ if (!newname)
{
- bool uses_ieee128_p = false;
- tree type = TREE_TYPE (decl);
- machine_mode ret_mode = TYPE_MODE (type);
+ const size_t printf_len = sizeof ("printf") - 1;
+ const size_t scanf_len = sizeof ("scanf") - 1;
+ const size_t printf_extra
+ = sizeof ("__") - 1 + sizeof ("ieee128") - 1;
+ const size_t scanf_extra
+ = sizeof ("__isoc99_") - 1 + sizeof ("ieee128") - 1;
- /* See if the function returns a IEEE 128-bit floating point type or
- complex type. */
- if (ret_mode == TFmode || ret_mode == TCmode)
- uses_ieee128_p = true;
- else
+ if (len >= printf_len
+ && strcmp (name + len - printf_len, "printf") == 0)
{
- function_args_iterator args_iter;
- tree arg;
+ char *name2 = (char *) alloca (len + 1 + printf_extra);
+ strcpy (name2, "__");
+ memcpy (name2 + 2, name, len);
+ strcpy (name2 + 2 + len, "ieee128");
+ newname = (const char *) name2;
+ }
- /* See if the function passes a IEEE 128-bit floating point type
- or complex type. */
- FOREACH_FUNCTION_ARGS (type, arg, args_iter)
+ else if (len >= scanf_len
+ && strcmp (name + len - scanf_len, "scanf") == 0)
+ {
+ char *name2 = (char *) alloca (len + 1 + scanf_extra);
+ strcpy (name2, "__isoc99_");
+ memcpy (name2 + sizeof ("__isoc99") - 1, name, len);
+ strcpy (name2 + sizeof ("__isoc99") - 1 + len, "ieee128");
+ newname = (const char *) name2;
+ }
+
+ else if (name[len - 1] == 'l')
+ {
+ bool uses_ieee128_p = false;
+ tree type = TREE_TYPE (decl);
+ machine_mode ret_mode = TYPE_MODE (type);
+
+ /* See if the function returns a IEEE 128-bit floating point type or
+ complex type. */
+ if (ret_mode == TFmode || ret_mode == TCmode)
+ uses_ieee128_p = true;
+ else
{
- machine_mode arg_mode = TYPE_MODE (arg);
- if (arg_mode == TFmode || arg_mode == TCmode)
+ function_args_iterator args_iter;
+ tree arg;
+
+ /* See if the function passes a IEEE 128-bit floating point type
+ or complex type. */
+ FOREACH_FUNCTION_ARGS (type, arg, args_iter)
{
- uses_ieee128_p = true;
- break;
+ machine_mode arg_mode = TYPE_MODE (arg);
+ if (arg_mode == TFmode || arg_mode == TCmode)
+ {
+ uses_ieee128_p = true;
+ break;
+ }
}
}
- }
- /* If we passed or returned an IEEE 128-bit floating point type,
- change the name. */
- if (uses_ieee128_p)
- {
- char *name2 = (char *) alloca (len + 4);
- memcpy (name2, name, len - 1);
- strcpy (name2 + len - 1, "f128");
- id = get_identifier (name2);
+ /* If we passed or returned an IEEE 128-bit floating point type,
+ change the name. */
+ if (uses_ieee128_p)
+ {
+ char *name2 = (char *) alloca (len + 4);
+ memcpy (name2, name, len - 1);
+ strcpy (name2 + len - 1, "f128");
+ newname = (const char *) name2;
+ }
}
}
+
+ if (newname)
+ {
+ if (TARGET_DEBUG_BUILTIN)
+ fprintf (stderr, "Map %s => %s\n", name, newname);
+
+ id = get_identifier (newname);
+ }
}
return id;