driver-alpha.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* Subroutines for the gcc driver.
  2. Copyright (C) 2009-2015 Free Software Foundation, Inc.
  3. Contributed by Arthur Loiret <aloiret@debian.org>
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. GCC is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GCC; see the file COPYING3. If not see
  15. <http://www.gnu.org/licenses/>. */
  16. #include "config.h"
  17. #include "system.h"
  18. #include "coretypes.h"
  19. #include "tm.h"
  20. /* Chip family type IDs, returned by implver instruction. */
  21. #define IMPLVER_EV4_FAMILY 0 /* LCA/EV4/EV45 */
  22. #define IMPLVER_EV5_FAMILY 1 /* EV5/EV56/PCA56 */
  23. #define IMPLVER_EV6_FAMILY 2 /* EV6 */
  24. #define IMPLVER_EV7_FAMILY 3 /* EV7 */
  25. /* Bit defines for amask instruction. */
  26. #define AMASK_BWX 0x1 /* byte/word extension. */
  27. #define AMASK_FIX 0x2 /* sqrt and f <-> i conversions
  28. extension. */
  29. #define AMASK_CIX 0x4 /* count extension. */
  30. #define AMASK_MVI 0x100 /* multimedia extension. */
  31. #define AMASK_PRECISE 0x200 /* Precise arithmetic traps. */
  32. #define AMASK_LOCKPFTCHOK 0x1000 /* Safe to prefetch lock cache
  33. block. */
  34. /* This will be called by the spec parser in gcc.c when it sees
  35. a %:local_cpu_detect(args) construct. Currently it will be called
  36. with either "cpu" or "tune" as argument depending on if -mcpu=native
  37. or -mtune=native is to be substituted.
  38. It returns a string containing new command line parameters to be
  39. put at the place of the above two options, depending on what CPU
  40. this is executed. E.g. "-mcpu=ev6" on an Alpha 21264 for
  41. -mcpu=native. If the routine can't detect a known processor,
  42. the -mcpu or -mtune option is discarded.
  43. ARGC and ARGV are set depending on the actual arguments given
  44. in the spec. */
  45. const char *
  46. host_detect_local_cpu (int argc, const char **argv)
  47. {
  48. static const struct cpu_types {
  49. long implver;
  50. long amask;
  51. const char *const cpu;
  52. } cpu_types[] = {
  53. { IMPLVER_EV7_FAMILY, AMASK_BWX|AMASK_MVI|AMASK_FIX|AMASK_CIX, "ev67" },
  54. { IMPLVER_EV6_FAMILY, AMASK_BWX|AMASK_MVI|AMASK_FIX|AMASK_CIX, "ev67" },
  55. { IMPLVER_EV6_FAMILY, AMASK_BWX|AMASK_MVI|AMASK_FIX, "ev6" },
  56. { IMPLVER_EV5_FAMILY, AMASK_BWX|AMASK_MVI, "pca56" },
  57. { IMPLVER_EV5_FAMILY, AMASK_BWX, "ev56" },
  58. { IMPLVER_EV5_FAMILY, 0, "ev5" },
  59. { IMPLVER_EV4_FAMILY, 0, "ev4" },
  60. { 0, 0, NULL }
  61. };
  62. long implver;
  63. long amask;
  64. const char *cpu;
  65. int i;
  66. if (argc < 1)
  67. return NULL;
  68. if (strcmp (argv[0], "cpu") && strcmp (argv[0], "tune"))
  69. return NULL;
  70. implver = __builtin_alpha_implver ();
  71. amask = __builtin_alpha_amask (~0L);
  72. cpu = NULL;
  73. for (i = 0; cpu_types[i].cpu != NULL; i++)
  74. if (implver == cpu_types[i].implver
  75. && (~amask & cpu_types[i].amask) == cpu_types[i].amask)
  76. {
  77. cpu = cpu_types[i].cpu;
  78. break;
  79. }
  80. if (cpu == NULL)
  81. return NULL;
  82. return concat ("-m", argv[0], "=", cpu, NULL);
  83. }