This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Optimizer questions/issues with EBCDIC i370/s390 modes.


Dave Pitts wrote:

Kaveh R. Ghazi wrote:

> 2. Outputing of constant strings with printf are converted to puts
> when running native.
> > It appears that the optimizer is looking for a native \n and not
> TARGET_NEWLINE.

Does this (as of yet untested) patch help?

2002-08-22 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>

* c-common.c (c_expand_builtin_printf): Use TARGET_NEWLINE.

Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.366
diff -u -p -r1.366 c-common.c
--- c-common.c 16 Aug 2002 23:31:03 -0000 1.366
+++ c-common.c 22 Aug 2002 14:27:06 -0000
@@ -4513,10 +4513,10 @@ c_expand_builtin_printf (arglist, target
includes the terminating NULL in its count. */
else if (TREE_STRING_LENGTH (stripped_string) > 2
&& TREE_STRING_POINTER (stripped_string)
- [TREE_STRING_LENGTH (stripped_string) - 2] == '\n')
+ [TREE_STRING_LENGTH (stripped_string) - 2] == TARGET_NEWLINE)
{
/* Create a NULL-terminated string that's one char shorter
- than the original, stripping off the trailing '\n'. */
+ than the original, stripping off the trailing TARGET_NEWLINE. */
const int newlen = TREE_STRING_LENGTH (stripped_string) - 1;
char *newstr = (char *) alloca (newlen);
memcpy (newstr, TREE_STRING_POINTER (stripped_string), newlen - 1);


Yes, you need this plus some conversion for the single character case. Patch as follows:

--- c-common.c Thu Aug 22 09:03:34 2002
+++ c-common.c.orig Wed Aug 21 15:17:02 2002
@@ -3924,14 +3924,6 @@ c_expand_builtin_printf (arglist, target
/* Given printf("c"), (where c is any one character,)
convert "c"[0] to an int and pass that to the replacement
function. */
-#ifdef MAP_OUTCHAR
- {
- unsigned x = MAP_OUTCHAR(TREE_STRING_POINTER (stripped_string)[0]);
- arglist = build_int_2 (x, 0);
- }
-#else
- arglist = build_int_2 (TREE_STRING_POINTER (stripped_string)[0], 0);
-#endif
arglist = build_int_2 (TREE_STRING_POINTER (stripped_string)[0], 0);
arglist = build_tree_list (NULL_TREE, arglist);
@@ -3943,10 +3935,10 @@ c_expand_builtin_printf (arglist, target
includes the terminating NULL in its count. */
else if (TREE_STRING_LENGTH (stripped_string) > 2
&& TREE_STRING_POINTER (stripped_string)
- [TREE_STRING_LENGTH (stripped_string) - 2] == TARGET_NEWLINE)
+ [TREE_STRING_LENGTH (stripped_string) - 2] == '\n')
{
/* Create a NULL-terminated string that's one char shorter
- than the original, stripping off the trailing TARGET_NEWLINE. */
+ than the original, stripping off the trailing '\n'. */
const int newlen = TREE_STRING_LENGTH (stripped_string) - 1;
char *newstr = (char *) alloca (newlen);
memcpy (newstr, TREE_STRING_POINTER (stripped_string), newlen - 1);



Oops, had the files backwards. Here's the correct patch:

--- c-common.c.orig Wed Aug 21 15:17:02 2002
+++ c-common.c Thu Aug 22 09:03:34 2002
@@ -3924,6 +3924,14 @@ c_expand_builtin_printf (arglist, target
/* Given printf("c"), (where c is any one character,)
convert "c"[0] to an int and pass that to the replacement
function. */
+#ifdef MAP_OUTCHAR
+ {
+ unsigned x = MAP_OUTCHAR(TREE_STRING_POINTER (stripped_string)[0]);
+ arglist = build_int_2 (x, 0);
+ }
+#else
+ arglist = build_int_2 (TREE_STRING_POINTER (stripped_string)[0], 0);
+#endif
arglist = build_int_2 (TREE_STRING_POINTER (stripped_string)[0], 0);
arglist = build_tree_list (NULL_TREE, arglist);
@@ -3935,10 +3943,10 @@ c_expand_builtin_printf (arglist, target
includes the terminating NULL in its count. */
else if (TREE_STRING_LENGTH (stripped_string) > 2
&& TREE_STRING_POINTER (stripped_string)
- [TREE_STRING_LENGTH (stripped_string) - 2] == '\n')
+ [TREE_STRING_LENGTH (stripped_string) - 2] == TARGET_NEWLINE)
{
/* Create a NULL-terminated string that's one char shorter
- than the original, stripping off the trailing '\n'. */
+ than the original, stripping off the trailing TARGET_NEWLINE. */
const int newlen = TREE_STRING_LENGTH (stripped_string) - 1;
char *newstr = (char *) alloca (newlen);
memcpy (newstr, TREE_STRING_POINTER (stripped_string), newlen - 1);


--
Dave Pitts PULLMAN: Travel and sleep in safety and comfort.
dpitts@cozx.com My other RV IS a Pullman (Colorado Pine). http://www.cozx.com/~dpitts




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]