Module Name: src Committed By: martin Date: Wed Apr 18 14:01:16 UTC 2018
Modified Files: src/external/gpl3/gcc/dist/gcc [netbsd-8]: genattrtab.c src/tools [netbsd-8]: Makefile.gnuhost Log Message: Pull up following revision(s) (requested by maya in ticket #775): tools/Makefile.gnuhost: revision 1.46-1.48 external/gpl3/gcc/dist/gcc/genattrtab.c: revision 1.2 do the bracket nesting only for clang for now. Use the __clang__ preprocessor symbol to check for clang, since --version might barf. From joerg@ Apply upstream commit: From: ppalka <ppalka@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed, 27 Apr 2016 21:18:05 +0000 Subject: [PATCH] Reduce nesting of parentheses in conditionals generated by genattrtab gcc/ChangeLog: * genattrtab.c (write_test_expr): New parameter EMIT_PARENS which defaults to true. Emit an outer pair of parentheses only if EMIT_PARENS. When continuing a chain of && or || (or & or |), don't emit parentheses for the right-hand operand. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235536 gcc/arm generates so many parens it hits a bracket depth limited which is enforced by clang. This reduces the number of parens generated and avoids the need to increase bracket depth. Fixes PR toolchain/53178 properly. Remove hack previously needed to build gcc/arm with clang. genattrtab.c:1.2 makes this unnecessary. Tested by thorpej. To generate a diff of this commit: cvs rdiff -u -r1.1.1.3 -r1.1.1.3.8.1 \ src/external/gpl3/gcc/dist/gcc/genattrtab.c cvs rdiff -u -r1.44.8.1 -r1.44.8.2 src/tools/Makefile.gnuhost Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/gpl3/gcc/dist/gcc/genattrtab.c diff -u src/external/gpl3/gcc/dist/gcc/genattrtab.c:1.1.1.3 src/external/gpl3/gcc/dist/gcc/genattrtab.c:1.1.1.3.8.1 --- src/external/gpl3/gcc/dist/gcc/genattrtab.c:1.1.1.3 Sun Jan 24 06:06:07 2016 +++ src/external/gpl3/gcc/dist/gcc/genattrtab.c Wed Apr 18 14:01:16 2018 @@ -3424,7 +3424,10 @@ find_attrs_to_cache (rtx exp, bool creat /* Given a piece of RTX, print a C expression to test its truth value to OUTF. We use AND and IOR both for logical and bit-wise operations, so - interpret them as logical unless they are inside a comparison expression. */ + interpret them as logical unless they are inside a comparison expression. + + An outermost pair of parentheses is emitted around this C expression unless + EMIT_PARENS is false. */ /* Interpret AND/IOR as bit-wise operations instead of logical. */ #define FLG_BITWISE 1 @@ -3440,16 +3443,16 @@ find_attrs_to_cache (rtx exp, bool creat #define FLG_OUTSIDE_AND 8 static unsigned int -write_test_expr (FILE *outf, rtx exp, unsigned int attrs_cached, int flags) +write_test_expr (FILE *outf, rtx exp, unsigned int attrs_cached, int flags, + bool emit_parens = true) { int comparison_operator = 0; RTX_CODE code; struct attr_desc *attr; - /* In order not to worry about operator precedence, surround our part of - the expression with parentheses. */ + if (emit_parens) + fprintf (outf, "("); - fprintf (outf, "("); code = GET_CODE (exp); switch (code) { @@ -3583,8 +3586,18 @@ write_test_expr (FILE *outf, rtx exp, un || GET_CODE (XEXP (exp, 1)) == EQ_ATTR || (GET_CODE (XEXP (exp, 1)) == NOT && GET_CODE (XEXP (XEXP (exp, 1), 0)) == EQ_ATTR))) - attrs_cached - = write_test_expr (outf, XEXP (exp, 1), attrs_cached, flags); + { + bool need_parens = true; + + /* No need to emit parentheses around the right-hand operand if we are + continuing a chain of && or || (or & or |). */ + if (GET_CODE (XEXP (exp, 1)) == code) + need_parens = false; + + attrs_cached + = write_test_expr (outf, XEXP (exp, 1), attrs_cached, flags, + need_parens); + } else write_test_expr (outf, XEXP (exp, 1), attrs_cached, flags | comparison_operator); @@ -3802,7 +3815,9 @@ write_test_expr (FILE *outf, rtx exp, un GET_RTX_NAME (code)); } - fprintf (outf, ")"); + if (emit_parens) + fprintf (outf, ")"); + return attrs_cached; } Index: src/tools/Makefile.gnuhost diff -u src/tools/Makefile.gnuhost:1.44.8.1 src/tools/Makefile.gnuhost:1.44.8.2 --- src/tools/Makefile.gnuhost:1.44.8.1 Sat Apr 14 10:44:56 2018 +++ src/tools/Makefile.gnuhost Wed Apr 18 14:01:16 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.gnuhost,v 1.44.8.1 2018/04/14 10:44:56 martin Exp $ +# $NetBSD: Makefile.gnuhost,v 1.44.8.2 2018/04/18 14:01:16 martin Exp $ # # Rules used when building a GNU host package. Expects MODULE to be set. # @@ -18,13 +18,11 @@ .include <bsd.own.mk> # Disable use of pre-compiled headers on Darwin. -# GCC build exceeds the macOS clang default bracket nesting level of 256. BUILD_OSTYPE!= uname -s .if ${BUILD_OSTYPE} == "Darwin" HOST_CFLAGS+=-O2 -no-cpp-precomp -HOST_CFLAGS+=-O2 -no-cpp-precomp -fbracket-depth=512 -HOST_CXXFLAGS+= -fbracket-depth=512 .endif + MAKE_PROGRAM?= ${MAKE} .for i in 3 2