Home | History | Annotate | Download | only in CodeGen
      1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
      2 
      3 unsigned long long foo(unsigned long long addr, unsigned long long a0,
      4                        unsigned long long a1, unsigned long long a2,
      5                        unsigned long long a3, unsigned long long a4,
      6                        unsigned long long a5) {
      7   register unsigned long long result asm("rax");
      8   register unsigned long long b0 asm("rdi");
      9   register unsigned long long b1 asm("rsi");
     10   register unsigned long long b2 asm("rdx");
     11   register unsigned long long b3 asm("rcx");
     12   register unsigned long long b4 asm("r8");
     13   register unsigned long long b5 asm("r9");
     14 
     15   b0 = a0;
     16   b1 = a1;
     17   b2 = a2;
     18   b3 = a3;
     19   b4 = a4;
     20   b5 = a5;
     21 
     22   asm("call *%1" : "=r" (result)
     23       : "r"(addr), "r" (b0), "r" (b1), "r" (b2), "r" (b3), "r" (b4), "r" (b5));
     24   return result;
     25 }
     26 
     27 // CHECK: call i64 asm "call *$1", "={rax},r,{rdi},{rsi},{rdx},{rcx},{r8},{r9},~{dirflag},~{fpsr},~{flags}"
     28 
     29 unsigned long long foo2(unsigned long long addr, double a0,
     30                        double a1, double a2,
     31                        double a3, double a4,
     32                        double a5, double a6, double a7) {
     33   register double b0 asm("xmm0");
     34   register double b1 asm("xmm1");
     35   register double b2 asm("xmm2");
     36   register double b3 asm("xmm3");
     37   register double b4 asm("xmm4");
     38   register double b5 asm("xmm5");
     39   register double b6 asm("xmm6");
     40   register double b7 asm("xmm7");
     41 
     42   register unsigned long long result asm("rax");
     43 
     44   b0 = a0;
     45   b1 = a1;
     46   b2 = a2;
     47   b3 = a3;
     48   b4 = a4;
     49   b5 = a5;
     50   b6 = a6;
     51   b7 = a7;
     52 
     53   asm("call *%1" : "=r" (result)
     54       : "r"(addr), "x" (b0), "x" (b1), "x" (b2), "x" (b3), "x" (b4), "x" (b5), "x" (b6),
     55         "x" (b7));
     56   return result;
     57 }
     58 
     59 // CHECK: call i64 asm "call *$1", "={rax},r,{xmm0},{xmm1},{xmm2},{xmm3},{xmm4},{xmm5},{xmm6},{xmm7},~{dirflag},~{fpsr},~{flags}
     60 
     61 int randomvar asm("randomvar");
     62 void foo3() {
     63   asm("vartest %0" : : "r"(randomvar));
     64 }
     65 // CHECK: call void asm sideeffect "vartest $0", "r,~{dirflag},~{fpsr},~{flags}"
     66