cpuinfo.pas 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. {
  2. Copyright (c) 1998-2004 by Florian Klaempfl
  3. Basic Processor information
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. Unit cpuinfo;
  18. {$i fpcdefs.inc}
  19. Interface
  20. uses
  21. globtype;
  22. Type
  23. bestreal = extended;
  24. ts32real = single;
  25. ts64real = double;
  26. ts80real = extended;
  27. ts128real = type extended;
  28. ts64comp = type extended;
  29. pbestreal=^bestreal;
  30. { possible supported processors for this target }
  31. tcputype =
  32. (cpu_none,
  33. cpu_386,
  34. cpu_Pentium,
  35. cpu_Pentium2,
  36. cpu_Pentium3,
  37. cpu_Pentium4,
  38. cpu_PentiumM,
  39. cpu_core_i,
  40. cpu_core_avx,
  41. cpu_core_avx2
  42. );
  43. tfputype =
  44. (fpu_none,
  45. // fpu_soft,
  46. fpu_x87,
  47. fpu_sse,
  48. fpu_sse2,
  49. fpu_sse3,
  50. fpu_ssse3,
  51. fpu_sse41,
  52. fpu_sse42,
  53. fpu_avx,
  54. fpu_avx2
  55. );
  56. Const
  57. { calling conventions supported by the code generator }
  58. supported_calling_conventions : tproccalloptions = [
  59. pocall_internproc,
  60. pocall_register,
  61. pocall_safecall,
  62. pocall_stdcall,
  63. pocall_cdecl,
  64. pocall_cppdecl,
  65. pocall_far16,
  66. pocall_pascal,
  67. pocall_oldfpccall,
  68. pocall_mwpascal
  69. ];
  70. cputypestr : array[tcputype] of string[10] = ('',
  71. '80386',
  72. 'PENTIUM',
  73. 'PENTIUM2',
  74. 'PENTIUM3',
  75. 'PENTIUM4',
  76. 'PENTIUMM',
  77. 'COREI',
  78. 'COREAVX',
  79. 'COREAVX2'
  80. );
  81. fputypestr : array[tfputype] of string[6] = ('',
  82. // 'SOFT',
  83. 'X87',
  84. 'SSE',
  85. 'SSE2',
  86. 'SSE3',
  87. 'SSSE3',
  88. 'SSE41',
  89. 'SSE42',
  90. 'AVX',
  91. 'AVX2'
  92. );
  93. sse_singlescalar = [fpu_sse..fpu_avx2];
  94. sse_doublescalar = [fpu_sse2..fpu_avx2];
  95. fpu_avx_instructionsets = [fpu_avx,fpu_avx2];
  96. { Supported optimizations, only used for information }
  97. supported_optimizerswitches = genericlevel1optimizerswitches+
  98. genericlevel2optimizerswitches+
  99. genericlevel3optimizerswitches-
  100. { no need to write info about those }
  101. [cs_opt_level1,cs_opt_level2,cs_opt_level3]+
  102. [cs_opt_peephole,cs_opt_regvar,cs_opt_stackframe,
  103. cs_opt_asmcse,cs_opt_loopunroll,cs_opt_uncertain,
  104. cs_opt_tailrecursion,cs_opt_nodecse,cs_useebp,
  105. cs_opt_reorder_fields,cs_opt_fastmath];
  106. level1optimizerswitches = genericlevel1optimizerswitches;
  107. level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
  108. [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion,cs_opt_nodecse];
  109. level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
  110. level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [cs_useebp];
  111. type
  112. tcpuflags =
  113. (CPUX86_HAS_SSEUNIT,
  114. CPUX86_HAS_BMI1,
  115. CPUX86_HAS_BMI2,
  116. CPUX86_HAS_POPCNT,
  117. CPUX86_HAS_AVXUNIT,
  118. CPUX86_HAS_LZCNT,
  119. CPUX86_HAS_MOVBE,
  120. CPUX86_HAS_FMA,
  121. CPUX86_HAS_FMA4
  122. );
  123. const
  124. cpu_capabilities : array[tcputype] of set of tcpuflags = (
  125. { cpu_none } [],
  126. { cpu_386 } [],
  127. { cpu_Pentium } [],
  128. { cpu_Pentium2 } [],
  129. { cpu_Pentium3 } [CPUX86_HAS_SSEUNIT],
  130. { cpu_Pentium4 } [CPUX86_HAS_SSEUNIT],
  131. { cpu_PentiumM } [CPUX86_HAS_SSEUNIT],
  132. { cpu_core_i } [CPUX86_HAS_SSEUNIT,CPUX86_HAS_POPCNT],
  133. { cpu_core_avx } [CPUX86_HAS_SSEUNIT,CPUX86_HAS_POPCNT,CPUX86_HAS_AVXUNIT],
  134. { cpu_core_avx2 } [CPUX86_HAS_SSEUNIT,CPUX86_HAS_POPCNT,CPUX86_HAS_AVXUNIT,CPUX86_HAS_BMI1,CPUX86_HAS_BMI2,CPUX86_HAS_LZCNT,CPUX86_HAS_MOVBE,CPUX86_HAS_FMA]
  135. );
  136. Implementation
  137. end.