x86: Change -malign-branch= to accept a comma separated list

Message ID 20200117044822.mmi2hlqka2s67xwb@google.com
State New
Headers show
Series
  • x86: Change -malign-branch= to accept a comma separated list
Related show

Commit Message

H.J. Lu via Binutils Jan. 17, 2020, 4:48 a.m.
It is a convention to use a comma separated list.

-fsanitize=address,undefined
-fsanitize=null,alignment
-fpatchable-function-entry=3,1
-finstrument-functions-exclude-function-list=a,b
-mrecip=all,!sqrt
-mfpmath=sse,387

Comments

H.J. Lu Jan. 17, 2020, 5:02 a.m. | #1
On Thu, Jan 16, 2020 at 8:49 PM Fangrui Song via binutils
<binutils@sourceware.org> wrote:
>

> It is a convention to use a comma separated list.

>

> -fsanitize=address,undefined

> -fsanitize=null,alignment

> -fpatchable-function-entry=3,1

> -finstrument-functions-exclude-function-list=a,b

> -mrecip=all,!sqrt

> -mfpmath=sse,387


  -malign-branch=TYPE[+TYPE...] (default: jcc+fused+jmp)

is done on purpose since you can't pass comma in assembler options
from GCC driver to assembler with -Wa,....

-- 
H.J.
H.J. Lu via Binutils Jan. 17, 2020, 5:30 a.m. | #2
On 2020-01-16, H.J. Lu wrote:
>On Thu, Jan 16, 2020 at 8:49 PM Fangrui Song via binutils

><binutils@sourceware.org> wrote:

>>

>> It is a convention to use a comma separated list.

>>

>> -fsanitize=address,undefined

>> -fsanitize=null,alignment

>> -fpatchable-function-entry=3,1

>> -finstrument-functions-exclude-function-list=a,b

>> -mrecip=all,!sqrt

>> -mfpmath=sse,387

>

>  -malign-branch=TYPE[+TYPE...] (default: jcc+fused+jmp)

>

>is done on purpose since you can't pass comma in assembler options

>from GCC driver to assembler with -Wa,....


Thanks for explaining the motivation.

