Home | History | Annotate | Download | only in X86
      1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
      2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mcpu=generic | FileCheck %s --check-prefix=X86
      3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=generic | FileCheck %s --check-prefix=X64
      4 
      5 ; Verify that we correctly lower ISD::READCYCLECOUNTER.
      6 
      7 
      8 define i64 @test_builtin_readcyclecounter() {
      9 ; X86-LABEL: test_builtin_readcyclecounter:
     10 ; X86:       # %bb.0:
     11 ; X86-NEXT:    rdtsc
     12 ; X86-NEXT:    retl
     13 ;
     14 ; X64-LABEL: test_builtin_readcyclecounter:
     15 ; X64:       # %bb.0:
     16 ; X64-NEXT:    rdtsc
     17 ; X64-NEXT:    shlq $32, %rdx
     18 ; X64-NEXT:    orq %rdx, %rax
     19 ; X64-NEXT:    retq
     20   %1 = tail call i64 @llvm.readcyclecounter()
     21   ret i64 %1
     22 }
     23 
     24 ; Verify that we correctly lower the Read Cycle Counter GCC x86 builtins
     25 ; (i.e. RDTSC and RDTSCP).
     26 
     27 define i64 @test_builtin_rdtsc() {
     28 ; X86-LABEL: test_builtin_rdtsc:
     29 ; X86:       # %bb.0:
     30 ; X86-NEXT:    rdtsc
     31 ; X86-NEXT:    retl
     32 ;
     33 ; X64-LABEL: test_builtin_rdtsc:
     34 ; X64:       # %bb.0:
     35 ; X64-NEXT:    rdtsc
     36 ; X64-NEXT:    shlq $32, %rdx
     37 ; X64-NEXT:    orq %rdx, %rax
     38 ; X64-NEXT:    retq
     39   %1 = tail call i64 @llvm.x86.rdtsc()
     40   ret i64 %1
     41 }
     42 
     43 define i64 @test_builtin_rdtscp(i8* %A) {
     44 ; X86-LABEL: test_builtin_rdtscp:
     45 ; X86:       # %bb.0:
     46 ; X86-NEXT:    pushl %esi
     47 ; X86-NEXT:    .cfi_def_cfa_offset 8
     48 ; X86-NEXT:    .cfi_offset %esi, -8
     49 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
     50 ; X86-NEXT:    rdtscp
     51 ; X86-NEXT:    movl %ecx, (%esi)
     52 ; X86-NEXT:    popl %esi
     53 ; X86-NEXT:    .cfi_def_cfa_offset 4
     54 ; X86-NEXT:    retl
     55 ;
     56 ; X64-LABEL: test_builtin_rdtscp:
     57 ; X64:       # %bb.0:
     58 ; X64-NEXT:    rdtscp
     59 ; X64-NEXT:    movl %ecx, (%rdi)
     60 ; X64-NEXT:    shlq $32, %rdx
     61 ; X64-NEXT:    orq %rdx, %rax
     62 ; X64-NEXT:    retq
     63   %1 = tail call i64 @llvm.x86.rdtscp(i8* %A)
     64   ret i64 %1
     65 }
     66 
     67 declare i64 @llvm.readcyclecounter()
     68 declare i64 @llvm.x86.rdtscp(i8*)
     69 declare i64 @llvm.x86.rdtsc()
     70 
     71