public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@bigpond.net.au>
To: Jan Beulich <JBeulich@novell.com>
Cc: binutils@sources.redhat.com
Subject: Re: i386 intel syntax integer load/store fp instructions
Date: Wed, 23 Jun 2004 15:03:00 -0000	[thread overview]
Message-ID: <20040623150348.GW3596@bubble.modra.org> (raw)
In-Reply-To: <s0d98755.098@emea1-mh.id2.novell.com>

On Wed, Jun 23, 2004 at 02:36:12PM +0200, Jan Beulich wrote:
> Still, I'd prefer to do away with suffixes for Intel syntax altogether,
> but that's perhaps not acceptable...

I believe suffixes are commonly used on certain instructions.  eg.
google for "fildq", so we can't get rid of them entirely.

The following fixes Intel mode disassembly of fp mem operands, and
tidies a few other things.  Since you're working on this area, I'll
leave the gas fixes to you..

include/opcode/ChangeLog
	* i386.h (i386_optab): Remove fildd, fistpd and fisttpd.

opcodes/ChangeLog
	* i386-dis.c (x_mode): Comment.
	(two_source_ops): File scope.
	(float_mem): Correct fisttpll and fistpll.
	(float_mem_mode): New table.
	(dofloat): Use it.
	(OP_E): Correct intel mode PTR output.
	(ptr_reg): Use open_char and close_char.
	(PNI_Fixup): Handle possible suffix on sidt.  Use op1out etc. for
	operands.  Set two_source_ops.

gas/testsuite/ChangeLog
	* gas/i386/prescott.s: Remove fisttpd and fisttpq.
	* gas/i386/prescott.d: Update.