We can make -malign-branch= both an assembler option and a compiler
driver option (https://gcc.gnu.org/ml/gcc/2020-01/msg00315.html)

Then we can let gcc pass -malign-branch=jcc,jmp to gas.
Jan Beulich Jan. 17, 2020, 9:05 a.m. | #3
On 17.01.2020 06:02,  H.J. Lu  wrote:
> On Thu, Jan 16, 2020 at 8:49 PM Fangrui Song via binutils

> <binutils@sourceware.org> wrote:

>>

>> It is a convention to use a comma separated list.

>>

>> -fsanitize=address,undefined

>> -fsanitize=null,alignment

>> -fpatchable-function-entry=3,1

>> -finstrument-functions-exclude-function-list=a,b

>> -mrecip=all,!sqrt

>> -mfpmath=sse,387

> 

>   -malign-branch=TYPE[+TYPE...] (default: jcc+fused+jmp)

> 

> is done on purpose since you can't pass comma in assembler options

> from GCC driver to assembler with -Wa,....


How about permitting both + and , ?

Jan

Patch

From 17dab65dcf53e7282011fa824d9534d8a3f8dab6 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i@maskray.me>
Date: Thu, 16 Jan 2020 20:26:05 -0800
Subject: [PATCH] x86: Change -malign-branch to accept a comma separated list
To: binutils@sourceware.org

---
 gas/ChangeLog                                 | 20 +++++++++++++++++++
 gas/config/tc-i386.c                          |  4 ++--
 gas/po/gas.pot                                |  2 +-
 gas/testsuite/gas/i386/align-branch-1b.d      |  2 +-
 gas/testsuite/gas/i386/align-branch-1d.d      |  2 +-
 gas/testsuite/gas/i386/align-branch-1f.d      |  2 +-
 gas/testsuite/gas/i386/align-branch-2a.d      |  2 +-
 gas/testsuite/gas/i386/align-branch-2c.d      |  2 +-
 gas/testsuite/gas/i386/align-branch-3.d       |  2 +-
 gas/testsuite/gas/i386/align-branch-4a.d      |  2 +-
 gas/testsuite/gas/i386/align-branch-5.d       |  2 +-
 .../gas/i386/x86-64-align-branch-1b.d         |  2 +-
 .../gas/i386/x86-64-align-branch-1d.d         |  2 +-
 .../gas/i386/x86-64-align-branch-1f.d         |  2 +-
 .../gas/i386/x86-64-align-branch-2a.d         |  2 +-
 .../gas/i386/x86-64-align-branch-2c.d         |  2 +-
 .../gas/i386/x86-64-align-branch-3.d          |  2 +-
 .../gas/i386/x86-64-align-branch-4a.d         |  2 +-
 .../gas/i386/x86-64-align-branch-5.d          |  2 +-
 19 files changed, 39 insertions(+), 19 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index f2b49b7a89..25b180b132 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,23 @@ 
+2020-01-16  Fangrui Song  <maskray@google.com>
+
+	* config/tc-i386.c (md_parse_option): Change plus to comma.
+	* testsuite/gas/i386/align-branch-1b.d: Change plus to comma.
+	* testsuite/gas/i386/align-branch-1d.d: Likewise.
+	* testsuite/gas/i386/align-branch-1f.d: Likewise.
+	* testsuite/gas/i386/align-branch-2a.d: Likewise.
+	* testsuite/gas/i386/align-branch-2c.d: Likewise.
+	* testsuite/gas/i386/align-branch-3.d: Likewise.
+	* testsuite/gas/i386/align-branch-4a.d: Likewise.
+	* testsuite/gas/i386/align-branch-5.d: Likewise.
+	* testsuite/gas/i386/x86-64-align-branch-1b.d: Likewise.
+	* testsuite/gas/i386/x86-64-align-branch-1d.d: Likewise.
+	* testsuite/gas/i386/x86-64-align-branch-1f.d: Likewise.
+	* testsuite/gas/i386/x86-64-align-branch-2a.d: Likewise.
+	* testsuite/gas/i386/x86-64-align-branch-2c.d: Likewise.
+	* testsuite/gas/i386/x86-64-align-branch-3.d: Likewise.
+	* testsuite/gas/i386/x86-64-align-branch-4a.d: Likewise.
+	* testsuite/gas/i386/x86-64-align-branch-5.d: Likewise.
+
 2020-01-16  Andre Vieira  <andre.simoesdiasvieira@arm.com>
 
 	PR 25376
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 3f7f4222bf..56d2385be2 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -12509,7 +12509,7 @@  md_parse_option (int c, const char *arg)
       type = saved;
       do
 	{
-	  next = strchr (type, '+');
+	  next = strchr (type, ',');
 	  if (next)
 	    *next++ = '\0';
 	  if (strcasecmp (type, "jcc") == 0)
@@ -12795,7 +12795,7 @@  md_show_usage (FILE *stream)
   -malign-branch-boundary=NUM (default: 0)\n\
                           align branches within NUM byte boundary\n"));
   fprintf (stream, _("\
-  -malign-branch=TYPE[+TYPE...] (default: jcc+fused+jmp)\n\
+  -malign-branch=TYPE[,TYPE...] (default: jcc,fused,jmp)\n\
                           TYPE is combination of jcc, fused, jmp, call, ret,\n\
                            indirect\n\
                           specify types of branches to align\n"));
diff --git a/gas/po/gas.pot b/gas/po/gas.pot
index 21dc23cd1d..1996385678 100644
--- a/gas/po/gas.pot
+++ b/gas/po/gas.pot
@@ -8813,7 +8813,7 @@  msgstr ""
 #: config/tc-i386.c:12803
 #, c-format
 msgid ""
-"  -malign-branch=TYPE[+TYPE...] (default: jcc+fused+jmp)\n"
+"  -malign-branch=TYPE[,TYPE...] (default: jcc,fused,jmp)\n"
 "                          TYPE is combination of jcc, fused, jmp, call, "
 "ret,\n"
 "                           indirect\n"
diff --git a/gas/testsuite/gas/i386/align-branch-1b.d b/gas/testsuite/gas/i386/align-branch-1b.d
index 1a993b5bef..b4e9e7fd86 100644
--- a/gas/testsuite/gas/i386/align-branch-1b.d
+++ b/gas/testsuite/gas/i386/align-branch-1b.d
@@ -1,5 +1,5 @@ 
 #source: align-branch-1.s
-#as: -malign-branch-boundary=32 -malign-branch=fused+jcc+jmp
+#as: -malign-branch-boundary=32 -malign-branch=fused,jcc,jmp
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/align-branch-1d.d b/gas/testsuite/gas/i386/align-branch-1d.d
index 7ea8d8f44b..d24ec8c385 100644
--- a/gas/testsuite/gas/i386/align-branch-1d.d
+++ b/gas/testsuite/gas/i386/align-branch-1d.d
@@ -1,5 +1,5 @@ 
 #source: align-branch-1.s
-#as: -malign-branch-boundary=32 -malign-branch=fused+jcc
+#as: -malign-branch-boundary=32 -malign-branch=fused,jcc
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/align-branch-1f.d b/gas/testsuite/gas/i386/align-branch-1f.d
index 07d75f6090..9263455262 100644
--- a/gas/testsuite/gas/i386/align-branch-1f.d
+++ b/gas/testsuite/gas/i386/align-branch-1f.d
@@ -1,5 +1,5 @@ 
 #source: align-branch-1.s
-#as: -malign-branch-boundary=32 -malign-branch=jcc+jmp
+#as: -malign-branch-boundary=32 -malign-branch=jcc,jmp
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/align-branch-2a.d b/gas/testsuite/gas/i386/align-branch-2a.d
index cba0560d9c..20a46f736e 100644
--- a/gas/testsuite/gas/i386/align-branch-2a.d
+++ b/gas/testsuite/gas/i386/align-branch-2a.d
@@ -1,5 +1,5 @@ 
 #source: align-branch-2.s
-#as: -malign-branch-boundary=32 -malign-branch=fused+jcc+jmp
+#as: -malign-branch-boundary=32 -malign-branch=fused,jcc,jmp
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/align-branch-2c.d b/gas/testsuite/gas/i386/align-branch-2c.d
index 2fc6339975..37ba078bc7 100644
--- a/gas/testsuite/gas/i386/align-branch-2c.d
+++ b/gas/testsuite/gas/i386/align-branch-2c.d
@@ -1,5 +1,5 @@ 
 #source: align-branch-2.s
-#as: -malign-branch-boundary=32 -malign-branch=indirect+call
+#as: -malign-branch-boundary=32 -malign-branch=indirect,call
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/align-branch-3.d b/gas/testsuite/gas/i386/align-branch-3.d
index da31b6f503..2062e8b255 100644
--- a/gas/testsuite/gas/i386/align-branch-3.d
+++ b/gas/testsuite/gas/i386/align-branch-3.d
@@ -1,4 +1,4 @@ 
-#as: -malign-branch-boundary=32 -malign-branch=indirect+call
+#as: -malign-branch-boundary=32 -malign-branch=indirect,call
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/align-branch-4a.d b/gas/testsuite/gas/i386/align-branch-4a.d
index 2b1e0b1f45..9fc340668e 100644
--- a/gas/testsuite/gas/i386/align-branch-4a.d
+++ b/gas/testsuite/gas/i386/align-branch-4a.d
@@ -1,5 +1,5 @@ 
 #source: align-branch-4.s
-#as: -malign-branch-boundary=32 -malign-branch=fused+jcc+jmp
+#as: -malign-branch-boundary=32 -malign-branch=fused,jcc,jmp
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/align-branch-5.d b/gas/testsuite/gas/i386/align-branch-5.d
index ca96c3c711..28b3bcf784 100644
--- a/gas/testsuite/gas/i386/align-branch-5.d
+++ b/gas/testsuite/gas/i386/align-branch-5.d
@@ -1,4 +1,4 @@ 
-#as: -malign-branch-boundary=32 -malign-branch=jcc+fused+jmp
+#as: -malign-branch-boundary=32 -malign-branch=jcc,fused,jmp
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-1b.d b/gas/testsuite/gas/i386/x86-64-align-branch-1b.d
index 375a31a8b2..3467920819 100644
--- a/gas/testsuite/gas/i386/x86-64-align-branch-1b.d
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-1b.d
@@ -1,5 +1,5 @@ 
 #source: x86-64-align-branch-1.s
-#as: -malign-branch-boundary=32 -malign-branch=fused+jcc+jmp
+#as: -malign-branch-boundary=32 -malign-branch=fused,jcc,jmp
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-1d.d b/gas/testsuite/gas/i386/x86-64-align-branch-1d.d
index c72b017627..5573699dda 100644
--- a/gas/testsuite/gas/i386/x86-64-align-branch-1d.d
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-1d.d
@@ -1,5 +1,5 @@ 
 #source: x86-64-align-branch-1.s
-#as: -malign-branch-boundary=32 -malign-branch=fused+jcc
+#as: -malign-branch-boundary=32 -malign-branch=fused,jcc
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-1f.d b/gas/testsuite/gas/i386/x86-64-align-branch-1f.d
index aed8169873..72e37da27d 100644
--- a/gas/testsuite/gas/i386/x86-64-align-branch-1f.d
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-1f.d
@@ -1,5 +1,5 @@ 
 #source: x86-64-align-branch-1.s
-#as: -malign-branch-boundary=32 -malign-branch=jcc+jmp
+#as: -malign-branch-boundary=32 -malign-branch=jcc,jmp
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-2a.d b/gas/testsuite/gas/i386/x86-64-align-branch-2a.d
index aaf759d42e..0a98d7c8a5 100644
--- a/gas/testsuite/gas/i386/x86-64-align-branch-2a.d
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-2a.d
@@ -1,5 +1,5 @@ 
 #source: x86-64-align-branch-2.s
-#as: -malign-branch-boundary=32 -malign-branch=fused+jcc+jmp
+#as: -malign-branch-boundary=32 -malign-branch=fused,jcc,jmp
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-2c.d b/gas/testsuite/gas/i386/x86-64-align-branch-2c.d
index fb87c49cd5..7b02cb5327 100644
--- a/gas/testsuite/gas/i386/x86-64-align-branch-2c.d
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-2c.d
@@ -1,5 +1,5 @@ 
 #source: x86-64-align-branch-2.s
-#as: -malign-branch-boundary=32 -malign-branch=indirect+call
+#as: -malign-branch-boundary=32 -malign-branch=indirect,call
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-3.d b/gas/testsuite/gas/i386/x86-64-align-branch-3.d
index 18767a7045..9b4028188a 100644
--- a/gas/testsuite/gas/i386/x86-64-align-branch-3.d
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-3.d
@@ -1,4 +1,4 @@ 
-#as: -malign-branch-boundary=32 -malign-branch=indirect+call
+#as: -malign-branch-boundary=32 -malign-branch=indirect,call
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-4a.d b/gas/testsuite/gas/i386/x86-64-align-branch-4a.d
index 47318e832a..dfbbca26e8 100644
--- a/gas/testsuite/gas/i386/x86-64-align-branch-4a.d
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-4a.d
@@ -1,5 +1,5 @@ 
 #source: x86-64-align-branch-4.s
-#as: -malign-branch-boundary=32 -malign-branch=fused+jcc+jmp
+#as: -malign-branch-boundary=32 -malign-branch=fused,jcc,jmp
 #objdump: -dw
 
 .*: +file format .*
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-5.d b/gas/testsuite/gas/i386/x86-64-align-branch-5.d
index 9770a4a07f..f5cef59610 100644
--- a/gas/testsuite/gas/i386/x86-64-align-branch-5.d
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-5.d
@@ -1,5 +1,5 @@ 
 #source: align-branch-5.s
-#as: -malign-branch-boundary=32 -malign-branch=jcc+fused+jmp
+#as: -malign-branch-boundary=32 -malign-branch=jcc,fused,jmp
 #objdump: -dw
 
 .*: +file format .*
-- 
2.25.0