aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Tocar <ilya.tocar@intel.com>2014-08-01 17:58:32 +0400
committerH.J. Lu <hjl.tools@gmail.com>2014-08-06 08:32:01 -0700
commitd022bddd4fd93428a7fa3cc7ad404c912ed20dbf (patch)
tree03fca1a622763ceb73b02e5c514be06f46f20681
parentad9fe6c108abf73f47219655ff19a5ec68b68124 (diff)
downloadgdb-d022bddd4fd93428a7fa3cc7ad404c912ed20dbf.zip
gdb-d022bddd4fd93428a7fa3cc7ad404c912ed20dbf.tar.gz
gdb-d022bddd4fd93428a7fa3cc7ad404c912ed20dbf.tar.bz2
Add -momit_lock_prefix=[no|yes] option
This option serves as a workaround for processors, which fail on lock prefix. gas/ * config/tc-i386.c (omit_lock_prefix): New. (output_insn): Omit lock prefix if omit_lock_prefix is true. (OPTION_omit_lock_prefix): New. (md_longopts): Add momit-lock-prefix. (md_parse_option): Handle momit-lock-prefix. (md_show_usage): Add momit-lock-prefix=[no|yes]. * doc/c-i386.texi (momit-lock-prefix): Document. gas/testsuite/ * gas/i386/i386.exp: Run new tests. * gas/i386/omit-lock-no.d: New. * gas/i386/omit-lock-yes.d: Ditto. * gas/i386/omit-lock.s: Ditto.
-rw-r--r--gas/ChangeLog10
-rw-r--r--gas/config/tc-i386.c27
-rw-r--r--gas/doc/c-i386.texi12
-rw-r--r--gas/testsuite/ChangeLog7
-rw-r--r--gas/testsuite/gas/i386/i386.exp2
-rw-r--r--gas/testsuite/gas/i386/omit-lock-no.d12
-rw-r--r--gas/testsuite/gas/i386/omit-lock-yes.d12
-rw-r--r--gas/testsuite/gas/i386/omit-lock.s6
8 files changed, 88 insertions, 0 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index b7926f4..2a584fd 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,13 @@
+2014-08-06 Ilya Tocar <ilya.tocar@intel.com>
+
+ * config/tc-i386.c (omit_lock_prefix): New.
+ (output_insn): Omit lock prefix if omit_lock_prefix is true.
+ (OPTION_omit_lock_prefix): New.
+ (md_longopts): Add momit-lock-prefix.
+ (md_parse_option): Handle momit-lock-prefix.
+ (md_show_usage): Add momit-lock-prefix=[no|yes].
+ * doc/c-i386.texi (momit-lock-prefix): Document.
+
2014-08-01 Takashi Yoshii <yoshii.takashi@renesas.com>
PR 10378
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index c61d22b..ab5a319 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -543,6 +543,10 @@ static int add_bnd_prefix = 0;
/* 1 if pseudo index register, eiz/riz, is allowed . */
static int allow_index_reg = 0;
+/* 1 if the assembler should ignore LOCK prefix, even if it was
+ specified explicitly. */
+static int omit_lock_prefix = 0;
+
static enum check_kind
{
check_none = 0,
@@ -6938,6 +6942,15 @@ output_insn (void)
unsigned int j;
unsigned int prefix;
+ /* Some processors fail on LOCK prefix. This options makes
+ assembler ignore LOCK prefix and serves as a workaround. */
+ if (omit_lock_prefix)
+ {
+ if (i.tm.base_opcode == LOCK_PREFIX_OPCODE)
+ return;
+ i.prefix[LOCK_PREFIX] = 0;
+ }
+
/* Since the VEX/EVEX prefix contains the implicit prefix, we
don't need the explicit prefix. */
if (!i.tm.opcode_modifier.vex && !i.tm.opcode_modifier.evex)
@@ -9532,6 +9545,7 @@ const char *md_shortopts = "qn";
#define OPTION_MEVEXLIG (OPTION_MD_BASE + 16)
#define OPTION_MEVEXWIG (OPTION_MD_BASE + 17)
#define OPTION_MBIG_OBJ (OPTION_MD_BASE + 18)
+#define OPTION_omit_lock_prefix (OPTION_MD_BASE + 19)
struct option md_longopts[] =
{
@@ -9561,6 +9575,7 @@ struct option md_longopts[] =
# if defined (TE_PE) || defined (TE_PEP)
{"mbig-obj", no_argument, NULL, OPTION_MBIG_OBJ},
#endif
+ {"momit-lock-prefix", required_argument, NULL, OPTION_omit_lock_prefix},
{NULL, no_argument, NULL, 0}
};
size_t md_longopts_size = sizeof (md_longopts);
@@ -9848,6 +9863,15 @@ md_parse_option (int c, char *arg)
break;
#endif
+ case OPTION_omit_lock_prefix:
+ if (strcasecmp (arg, "yes") == 0)
+ omit_lock_prefix = 1;
+ else if (strcasecmp (arg, "no") == 0)
+ omit_lock_prefix = 0;
+ else
+ as_fatal (_("invalid -momit-lock-prefix= option: `%s'"), arg);
+ break;
+
default:
return 0;
}
@@ -10004,6 +10028,9 @@ md_show_usage (FILE *stream)
fprintf (stream, _("\
-mbig-obj generate big object files\n"));
#endif
+ fprintf (stream, _("\
+ -momit-lock-prefix=[no|yes]\n\
+ strip all lock prefixes\n"));
}
#if ((defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT)) \
diff --git a/gas/doc/c-i386.texi b/gas/doc/c-i386.texi
index c1631c2..0c2e134 100644
--- a/gas/doc/c-i386.texi
+++ b/gas/doc/c-i386.texi
@@ -291,6 +291,18 @@ if such prefix was not explicitly specified in the source code.
On x86-64 PE/COFF target this option forces the use of big object file
format, which allows more than 32768 sections.
+@cindex @samp{-momit-lock-prefix=} option, i386
+@cindex @samp{-momit-lock-prefix=} option, x86-64
+@item -momit-lock-prefix=@var{no}
+@itemx -momit-lock-prefix=@var{yes}
+These options control how the assembler should encode lock prefix.
+This option is intended as a workaround for processors, that fail on
+lock prefix. This option can only be safely used with single-core,
+single-thread computers
+@option{-momit-lock-prefix=@var{yes}} will omit all lock prefixes.
+@option{-momit-lock-prefix=@var{no}} will encode lock prefix as usual,
+which is the default.
+
@end table
@c man end
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index acb0ac2..44e3c34 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2014-08-06 Ilya Tocar <ilya.tocar@intel.com>
+
+ * gas/i386/i386.exp: Run new tests.
+ * gas/i386/omit-lock-no.d: New.
+ * gas/i386/omit-lock-yes.d: Ditto.
+ * gas/i386/omit-lock.s: Ditto.
+
2014-07-29 Matthew Fortune <matthew.fortune@imgtec.com>
* gas/mips/attr-gnu-4-0.d: New.
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 01de5d9..680d28c 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -301,6 +301,8 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_32_check]]
run_dump_test "avx512dq"
run_dump_test "avx512dq_vl-intel"
run_dump_test "avx512dq_vl"
+ run_dump_test "omit-lock-yes"
+ run_dump_test "omit-lock-no"
run_dump_test "disassem"
# These tests require support for 8 and 16 bit relocs,
diff --git a/gas/testsuite/gas/i386/omit-lock-no.d b/gas/testsuite/gas/i386/omit-lock-no.d
new file mode 100644
index 0000000..87f796f
--- /dev/null
+++ b/gas/testsuite/gas/i386/omit-lock-no.d
@@ -0,0 +1,12 @@
+#source: omit-lock.s
+#as: -momit-lock-prefix=yes -momit-lock-prefix=no
+#objdump: -dw
+#name: i386 omit lock = no
+
+.*: +file format .*i386.*
+
+Disassembly of section .text:
+
+0+ <main>:
+ 0: f0 f0 83 00 01 lock lock addl \$0x1,\(%eax\)
+#pass
diff --git a/gas/testsuite/gas/i386/omit-lock-yes.d b/gas/testsuite/gas/i386/omit-lock-yes.d
new file mode 100644
index 0000000..67f0ef1
--- /dev/null
+++ b/gas/testsuite/gas/i386/omit-lock-yes.d
@@ -0,0 +1,12 @@
+#source: omit-lock.s
+#as: -momit-lock-prefix=yes
+#objdump: -dw
+#name: i386 omit lock = yes
+
+.*: +file format .*i386.*
+
+Disassembly of section .text:
+
+0+ <main>:
+ 0: 83 00 01 addl \$0x1,\(%eax\)
+#pass
diff --git a/gas/testsuite/gas/i386/omit-lock.s b/gas/testsuite/gas/i386/omit-lock.s
new file mode 100644
index 0000000..b267ebe
--- /dev/null
+++ b/gas/testsuite/gas/i386/omit-lock.s
@@ -0,0 +1,6 @@
+ .code32
+.globl main
+ .type main, @function
+main:
+ lock
+ lock addl $0x1,(%eax)