[patch] Fixes for -mintel-syntax on i386

Diego Novillo dnovillo@cygnus.com
Tue Oct 24 15:01:00 GMT 2000


This patch fixes a few problems when emitting intel assembly on
i386. Together with the assembler patch I posted this morning
( http://sources.redhat.com/ml/binutils/2000-10/msg00246.html ) it
allows us to run c-torture without regressions with
-mintel-syntax enabled.

There are a few AT&T-isms remaining in libgcc that I still need
to fix to be able to bootstrap with -mintel-syntax.


2000-10-23  Diego Novillo  <dnovillo@cygnus.com>

	* i386.c (print_operand): Handle new 'A' formatting code.
	387 opcodes need suffixes even with -mintel-syntax.
	Check for explicit size override (codes 'b', 'w' and 'k').
	(print_operand_address): Check if register prefix is needed when
	emitting `ds' segment override.
	* i386.h: Add comment about new 'A' formatting code.
	* i386.md (jump and call patterns): Emit absolute references using %A.

Index: i386.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.c,v
retrieving revision 1.184
diff -d -c -p -r1.184 i386.c
*** i386.c	2000/10/18 05:11:37	1.184
--- i386.c	2000/10/24 21:43:57
*************** print_reg (x, code, file)
*** 3250,3255 ****
--- 3250,3256 ----
     R -- print the prefix for register names.
     z -- print the opcode suffix for the size of the current operand.
     * -- print a star (in certain assembler syntax)
+    A -- print an absolute memory reference.
     w -- print the operand as if it's a "word" (HImode) even if it isn't.
     s -- print a shift double count, followed by the assemblers argument
  	delimiter.
*************** print_operand (file, x, code)
*** 3276,3281 ****
--- 3277,3302 ----
  	    putc ('*', file);
  	  return;
  
+ 	case 'A':
+ 	  if (ASSEMBLER_DIALECT == 0)
+ 	    putc ('*', file);
+ 	  else if (ASSEMBLER_DIALECT == 1)
+ 	    {
+ 	      /* Intel syntax. For absolute addresses, registers should not
+ 		 be surrounded by braces.  */
+ 	      if (GET_CODE (x) != REG)
+ 		{
+ 		  putc ('[', file);
+ 		  PRINT_OPERAND (file, x, 0);
+ 		  putc (']', file);
+ 		  return;
+ 		}
+ 	    }
+ 
+ 	  PRINT_OPERAND (file, x, 0);
+ 	  return;
+ 
+ 
  	case 'L':
  	  if (ASSEMBLER_DIALECT == 0)
  	    putc ('l', file);
*************** print_operand (file, x, code)
*** 3313,3322 ****
  	  if (STACK_REG_P (x))
  	    return;
  
- 	  /* Intel syntax has no truck with instruction suffixes.  */
- 	  if (ASSEMBLER_DIALECT != 0)
- 	    return;
- 
  	  /* this is the size of op from size of operand */
  	  switch (GET_MODE_SIZE (GET_MODE (x)))
  	    {
--- 3334,3339 ----
*************** print_operand (file, x, code)
*** 3422,3427 ****
--- 3439,3453 ----
  	    default:
  	      abort ();
  	    }
+ 
+ 	  /* Check for explicit size override (codes 'b', 'w' and 'k')  */
+ 	  if (code == 'b')
+ 	    size = "BYTE";
+ 	  else if (code == 'w')
+ 	    size = "WORD";
+ 	  else if (code == 'k')
+ 	    size = "DWORD";
+ 
  	  fputs (size, file);
  	  fputs (" PTR ", file);
  	}
*************** print_operand_address (file, addr)
*** 3519,3525 ****
        if (GET_CODE (disp) == CONST_INT)
  	{
  	  if (ASSEMBLER_DIALECT != 0)
! 	    fputs ("ds:", file);
  	  fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (addr));
  	}
        else if (flag_pic)
--- 3545,3555 ----
        if (GET_CODE (disp) == CONST_INT)
  	{
  	  if (ASSEMBLER_DIALECT != 0)
! 	    {
! 	      if (USER_LABEL_PREFIX[0] == 0)
! 		putc ('%', file);
! 	      fputs ("ds:", file);
! 	    }
  	  fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (addr));
  	}
        else if (flag_pic)
Index: i386.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.h,v
retrieving revision 1.134
diff -d -c -p -r1.134 i386.h
*** i386.h	2000/10/19 12:27:28	1.134
--- i386.h	2000/10/24 21:43:58
*************** do { long l;						\
*** 2723,2728 ****
--- 2723,2729 ----
     R -- print the prefix for register names.
     z -- print the opcode suffix for the size of the current operand.
     * -- print a star (in certain assembler syntax)
+    A -- print an absolute memory reference.
     P -- if PIC, print an @PLT suffix.
     X -- don't print any sort of PIC '@' suffix for a symbol.
     s -- ??? something to do with double shifts.  not actually used, afaik.
Index: i386.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.md,v
retrieving revision 1.187
diff -d -c -p -r1.187 i386.md
*** i386.md	2000/10/18 05:11:37	1.187
--- i386.md	2000/10/24 21:44:00
***************
*** 8662,8668 ****
  (define_insn "indirect_jump"
    [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))]
    ""
!   "jmp\\t%*%0"
    [(set_attr "type" "ibr")
     (set_attr "length_immediate" "0")])
  
--- 8662,8668 ----
  (define_insn "indirect_jump"
    [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))]
    ""
!   "jmp\\t%A0"
    [(set_attr "type" "ibr")
     (set_attr "length_immediate" "0")])
  
***************
*** 8670,8676 ****
    [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))
     (use (label_ref (match_operand 1 "" "")))]
    "! flag_pic"
!   "jmp\\t%*%0"
    [(set_attr "type" "ibr")
     (set_attr "length_immediate" "0")])
  
--- 8670,8676 ----
    [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))
     (use (label_ref (match_operand 1 "" "")))]
    "! flag_pic"
!   "jmp\\t%A0"
    [(set_attr "type" "ibr")
     (set_attr "length_immediate" "0")])
  
***************
*** 8744,8750 ****
    [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))
     (use (label_ref (match_operand 1 "" "")))]
    ""
!   "jmp\\t%*%0"
    [(set_attr "type" "ibr")
     (set_attr "length_immediate" "0")])
  
--- 8744,8750 ----
    [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))
     (use (label_ref (match_operand 1 "" "")))]
    ""
!   "jmp\\t%A0"
    [(set_attr "type" "ibr")
     (set_attr "length_immediate" "0")])
  
***************
*** 8915,8923 ****
  	return \"call\\t%P0\";
      }
    if (SIBLING_CALL_P (insn))
!     return \"jmp\\t%*%0\";
    else
!     return \"call\\t%*%0\";
  }"
    [(set_attr "type" "call")])
  
--- 8915,8923 ----
  	return \"call\\t%P0\";
      }
    if (SIBLING_CALL_P (insn))
!     return \"jmp\\t%A0\";
    else
!     return \"call\\t%A0\";
  }"
    [(set_attr "type" "call")])
  
***************
*** 8965,8973 ****
  	return \"call\\t%P0\";
      }
    if (SIBLING_CALL_P (insn))
!     return \"jmp\\t%*%0\";
    else
!     return \"call\\t%*%0\";
  }"
    [(set_attr "type" "call")])
  
--- 8965,8973 ----
  	return \"call\\t%P0\";
      }
    if (SIBLING_CALL_P (insn))
!     return \"jmp\\t%A0\";
    else
!     return \"call\\t%A0\";
  }"
    [(set_attr "type" "call")])
  
***************
*** 9103,9109 ****
    [(return)
     (use (match_operand:SI 0 "register_operand" "r"))]
    "reload_completed"
!   "jmp\\t%*%0"
    [(set_attr "type" "ibr")
     (set_attr "length_immediate" "0")])
  
--- 9103,9109 ----
    [(return)
     (use (match_operand:SI 0 "register_operand" "r"))]
    "reload_completed"
!   "jmp\\t%A0"
    [(set_attr "type" "ibr")
     (set_attr "length_immediate" "0")])
  
***************
*** 11546,11554 ****
  	return \"call\\t%P1\";
      }
    if (SIBLING_CALL_P (insn))
!     return \"jmp\\t%*%1\";
    else
!     return \"call\\t%*%1\";
  }"
    [(set_attr "type" "callv")])
  
--- 11546,11554 ----
  	return \"call\\t%P1\";
      }
    if (SIBLING_CALL_P (insn))
!     return \"jmp\\t%A1\";
    else
!     return \"call\\t%A1\";
  }"
    [(set_attr "type" "callv")])
  
***************
*** 11581,11589 ****
  	return \"call\\t%P1\";
      }
    if (SIBLING_CALL_P (insn))
!     return \"jmp\\t%*%1\";
    else
!     return \"call\\t%*%1\";
  }"
    [(set_attr "type" "callv")])
  
--- 11581,11589 ----
  	return \"call\\t%P1\";
      }
    if (SIBLING_CALL_P (insn))
!     return \"jmp\\t%A1\";
    else
!     return \"call\\t%A1\";
  }"
    [(set_attr "type" "callv")])
  


More information about the Gcc-patches mailing list