From: Michael Meissner Date: Tue, 5 May 2020 17:32:22 +0000 (-0400) Subject: Patch ieee128-lib-patch004b X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=18c2f7a740a61e317e1911ee0ad7dea6043ea511;p=gcc.git Patch ieee128-lib-patch004b --- diff --git a/gcc/ChangeLog.meissner b/gcc/ChangeLog.meissner index ab1d5afa56a..342a439dafd 100644 --- a/gcc/ChangeLog.meissner +++ b/gcc/ChangeLog.meissner @@ -1,3 +1,10 @@ +2020-05-05 Michael Meissner + + (ieee128-lib-patch004b) + * config/rs6000/rs6000.c (rs6000_mangle_decl_assembler_name): Add + special cases for built-in functions that return or use long + double, but don't end in 'l'. + 2020-05-05 Michael Meissner (ieee128-lib-patch002b) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index dc184419d44..6271d4c00e0 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -26335,75 +26335,114 @@ static tree 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;