343cc1
commit 6effbc703b711779a196e5dbaf6335f39fab71c2
343cc1
Author: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
343cc1
Date:   Tue Jan 16 11:19:51 2018 +0000
343cc1
343cc1
    HJ patch #4
343cc1
343cc1
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
343cc1
index 9dffd02f..e73389b 100644
343cc1
--- a/gcc/config/i386/i386.c
343cc1
+++ b/gcc/config/i386/i386.c
343cc1
@@ -14497,6 +14497,7 @@ put_condition_code (enum rtx_code code, enum machine_mode mode, bool reverse,
343cc1
    If CODE is 'h', pretend the reg is the 'high' byte register.
343cc1
    If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op.
343cc1
    If CODE is 'd', duplicate the operand for AVX instruction.
343cc1
+   If CODE is 'V', print naked full integer register name without %.
343cc1
  */
343cc1
 
343cc1
 void
343cc1
@@ -14506,7 +14507,7 @@ print_reg (rtx x, int code, FILE *file)
343cc1
   unsigned int regno;
343cc1
   bool duplicated = code == 'd' && TARGET_AVX;
343cc1
 
343cc1
-  if (ASSEMBLER_DIALECT == ASM_ATT)
343cc1
+  if (ASSEMBLER_DIALECT == ASM_ATT && code != 'V')
343cc1
     putc ('%', file);
343cc1
 
343cc1
   if (x == pc_rtx)
343cc1
@@ -14542,6 +14543,14 @@ print_reg (rtx x, int code, FILE *file)
343cc1
   else
343cc1
     code = GET_MODE_SIZE (GET_MODE (x));
343cc1
 
343cc1
+  if (code == 'V')
343cc1
+    {
343cc1
+      if (GENERAL_REGNO_P (regno))
343cc1
+	code = GET_MODE_SIZE (word_mode);
343cc1
+      else
343cc1
+	error ("'V' modifier on non-integer register");
343cc1
+    }
343cc1
+
343cc1
   /* Irritatingly, AMD extended registers use different naming convention
343cc1
      from the normal registers: "r%d[bwd]"  */
343cc1
   if (REX_INT_REGNO_P (regno))
343cc1
@@ -14695,6 +14704,7 @@ get_some_local_dynamic_name (void)
343cc1
    & -- print some in-use local-dynamic symbol name.
343cc1
    H -- print a memory address offset by 8; used for sse high-parts
343cc1
    Y -- print condition for XOP pcom* instruction.
343cc1
+   V -- print naked full integer register name without %.
343cc1
    + -- print a branch hint as 'cs' or 'ds' prefix
343cc1
    ; -- print a semicolon (after prefixes due to bug in older gas).
343cc1
    ~ -- print "i" if TARGET_AVX2, "f" otherwise.
343cc1
@@ -14919,6 +14929,7 @@ ix86_print_operand (FILE *file, rtx x, int code)
343cc1
 	case 'X':
343cc1
 	case 'P':
343cc1
 	case 'p':
343cc1
+	case 'V':
343cc1
 	  break;
343cc1
 
343cc1
 	case 's':
343cc1
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
343cc1
new file mode 100644
343cc1
index 0000000..f0cd9b7
343cc1
--- /dev/null
343cc1
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
343cc1
@@ -0,0 +1,13 @@
343cc1
+/* { dg-do compile } */
343cc1
+/* { dg-options "-O2 -mindirect-branch=keep -fno-pic" } */
343cc1
+
343cc1
+extern void (*func_p) (void);
343cc1
+
343cc1
+void
343cc1
+foo (void)
343cc1
+{
343cc1
+  asm("call __x86_indirect_thunk_%V0" : : "a" (func_p));
343cc1
+}
343cc1
+
343cc1
+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_eax" { target ia32 } } } */
343cc1
+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_rax" { target { ! ia32 } } } } */