示例#1
0
void find_cpu_mode(void){

  int f;
  if(Cpu_mode != UNKNOWN)
    return;
  else
    Cpu_mode = PORT;
#ifdef __i386__
  /* Figure out what kind of CPU we have */
  f = cpu_features();
  if(f & (1<<26)){ /* SSE2 is present */
    Cpu_mode = SSE2;
  } else if(f & (1<<25)){ /* SSE is present */
    Cpu_mode = SSE;
  } else if(f & (1<<23)){ /* MMX is present */
    Cpu_mode = MMX;
  }
#endif
//#ifdef __VEC__
#if 0
// This looks very Linux specific
  {
  /* Ask the OS if we have Altivec support */
  int selectors[2] = { CTL_HW, HW_VECTORUNIT };
  int hasVectorUnit = 0;
  size_t length = sizeof(hasVectorUnit);
  int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0);
  if(0 == error && hasVectorUnit)
    Cpu_mode = ALTIVEC;
  }
#endif
  fprintf(stderr,"SIMD CPU detect: %s\n",Cpu_modes[Cpu_mode]);
}
void find_cpu_mode(void) {

    int f;
    if(Cpu_mode != UNKNOWN)
        return;

    /* Figure out what kind of CPU we have */
    f = cpu_features();
    if(f & (1<<26)) { /* SSE2 is present */
        Cpu_mode = SSE2;
    } else if(f & (1<<25)) { /* SSE is present */
        Cpu_mode = SSE;
    } else if(f & (1<<23)) { /* MMX is present */
        Cpu_mode = MMX;
    } else { /* No SIMD at all */
        Cpu_mode = PORT;
    }
    fprintf(stderr,"SIMD CPU detect: %s\n",Cpu_modes[Cpu_mode]);
}
void VM_Version::print_features() {
  tty->print_cr("Version:%s", cpu_features());
}