]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/debugserver/source/MacOSX/HasAVX.s
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / tools / debugserver / source / MacOSX / HasAVX.s
1 //===-- HasAVX.s ---------------------------------------*- x86 Assembly -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #if defined (__i386__) || defined (__x86_64__)
11
12 .globl _HasAVX
13
14 _HasAVX:
15 #if defined (__x86_64__)
16     pushq %rbp
17     movq %rsp, %rbp
18     pushq %rbx
19 #else
20     pushl %ebp
21     movl %esp, %ebp
22     pushl %ebx
23 #endif
24     mov $1, %eax
25     cpuid                                                                       // clobbers ebx
26     and $0x018000000, %ecx
27     cmp $0x018000000, %ecx
28     jne not_supported
29     mov $0, %ecx
30 .byte 0x0f, 0x01, 0xd0    // xgetbv, for those assemblers that don't know it
31     and $0x06, %eax
32     cmp $0x06, %eax
33     jne not_supported
34     mov $1, %eax
35     jmp done
36 not_supported:
37     mov $0, %eax
38 done:
39 #if defined (__x86_64__)
40     popq %rbx
41     movq %rbp, %rsp
42     popq %rbp
43 #else
44     popl %ebx
45     movl %ebp, %esp
46     popl %ebp
47 #endif
48     ret                                                                         // return
49
50 #endif