Index: include/opcode/i386.h
===================================================================
RCS file: /cvs/src/src/include/opcode/i386.h,v
retrieving revision 1.43
diff -u -p -r1.43 i386.h
--- include/opcode/i386.h	12 Mar 2004 13:38:46 -0000	1.43
+++ include/opcode/i386.h	23 Jun 2004 14:42:02 -0000
@@ -583,7 +583,6 @@ static const template i386_optab[] = {
 {"fld",    1,	0xdb, 5, 0,	 x_FP|Modrm,		{ LLongMem, 0, 0} },
 {"fild",   1,	0xdf, 0, 0,	 sl_FP|FloatMF|Modrm,	{ ShortMem|LongMem, 0, 0} },
 /* Intel Syntax */
-{"fildd",  1,	0xdf, 5, 0,	 FP|Modrm,		{ LLongMem, 0, 0} },
 {"fildq",  1,	0xdf, 5, 0,	 FP|Modrm,		{ LLongMem, 0, 0} },
 {"fildll", 1,	0xdf, 5, 0,	 FP|Modrm,		{ LLongMem, 0, 0} },
 {"fldt",   1,	0xdb, 5, 0,	 FP|Modrm,		{ LLongMem, 0, 0} },
@@ -603,7 +602,6 @@ static const template i386_optab[] = {
 {"fstp",   1,	0xdb, 7, 0,	 x_FP|Modrm,		{ LLongMem, 0, 0} },
 {"fistp",  1,	0xdf, 3, 0,	 sl_FP|FloatMF|Modrm,	{ ShortMem|LongMem, 0, 0} },
 /* Intel Syntax */
-{"fistpd", 1,	0xdf, 7, 0,	 FP|Modrm,		{ LLongMem, 0, 0} },
 {"fistpq", 1,	0xdf, 7, 0,	 FP|Modrm,		{ LLongMem, 0, 0} },
 {"fistpll",1,	0xdf, 7, 0,	 FP|Modrm,		{ LLongMem, 0, 0} },
 {"fstpt",  1,	0xdb, 7, 0,	 FP|Modrm,		{ LLongMem, 0, 0} },
@@ -1308,7 +1306,6 @@ static const template i386_optab[] = {
 {"addsubps",  2, 0xf20fd0,  X, CpuPNI, FP|Modrm,	{ RegXMM|LLongMem, RegXMM, 0 } },
 {"fisttp",    1, 0xdf,      1, CpuPNI, sl_FP|FloatMF|Modrm, { ShortMem|LongMem, 0, 0} },
 /* Intel Syntax */
-{"fisttpd",   1, 0xdd,      1, CpuPNI, FP|Modrm,	{ LLongMem, 0, 0} },
 {"fisttpq",   1, 0xdd,      1, CpuPNI, FP|Modrm,	{ LLongMem, 0, 0} },
 {"fisttpll",  1, 0xdd,      1, CpuPNI, FP|Modrm,	{ LLongMem, 0, 0} },
 {"haddpd",    2, 0x660f7c,  X, CpuPNI, FP|Modrm,	{ RegXMM|LLongMem, RegXMM, 0 } },
Index: opcodes/i386-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/i386-dis.c,v
retrieving revision 1.47
diff -u -p -r1.47 i386-dis.c
--- opcodes/i386-dis.c	12 Mar 2004 13:38:16 -0000	1.47
+++ opcodes/i386-dis.c	23 Jun 2004 14:42:04 -0000
@@ -312,7 +312,7 @@ fetch_data (struct disassemble_info *inf
 #define w_mode 3  /* word operand */
 #define d_mode 4  /* double word operand  */
 #define q_mode 5  /* quad word operand */
-#define x_mode 6
+#define x_mode 6  /* 80 bit float operand */
 #define m_mode 7  /* d_mode in 32bit, q_mode in 64bit mode.  */
 #define cond_jump_mode 8
 #define loop_jcxz_mode 9
@@ -1881,6 +1881,7 @@ prefix_name (int pref, int sizeflag)
 
 static char op1out[100], op2out[100], op3out[100];
 static int op_ad, op_index[3];
+static int two_source_ops;
 static bfd_vma op_address[3];
 static bfd_vma op_riprel[3];
 static bfd_vma start_pc;
@@ -1932,7 +1933,6 @@ print_insn (bfd_vma pc, disassemble_info
 {
   const struct dis386 *dp;
   int i;
-  int two_source_ops;
   char *first, *second, *third;
   int needcomma;
   unsigned char uses_SSE_prefix;
@@ -2364,7 +2364,7 @@ static const char *float_mem[] = {
   "fdivr{l||l|}",
   /* dd */
   "fld{l||l|}",
-  "fisttpll",
+  "fisttp{ll||ll|}",
   "fst{l||l|}",
   "fstp{l||l|}",
   "frstor",
@@ -2388,7 +2388,82 @@ static const char *float_mem[] = {
   "fbld",
   "fild{ll||ll|}",
   "fbstp",
-  "fistpll",
+  "fistp{ll||ll|}",
+};
+
+static const unsigned char float_mem_mode[] = {
+  /* d8 */
+  d_mode,
+  d_mode,
+  d_mode,
+  d_mode,
+  d_mode,
+  d_mode,
+  d_mode,
+  d_mode,
+  /* d9 */
+  d_mode,
+  0,
+  d_mode,
+  d_mode,
+  0,
+  w_mode,
+  0,
+  w_mode,
+  /* da */
+  d_mode,
+  d_mode,
+  d_mode,
+  d_mode,
+  d_mode,
+  d_mode,
+  d_mode,
+  d_mode,
+  /* db */
+  d_mode,
+  d_mode,
+  d_mode,
+  d_mode,
+  0,
+  x_mode,
+  0,
+  x_mode,
+  /* dc */
+  q_mode,
+  q_mode,
+  q_mode,
+  q_mode,
+  q_mode,
+  q_mode,
+  q_mode,
+  q_mode,
+  /* dd */
+  q_mode,
+  q_mode,
+  q_mode,
+  q_mode,
+  0,
+  0,
+  0,
+  w_mode,
+  /* de */
+  w_mode,
+  w_mode,
+  w_mode,
+  w_mode,
+  w_mode,
+  w_mode,
+  w_mode,
+  w_mode,
+  /* df */
+  w_mode,
+  w_mode,
+  w_mode,
+  w_mode,
+  x_mode,
+  q_mode,
+  x_mode,
+  q_mode
 };
 
 #define ST OP_ST, 0
@@ -2567,14 +2642,11 @@ dofloat (int sizeflag)
 
   if (mod != 3)
     {
-      putop (float_mem[(floatop - 0xd8) * 8 + reg], sizeflag);
+      int fp_indx = (floatop - 0xd8) * 8 + reg;
+
+      putop (float_mem[fp_indx], sizeflag);
       obufp = op1out;
-      if (floatop == 0xdb)
-	OP_E (x_mode, sizeflag);
-      else if (floatop == 0xdd)
-	OP_E (d_mode, sizeflag);
-      else
-	OP_E (v_mode, sizeflag);
+      OP_E (float_mem_mode[fp_indx], sizeflag);
       return;
     }
   /* Skip mod/rm byte.  */
@@ -3135,9 +3207,15 @@ OP_E (int bytemode, int sizeflag)
 		  oappend ("WORD PTR ");
 		  break;
 		case v_mode:
-		  oappend ("DWORD PTR ");
+		  if (sizeflag & DFLAG)
+		    oappend ("DWORD PTR ");
+		  else
+		    oappend ("WORD PTR ");
 		  break;
 		case d_mode:
+		  oappend ("DWORD PTR ");
+		  break;
+		case q_mode:
 		  oappend ("QWORD PTR ");
 		  break;
 		case m_mode:
@@ -3776,11 +3854,8 @@ static void
 ptr_reg (int code, int sizeflag)
 {
   const char *s;
-  if (intel_syntax)
-    oappend ("[");
-  else
-    oappend ("(");
 
+  *obufp++ = open_char;
   USED_REX (REX_MODE64);
   if (rex & REX_MODE64)
     {
@@ -3794,10 +3869,8 @@ ptr_reg (int code, int sizeflag)
   else
     s = names16[code - eAX_reg];
   oappend (s);
-  if (intel_syntax)
-    oappend ("]");
-  else
-    oappend (")");
+  *obufp++ = close_char;
+  *obufp = 0;
 }
 
 static void
@@ -4162,21 +4235,29 @@ SIMD_Fixup (int extrachar, int sizeflag 
 static void
 PNI_Fixup (int extrachar ATTRIBUTE_UNUSED, int sizeflag)
 {
-  if (mod == 3 && reg == 1)
+  if (mod == 3 && reg == 1 && rm <= 1)
     {
-      char *p = obuf + strlen (obuf);
-
       /* Override "sidt".  */
+      char *p = obuf + strlen (obuf) - 4;
+
+      /* We might have a suffix.  */
+      if (*p == 'i')
+	--p;
+
       if (rm)
 	{
 	  /* mwait %eax,%ecx  */
-	  strcpy (p - 4, "mwait   %eax,%ecx");
+	  strcpy (p, "mwait");
 	}
       else
 	{
 	  /* monitor %eax,%ecx,%edx"  */
-	  strcpy (p - 4, "monitor %eax,%ecx,%edx");
+	  strcpy (p, "monitor");
+	  strcpy (op3out, names32[2]);
 	}
+      strcpy (op1out, names32[0]);
+      strcpy (op2out, names32[1]);
+      two_source_ops = 1;
 
       codep++;
     }
Index: gas/testsuite/gas/i386/prescott.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/i386/prescott.d,v
retrieving revision 1.2
diff -u -p -r1.2 prescott.d
--- gas/testsuite/gas/i386/prescott.d	18 Jan 2004 23:13:35 -0000	1.2
+++ gas/testsuite/gas/i386/prescott.d	23 Jun 2004 14:42:18 -0000
@@ -13,25 +13,24 @@ Disassembly of section .text:
   10:	df 88 90 90 90 90 [ 	]*fisttp 0x90909090\(%eax\)
   16:	db 88 90 90 90 90 [ 	]*fisttpl 0x90909090\(%eax\)
   1c:	dd 88 90 90 90 90 [ 	]*fisttpll 0x90909090\(%eax\)
-  22:	dd 88 90 90 90 90 [ 	]*fisttpll 0x90909090\(%eax\)
-  28:	dd 88 90 90 90 90 [ 	]*fisttpll 0x90909090\(%eax\)
-  2e:	66 0f 7c 65 00 [ 	]*haddpd 0x0\(%ebp\),%xmm4
-  33:	66 0f 7c ee [ 	]*haddpd %xmm6,%xmm5
-  37:	f2 0f 7c 37 [ 	]*haddps \(%edi\),%xmm6
-  3b:	f2 0f 7c f8 [ 	]*haddps %xmm0,%xmm7
-  3f:	66 0f 7d c1 [ 	]*hsubpd %xmm1,%xmm0
-  43:	66 0f 7d 0a [ 	]*hsubpd \(%edx\),%xmm1
-  47:	f2 0f 7d d2 [ 	]*hsubps %xmm2,%xmm2
-  4b:	f2 0f 7d 1c 24 [ 	]*hsubps \(%esp\),%xmm3
-  50:	f2 0f f0 2e [ 	]*lddqu  \(%esi\),%xmm5
-  54:	0f 01 c8 [ 	]*monitor %eax,%ecx,%edx 
-  57:	0f 01 c8 [ 	]*monitor %eax,%ecx,%edx 
-  5a:	f2 0f 12 f7 [ 	]*movddup %xmm7,%xmm6
-  5e:	f2 0f 12 38 [ 	]*movddup \(%eax\),%xmm7
-  62:	f3 0f 16 01 [ 	]*movshdup \(%ecx\),%xmm0
-  66:	f3 0f 16 ca [ 	]*movshdup %xmm2,%xmm1
-  6a:	f3 0f 12 13 [ 	]*movsldup \(%ebx\),%xmm2
-  6e:	f3 0f 12 dc [ 	]*movsldup %xmm4,%xmm3
-  72:	0f 01 c9 [ 	]*mwait   %eax,%ecx 
-  75:	0f 01 c9 [ 	]*mwait   %eax,%ecx 
+  22:	66 0f 7c 65 00 [ 	]*haddpd 0x0\(%ebp\),%xmm4
+  27:	66 0f 7c ee [ 	]*haddpd %xmm6,%xmm5
+  2b:	f2 0f 7c 37 [ 	]*haddps \(%edi\),%xmm6
+  2f:	f2 0f 7c f8 [ 	]*haddps %xmm0,%xmm7
+  33:	66 0f 7d c1 [ 	]*hsubpd %xmm1,%xmm0
+  37:	66 0f 7d 0a [ 	]*hsubpd \(%edx\),%xmm1
+  3b:	f2 0f 7d d2 [ 	]*hsubps %xmm2,%xmm2
+  3f:	f2 0f 7d 1c 24 [ 	]*hsubps \(%esp\),%xmm3
+  44:	f2 0f f0 2e [ 	]*lddqu  \(%esi\),%xmm5
+  48:	0f 01 c8 [ 	]*monitor %eax,%ecx,%edx
+  4b:	0f 01 c8 [ 	]*monitor %eax,%ecx,%edx
+  4e:	f2 0f 12 f7 [ 	]*movddup %xmm7,%xmm6
+  52:	f2 0f 12 38 [ 	]*movddup \(%eax\),%xmm7
+  56:	f3 0f 16 01 [ 	]*movshdup \(%ecx\),%xmm0
+  5a:	f3 0f 16 ca [ 	]*movshdup %xmm2,%xmm1
+  5e:	f3 0f 12 13 [ 	]*movsldup \(%ebx\),%xmm2
+  62:	f3 0f 12 dc [ 	]*movsldup %xmm4,%xmm3
+  66:	0f 01 c9 [ 	]*mwait  %eax,%ecx
+  69:	0f 01 c9 [ 	]*mwait  %eax,%ecx
+  6c:	00 00 [ 	]*add    %al,\(%eax\)
 	...
Index: gas/testsuite/gas/i386/prescott.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/i386/prescott.s,v
retrieving revision 1.1
diff -u -p -r1.1 prescott.s
--- gas/testsuite/gas/i386/prescott.s	23 Jun 2003 20:15:33 -0000	1.1
+++ gas/testsuite/gas/i386/prescott.s	23 Jun 2004 14:42:19 -0000
@@ -8,8 +8,6 @@ foo:
 	addsubps	%xmm4,%xmm3
 	fisttp		0x90909090(%eax)
 	fisttpl		0x90909090(%eax)
-	fisttpd		0x90909090(%eax)
-	fisttpq		0x90909090(%eax)
 	fisttpll	0x90909090(%eax)
 	haddpd		0x0(%ebp),%xmm4
 	haddpd		%xmm6,%xmm5


-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

       reply	other threads:[~2004-06-23 15:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <s0d98755.098@emea1-mh.id2.novell.com>
2004-06-23 15:03 ` Alan Modra [this message]
2004-11-02 17:02 Jan Beulich
  -- strict thread matches above, loose matches on Subject: below --
2004-10-18 13:23 Jan Beulich
2004-10-21 11:43 ` Alan Modra
2004-10-13  8:37 Jan Beulich
2004-10-15  5:04 ` Alan Modra
2004-06-23 12:36 Jan Beulich
2004-06-15 12:14 Jan Beulich
2004-06-23  1:24 ` Alan Modra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040623150348.GW3596@bubble.modra.org \
    --to=amodra@bigpond.net.au \
    --cc=JBeulich@novell.com \
    --cc=binutils@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).