tools/cpuflags.c
branchpyrit
changeset 70 4b84e90325c5
parent 68 2c154aad7f33
child 103 3b3257a410fe
equal deleted inserted replaced
69:303583d2fb97 70:4b84e90325c5
   219      }
   219      }
   220      else if (family == 6)
   220      else if (family == 6)
   221      {
   221      {
   222        if (model <= 1) arch = "pentiumpro";
   222        if (model <= 1) arch = "pentiumpro";
   223        else if (model < 7) arch = "pentium2";
   223        else if (model < 7) arch = "pentium2";
   224        else if (model == 7) arch = "pentium3";
   224        else if (model < 12) arch = "pentium3";
   225        else if (model < 15) arch = "pentium-m";
   225        else if (model < 14) arch = "pentium-m";
   226        else if (model == 15)
   226        else if (model == 14) arch = "prescott"; // core
   227        {
   227        else if (model == 15) arch = "core2";
   228          if (stepping < 6) arch = "core";
       
   229          else arch = "core2";
       
   230        }
       
   231 
       
   232      }
   228      }
   233      else if (family > 6)
   229      else if (family > 6)
   234      { /* family == 15 */
   230      { /* family == 15 */
   235        arch = "pentium4";
   231        arch = "pentium4";
   236      }
   232      }
   293 
   289 
   294    /* some targets not supported by older gcc */
   290    /* some targets not supported by older gcc */
   295    gccarch = arch;
   291    gccarch = arch;
   296    if (gccver < (float)4.3)
   292    if (gccver < (float)4.3)
   297    {
   293    {
   298      if (!strcmp(gccarch, "core2")) gccarch = "pentium3";
   294      if (!strcmp(gccarch, "core2")) gccarch = "pentium-m";
       
   295    }
       
   296    if (gccver < (float)3.41)
       
   297    {
       
   298      if (!strcmp(gccarch, "prescott")) gccarch = "pentium4";
       
   299      if (!strcmp(gccarch, "pentium-m")) gccarch = "pentium4";
   299    }
   300    }
   300    if (gccver < (float)3.4)
   301    if (gccver < (float)3.4)
   301    {
   302    {
   302      if (!strcmp(gccarch, "k8")) gccarch = "athlon-xp";
   303      if (!strcmp(gccarch, "k8")) gccarch = "athlon-xp";
   303    }
   304    }
   312      else if (!strcmp(gccarch, "pentium2")
   313      else if (!strcmp(gccarch, "pentium2")
   313      || !strcmp(gccarch, "pentium3")
   314      || !strcmp(gccarch, "pentium3")
   314      || !strcmp(gccarch, "pentium4"))
   315      || !strcmp(gccarch, "pentium4"))
   315        gccarch = "pentiumpro";
   316        gccarch = "pentiumpro";
   316    }
   317    }
   317 
       
   318    if (gccver < (float)3.0)
   318    if (gccver < (float)3.0)
   319    {
   319    {
   320      if (!strcmp(gccarch, "athlon"))
   320      if (!strcmp(gccarch, "athlon"))
   321        gccarch = "pentiumpro";
   321        gccarch = "pentiumpro";
   322      else if (!strcmp(gccarch, "k6"))
   322      else if (!strcmp(gccarch, "k6"))
   323        gccarch = "pentium";
   323        gccarch = "pentium";
   324    }
   324    }
   325 
   325    if (gccver < (float)2.95)
   326    if (gccver < (float)2.9)
       
   327    {
   326    {
   328      if (!strcmp(gccarch, "pentiumpro"))
   327      if (!strcmp(gccarch, "pentiumpro"))
   329        gccarch = "i686";
   328        gccarch = "i686";
   330      else if (!strcmp(gccarch, "pentium"))
   329      else if (!strcmp(gccarch, "pentium"))
   331        gccarch = "i586";
   330        gccarch = "i586";
   349        else if ( simd.has_sse ) gccsimd = "-msse";
   348        else if ( simd.has_sse ) gccsimd = "-msse";
   350        else if ( simd.has_mmx ) gccsimd = "-mmmx";
   349        else if ( simd.has_mmx ) gccsimd = "-mmmx";
   351      }
   350      }
   352    }
   351    }
   353 
   352 
   354    /* intelc options */
   353    /* IntelC options */
   355    iccarch = arch;
   354    iccarch = arch;
   356    icctune = arch;
   355    icctune = arch;
   357    iccsimd = "";
   356    iccsimd = "";
   358    if (simd.has_sse41 || simd.has_sse42) iccsimd = "-xS";
   357    if (simd.has_sse41 || simd.has_sse42) iccsimd = "-xS";
   359    else if (simd.has_ssse3) iccsimd = "-xT";
   358    else if (simd.has_ssse3) iccsimd = "-xT";
   360    else if (simd.has_sse3) iccsimd = "-msse3 -xP";
   359    else if (simd.has_sse3) iccsimd = "-msse3 -xP";
   361    else if (simd.has_sse2) iccsimd = "-msse2";
   360    else if (simd.has_sse2) iccsimd = "-msse2";
   362 
   361 
   363    printf("%s\n", arch);
   362    printf("%s\n", arch);
       
   363 
       
   364    /* GCC flags */
   364    if (gccver >= 4.2) gccarch = "native";
   365    if (gccver >= 4.2) gccarch = "native";
   365    printf("-march=%s -mtune=%s %s\n", gccarch, gccarch, gccsimd);
   366 #ifdef __x86_64__
       
   367    /* do not output i386 flags on x86_64 */
       
   368    if (strcmp(gccarch, "core2") != 0 && strcmp(gccarch, "native") != 0)
       
   369      printf("%s\n", gccsimd);
       
   370    else
       
   371 #endif
       
   372    printf("-march=%s %s\n", gccarch, gccsimd);
       
   373 
       
   374    /* IntelC flags */
   366    printf("-march=%s -mtune=%s %s\n", iccarch, icctune, iccsimd);
   375    printf("-march=%s -mtune=%s %s\n", iccarch, icctune, iccsimd);
       
   376 
   367    return 0;
   377    return 0;
   368 }
   378 }