[LLVMbugs] [Bug 8874] New: Needs to support "register uint64_t foo asm("r8")"

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Dec 29 21:32:41 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=8874

           Summary: Needs to support "register uint64_t foo asm("r8")"
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: rafael.espindola at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Unfortunately there is no simple constraint for using r8 (or higher) on x86-64,
and therefore one has to write code like

---------------------------------
uint64_t foo(uint64_t addr, uint64_t a0, uint64_t a1, uint64_t a2,
             uint64_t a3, uint64_t a4, uint64_t a5) {
  register uint64_t result asm("rax");
  register uint64_t b0 asm("rdi");
  register uint64_t b1 asm("rsi");
  register uint64_t b2 asm("rdx");
  register uint64_t b3 asm("rcx");
  register uint64_t b4 asm("r8");
  register uint64_t b5 asm("r9");

  b0 = a0;
  b1 = a1;
  b2 = a2;
  b3 = a3;
  b4 = a4;
  b5 = a5;

  asm("call *%0" : "=r" (result)
      : "r"(addr), "r" (a0), "r" (b1), "r" (b2), "r" (b3), "r" (b4), "r" (b5));
  return result;
}
-------------------------------


Which gcc compiles to

        movq    %rsi, %rax
        movq    %rdx, %rsi
        movq    %rcx, %rdx
        movq    %r8, %rcx
        movq    %r9, %r8
        movq    8(%rsp), %r9
        call *%rax
        ret

This is all that has implemented, so hopefully it can be done by transforming
that asm("register") in a note that does nothing unless the variable is used in
inline assembly.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list