OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [i386-cpuid.h] - Blame information for rev 149

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Helper file for i386 platform.  Runtime check for MMX/SSE/SSE2 support.
2
   Used by 20020523-2.c and i386-sse-6.c, and possibly others.  */
3
/* Plagarized from 20020523-2.c.  */
4
 
5
/* %ecx */
6
#define bit_SSE3 (1 << 0)
7
 
8
/* %edx */
9
#define bit_CMOV (1 << 15)
10
#define bit_MMX (1 << 23)
11
#define bit_SSE (1 << 25)
12
#define bit_SSE2 (1 << 26)
13
 
14
#ifndef NOINLINE
15
#define NOINLINE __attribute__ ((noinline))
16
#endif
17
 
18
static inline unsigned int
19
i386_get_cpuid (unsigned int *ecx, unsigned int *edx)
20
{
21
  int fl1;
22
 
23
#ifndef __x86_64__
24
  int fl2;
25
 
26
  /* See if we can use cpuid.  On AMD64 we always can.  */
27
  __asm__ ("pushfl; pushfl; popl %0; movl %0,%1; xorl %2,%0;"
28
           "pushl %0; popfl; pushfl; popl %0; popfl"
29
           : "=&r" (fl1), "=&r" (fl2)
30
           : "i" (0x00200000));
31
  if (((fl1 ^ fl2) & 0x00200000) == 0)
32
    return (0);
33
#endif
34
 
35
  /* Host supports cpuid.  See if cpuid gives capabilities, try
36
     CPUID(0).  Preserve %ebx and %ecx; cpuid insn clobbers these, we
37
     don't need their CPUID values here, and %ebx may be the PIC
38
     register.  */
39
#ifdef __x86_64__
40
  __asm__ ("pushq %%rcx; pushq %%rbx; cpuid; popq %%rbx; popq %%rcx"
41
           : "=a" (fl1) : "0" (0) : "rdx", "cc");
42
#else
43
  __asm__ ("pushl %%ecx; pushl %%ebx; cpuid; popl %%ebx; popl %%ecx"
44
           : "=a" (fl1) : "0" (0) : "edx", "cc");
45
#endif
46
  if (fl1 == 0)
47
    return (0);
48
 
49
  /* Invoke CPUID(1), return %ecx and %edx; caller can examine bits to
50
     determine what's supported.  */
51
#ifdef __x86_64__
52
  __asm__ ("pushq %%rbx; cpuid; popq %%rbx"
53
           : "=c" (*ecx), "=d" (*edx), "=a" (fl1) : "2" (1) : "cc");
54
#else
55
  __asm__ ("pushl %%ebx; cpuid; popl %%ebx"
56
           : "=c" (*ecx), "=d" (*edx), "=a" (fl1) : "2" (1) : "cc");
57
#endif
58
 
59
  return 1;
60
}
61
 
62
unsigned int i386_cpuid_ecx (void) NOINLINE;
63
unsigned int i386_cpuid_edx (void) NOINLINE;
64
 
65
unsigned int NOINLINE
66
i386_cpuid_ecx (void)
67
{
68
  unsigned int ecx, edx;
69
  if (i386_get_cpuid (&ecx, &edx))
70
    return ecx;
71
  else
72
    return 0;
73
}
74
 
75
unsigned int NOINLINE
76
i386_cpuid_edx (void)
77
{
78
  unsigned int ecx, edx;
79
  if (i386_get_cpuid (&ecx, &edx))
80
    return edx;
81
  else
82
    return 0;
83
}
84
 
85
static inline unsigned int
86
i386_cpuid (void)
87
{
88
  return i386_cpuid_edx ();
89
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.