This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: Fix x86 4 operand instruction handling
On Thu, Dec 28, 2006 at 05:56:04PM -0800, H. J. Lu wrote:
> On Thu, Dec 28, 2006 at 03:27:37PM -0800, H. J. Lu wrote:
> > On Thu, Dec 28, 2006 at 02:39:40PM -0800, H. J. Lu wrote:
> > > The current code has
> > >
> > > if ((i.operands == 4)&&(i.imm_operands=2)) source++;
> > > ^^^^^^^^^^^^^^^^^
> > >
> > > It is wrong. I am checking in this patch.
> > >
> >
> > I am testing this patch instead now.
> >
>
> Ooops. Wrong patch. This is the correct one.
>
>
> H.J.
> ----
> 2006-12-28 H.J. Lu <hongjiu.lu@intel.com>
>
> * config/tc-i386.c (process_operands): Increment i.operands
> when adding a register operand.
> (build_modrm_byte): Fix 4 operand instruction handling.
>
I am checking this patch to handle "shrd %cl,%edx,%eax" and
"shld %cl,%edx,%eax".
H.J.
----
gas/
2006-12-29 H.J. Lu <hongjiu.lu@intel.com>
* config/tc-i386.c (build_modrm_byte): Handle shift count
register with 3 operands.
gas/testsuite/
2006-12-29 H.J. Lu <hongjiu.lu@intel.com>
* gas/i386/intel.s: Add tests for "shrd %cl,%edx,%eax" and
"shld %cl,%edx,%eax".
* gas/i386/opcode.s: Likewise.
* gas/i386/intel.d: Updated.
* gas/i386/opcode-intel.d: Likewise.
* gas/i386/opcode-suffix.d: Likewise.
* gas/i386/opcode.d: Likewise.
--- gas/config/tc-i386.c.imp 2006-12-28 22:18:27.000000000 -0800
+++ gas/config/tc-i386.c 2006-12-29 13:28:15.000000000 -0800
@@ -3436,10 +3436,13 @@ build_modrm_byte ()
source = 0;
break;
case 3:
- /* When there are 3 operands, one of them must be immediate,
- which may be the first or the last operand. */
- assert (i.imm_operands == 1);
- source = (i.types[0] & Imm) ? 1 : 0;
+ /* When there are 3 operands, one of them may be immediate,
+ which may be the first or the last operand. Otherwise,
+ the first operand must be shift count register (cl). */
+ assert (i.imm_operands == 1
+ || (i.imm_operands == 0
+ && (i.types[0] & ShiftCount)));
+ source = (i.types[0] & (Imm | ShiftCount)) ? 1 : 0;
break;
case 4:
/* When there are 4 operands, the first two must be immediate
--- gas/testsuite/gas/i386/intel.d.imp 2006-12-05 11:28:01.000000000 -0800
+++ gas/testsuite/gas/i386/intel.d 2006-12-29 13:32:10.000000000 -0800
@@ -628,5 +628,6 @@ Disassembly of section .text:
a87: b0 11 [ ]*mov \$0x11,%al
a89: b3 47 [ ]*mov \$0x47,%bl
a8b: b3 47 [ ]*mov \$0x47,%bl
- a8d: 00 00 .*
+ a8d: 0f ad d0 [ ]*shrd %cl,%edx,%eax
+ a90: 0f a5 d0 [ ]*shld %cl,%edx,%eax
[ ]*...
--- gas/testsuite/gas/i386/intel.s.imp 2006-12-05 11:28:01.000000000 -0800
+++ gas/testsuite/gas/i386/intel.s 2006-12-29 13:26:51.000000000 -0800
@@ -624,5 +624,8 @@ rot5:
mov %al, 0x11
mov %bl, ((( 0x4711 ) >> 8) & 0xff)
mov %bl, 0x47
-
+
+ shrd eax, edx, cl
+ shld eax, edx, cl
+
.p2align 4,0
--- gas/testsuite/gas/i386/opcode-intel.d.imp 2006-12-04 00:53:28.000000000 -0800
+++ gas/testsuite/gas/i386/opcode-intel.d 2006-12-29 13:35:53.000000000 -0800
@@ -606,4 +606,6 @@ Disassembly of section .text:
*[0-9a-f]+: 0f 00 c8[ ]+str[ ]+eax
*[0-9a-f]+: 66 0f 00 c8[ ]+str[ ]+ax
*[0-9a-f]+: 0f 00 08[ ]+str[ ]+(WORD PTR )?\[eax\]
+ *[0-9a-f]+: 0f ad d0 [ ]*shrd[ ]+eax,edx,cl
+ *[0-9a-f]+: 0f a5 d0 [ ]*shld[ ]+eax,edx,cl
\.\.\.
--- gas/testsuite/gas/i386/opcode-suffix.d.imp 2006-12-01 08:49:21.000000000 -0800
+++ gas/testsuite/gas/i386/opcode-suffix.d 2006-12-29 13:36:29.000000000 -0800
@@ -583,4 +583,6 @@ Disassembly of section .text:
*[0-9a-f]+: 0f 00 c8[ ]+strl[ ]+%eax
*[0-9a-f]+: 66 0f 00 c8[ ]+strw[ ]+%ax
*[0-9a-f]+: 0f 00 08[ ]+strw[ ]+\(%eax\)
+ *[0-9a-f]+: 0f ad d0 [ ]*shrdl[ ]+%cl,%edx,%eax
+ *[0-9a-f]+: 0f a5 d0 [ ]*shldl[ ]+%cl,%edx,%eax
\.\.\.
--- gas/testsuite/gas/i386/opcode.d.imp 2006-12-05 11:28:01.000000000 -0800
+++ gas/testsuite/gas/i386/opcode.d 2006-12-29 13:32:34.000000000 -0800
@@ -582,4 +582,6 @@ Disassembly of section .text:
9e5: 0f 00 c8 [ ]*str %eax
9e8: 66 0f 00 c8 [ ]*str %ax
9ec: 0f 00 08 [ ]*str \(%eax\)
+ 9ef: 0f ad d0 [ ]*shrd %cl,%edx,%eax
+ 9f2: 0f a5 d0 [ ]*shld %cl,%edx,%eax
\.\.\.
--- gas/testsuite/gas/i386/opcode.s.imp 2006-07-18 13:25:40.000000000 -0700
+++ gas/testsuite/gas/i386/opcode.s 2006-12-29 13:24:38.000000000 -0800
@@ -578,5 +578,8 @@ foo:
str %ax
str (%eax)
+ shrd %cl,%edx,%eax
+ shld %cl,%edx,%eax
+
# Force a good alignment.
.p2align 4,0