]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
x86: Add 'V' register operand modifier
authorH.J. Lu <hongjiu.lu@intel.com>
Mon, 16 Apr 2018 19:00:53 +0000 (19:00 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Mon, 16 Apr 2018 19:00:53 +0000 (12:00 -0700)
Add 'V', a special modifier which prints the name of the full integer
register without '%'.  For

extern void (*func_p) (void);

void
foo (void)
{
  asm ("call __x86_indirect_thunk_%V0" : : "a" (func_p));
}

it generates:

foo:
movq func_p(%rip), %rax
call __x86_indirect_thunk_rax
ret

gcc/

Backport from mainline
2018-01-14  H.J. Lu  <hongjiu.lu@intel.com>

* config/i386/i386.c (print_reg): Print the name of the full
integer register without '%'.
(ix86_print_operand): Handle 'V'.
 * doc/extend.texi: Document 'V' modifier.

gcc/testsuite/

Backport from mainline
2018-01-14  H.J. Lu  <hongjiu.lu@intel.com>

* gcc.target/i386/indirect-thunk-register-4.c: New test.

From-SVN: r259416

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/doc/extend.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c [new file with mode: 0644]

index 74f19a230063479a2d88821a9183974304706937..73561c24f123e7e0957fe935f4ef56dddee30e85 100644 (file)
@@ -1,3 +1,13 @@
+2018-04-16  H.J. Lu  <hongjiu.lu@intel.com>
+
+       Backport from mainline
+       2018-01-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * config/i386/i386.c (print_reg): Print the name of the full
+       integer register without '%'.
+       (ix86_print_operand): Handle 'V'.
+        * doc/extend.texi: Document 'V' modifier.
+
 2018-04-16  H.J. Lu  <hongjiu.lu@intel.com>
 
        Backport from mainline
index 34e26a3a3c7b25dc1f783a96e7a726bba8677ee7..eeca7e5e490753d96cf59297ef492801c60b7a57 100644 (file)
@@ -16869,6 +16869,7 @@ put_condition_code (enum rtx_code code, machine_mode mode, bool reverse,
    If CODE is 'h', pretend the reg is the 'high' byte register.
    If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op.
    If CODE is 'd', duplicate the operand for AVX instruction.
+   If CODE is 'V', print naked full integer register name without %.
  */
 
 void
@@ -16879,7 +16880,7 @@ print_reg (rtx x, int code, FILE *file)
   unsigned int regno;
   bool duplicated;
 
-  if (ASSEMBLER_DIALECT == ASM_ATT)
+  if (ASSEMBLER_DIALECT == ASM_ATT && code != 'V')
     putc ('%', file);
 
   if (x == pc_rtx)
@@ -16922,6 +16923,14 @@ print_reg (rtx x, int code, FILE *file)
              && regno != FPSR_REG
              && regno != FPCR_REG);
 
+  if (code == 'V')
+    {
+      if (GENERAL_REGNO_P (regno))
+       msize = GET_MODE_SIZE (word_mode);
+      else
+       error ("'V' modifier on non-integer register");
+    }
+
   duplicated = code == 'd' && TARGET_AVX;
 
   switch (msize)
@@ -17035,6 +17044,7 @@ print_reg (rtx x, int code, FILE *file)
    & -- print some in-use local-dynamic symbol name.
    H -- print a memory address offset by 8; used for sse high-parts
    Y -- print condition for XOP pcom* instruction.
+   V -- print naked full integer register name without %.
    + -- print a branch hint as 'cs' or 'ds' prefix
    ; -- print a semicolon (after prefixes due to bug in older gas).
    ~ -- print "i" if TARGET_AVX2, "f" otherwise.
@@ -17259,6 +17269,7 @@ ix86_print_operand (FILE *file, rtx x, int code)
        case 'X':
        case 'P':
        case 'p':
+       case 'V':
          break;
 
        case 's':
index 0c4e3562af0940f7bb294ce2a95c65e74f371594..146a5d9a9cddff0d823105bb98ca1be85268f43a 100644 (file)
@@ -8511,6 +8511,9 @@ The table below shows the list of supported modifiers and their effects.
 @tab @code{2}
 @end multitable
 
+@code{V} is a special modifier which prints the name of the full integer
+register without @code{%}.
+
 @anchor{x86floatingpointasmoperands}
 @subsubsection x86 Floating-Point @code{asm} Operands
 
index 472a351de1a9ab647c7ef04a591a1bd9fcec5cc6..c1a852f7b1dc648cad0dcba34caab82830ad939c 100644 (file)
@@ -1,3 +1,10 @@
+2018-04-16  H.J. Lu  <hongjiu.lu@intel.com>
+
+       Backport from mainline
+       2018-01-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * gcc.target/i386/indirect-thunk-register-4.c: New test.
+
 2018-04-16  H.J. Lu  <hongjiu.lu@intel.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
new file mode 100644 (file)
index 0000000..f0cd9b7
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mindirect-branch=keep -fno-pic" } */
+
+extern void (*func_p) (void);
+
+void
+foo (void)
+{
+  asm("call __x86_indirect_thunk_%V0" : : "a" (func_p));
+}
+
+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_eax" { target ia32 } } } */
+/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_rax" { target { ! ia32 } } } } */