cpuinfo.pas 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. {
  2. Copyright (c) 1998-2002 by the Free Pascal development team
  3. Basic Processor information for the m68k
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. Unit CPUInfo;
  11. {$i fpcdefs.inc}
  12. Interface
  13. uses
  14. globtype;
  15. Type
  16. bestreal = double;
  17. {$if FPC_FULLVERSION>20700}
  18. bestrealrec = TDoubleRec;
  19. {$endif FPC_FULLVERSION>20700}
  20. ts32real = single;
  21. ts64real = double;
  22. ts80real = extended;
  23. ts128real = type extended;
  24. ts64comp = extended;
  25. pbestreal=^bestreal;
  26. { possible supported processors for this target }
  27. tcputype =
  28. (cpu_none,
  29. cpu_MC68000,
  30. cpu_MC68020,
  31. cpu_MC68040,
  32. cpu_MC68060,
  33. cpu_isa_a,
  34. cpu_isa_a_p,
  35. cpu_isa_b,
  36. cpu_isa_c,
  37. cpu_cfv4e
  38. );
  39. tfputype =
  40. (fpu_none,
  41. fpu_soft,
  42. fpu_libgcc,
  43. fpu_68881,
  44. fpu_68040,
  45. fpu_68060,
  46. fpu_coldfire
  47. );
  48. tcontrollertype =
  49. (ct_none
  50. );
  51. tcontrollerdatatype = record
  52. controllertypestr, controllerunitstr: string[20];
  53. cputype: tcputype; fputype: tfputype;
  54. flashbase, flashsize, srambase, sramsize, eeprombase, eepromsize, bootbase, bootsize: dword;
  55. end;
  56. Const
  57. { Is there support for dealing with multiple microcontrollers available }
  58. { for this platform? }
  59. ControllerSupport = false;
  60. { We know that there are fields after sramsize
  61. but we don't care about this warning }
  62. {$PUSH}
  63. {$WARN 3177 OFF}
  64. embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
  65. (
  66. (controllertypestr:''; controllerunitstr:''; cputype:cpu_none; fputype:fpu_none; flashbase:0; flashsize:0; srambase:0; sramsize:0));
  67. {$POP}
  68. { calling conventions supported by the code generator }
  69. supported_calling_conventions : tproccalloptions = [
  70. pocall_internproc,
  71. pocall_register,
  72. pocall_stdcall,
  73. pocall_safecall,
  74. { the difference to stdcall is only the name mangling }
  75. pocall_cdecl,
  76. { the difference to stdcall is only the name mangling }
  77. pocall_cppdecl,
  78. { this is used by PalmOS, Atari and Amiga-likes }
  79. pocall_syscall
  80. ];
  81. cputypestr : array[tcputype] of string[8] = ('',
  82. '68000',
  83. '68020',
  84. '68040',
  85. '68060',
  86. 'ISAA',
  87. 'ISAA+',
  88. 'ISAB',
  89. 'ISAC',
  90. 'CFV4E'
  91. );
  92. gascputypestr : array[tcputype] of string[8] = ('',
  93. '68000',
  94. '68020',
  95. '68040',
  96. '68060',
  97. 'isaa',
  98. 'isaaplus',
  99. 'isab',
  100. 'isac',
  101. 'cfv4e'
  102. );
  103. fputypestr : array[tfputype] of string[8] = (
  104. 'NONE',
  105. 'SOFT',
  106. 'LIBGCC',
  107. '68881',
  108. '68040',
  109. '68060',
  110. 'COLDFIRE'
  111. );
  112. { Supported optimizations, only used for information }
  113. supported_optimizerswitches = genericlevel1optimizerswitches+
  114. genericlevel2optimizerswitches+
  115. genericlevel3optimizerswitches-
  116. { no need to write info about those }
  117. [cs_opt_level1,cs_opt_level2,cs_opt_level3]+
  118. [cs_opt_regvar,cs_opt_stackframe,cs_opt_loopunroll,
  119. cs_opt_tailrecursion,cs_opt_nodecse,
  120. cs_opt_reorder_fields,cs_opt_fastmath];
  121. level1optimizerswitches = genericlevel1optimizerswitches;
  122. level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
  123. [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion,cs_opt_nodecse];
  124. level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
  125. level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
  126. type
  127. tcpuflags =
  128. (CPUM68K_HAS_DBRA, { CPU supports the DBRA instruction }
  129. CPUM68K_HAS_RTD, { CPU supports the RTD instruction }
  130. CPUM68K_HAS_CAS, { CPU supports the CAS instruction }
  131. CPUM68K_HAS_TAS, { CPU supports the TAS instruction }
  132. CPUM68K_HAS_BRAL, { CPU supports the BRA.L/Bcc.L instructions }
  133. CPUM68K_HAS_ROLROR, { CPU supports the ROL/ROR and ROXL/ROXR instructions }
  134. CPUM68K_HAS_BYTEREV, { CPU supports the BYTEREV instruction }
  135. CPUM68K_HAS_MVSMVZ, { CPU supports the MVZ and MVS instructions }
  136. CPUM68K_HAS_MOVE16, { CPU supports the MOVE16 instruction }
  137. CPUM68K_HAS_MULIMM, { CPU supports MULS/MULU with immediate value }
  138. CPUM68K_HAS_32BITMUL, { CPU supports MULS/MULU 32x32 -> 32bit }
  139. CPUM68K_HAS_64BITMUL, { CPU supports MULS/MULU 32x32 -> 64bit }
  140. CPUM68K_HAS_16BITDIV, { CPU supports DIVS/DIVU 32/16 -> 16bit }
  141. CPUM68K_HAS_32BITDIV, { CPU supports DIVS/DIVU 32/32 -> 32bit }
  142. CPUM68K_HAS_64BITDIV, { CPU supports DIVS/DIVU 64/32 -> 32bit }
  143. CPUM68K_HAS_REMSREMU, { CPU supports the REMS/REMU instructions }
  144. CPUM68K_HAS_UNALIGNED, { CPU supports unaligned access }
  145. CPUM68K_HAS_BASEDISP, { CPU supports addressing with 32bit base displacements }
  146. CPUM68K_HAS_INDEXSCALE, { CPU supports scaling the index register with 2 or 4 }
  147. CPUM68K_HAS_INDEXSCALE8, { CPU supports scaling the index register with 2, 4 or 8 }
  148. CPUM68K_HAS_INDEXWORD, { CPU supports indexing with 16bit index }
  149. CPUM68K_HAS_BYTEWORDMATH { CPU supports supports 8 and 16bit aritmetic operations }
  150. );
  151. tfpuflags =
  152. (FPUM68K_HAS_HARDWARE, { FPU is actually a hardware implementation, not a software library }
  153. FPUM68K_HAS_EXTENDED, { FPU has 80 bit extended support }
  154. FPUM68K_HAS_TRIGONOMETRY, { FPU supports trigonometric instructions (FSIN/FCOS, etc) }
  155. FPUM68K_HAS_RESULTPRECISION, { FPU supports encoding the result precision into instructions }
  156. FPUM68K_HAS_FLOATIMMEDIATE, { FPU supports floating point immediate values }
  157. FPUM68K_HAS_FINTRZ { FPU supports the FINT/FINTRZ instruction }
  158. );
  159. const
  160. cpu_capabilities : array[tcputype] of set of tcpuflags =
  161. ( { cpu_none } [],
  162. { cpu_68000 } [CPUM68K_HAS_DBRA,CPUM68K_HAS_TAS,CPUM68K_HAS_ROLROR,CPUM68K_HAS_MULIMM,CPUM68K_HAS_16BITDIV,CPUM68K_HAS_BYTEWORDMATH],
  163. { cpu_68020 } [CPUM68K_HAS_DBRA,CPUM68K_HAS_RTD,CPUM68K_HAS_CAS,CPUM68K_HAS_TAS,CPUM68K_HAS_BRAL,CPUM68K_HAS_ROLROR,CPUM68K_HAS_UNALIGNED,CPUM68K_HAS_BASEDISP,CPUM68K_HAS_MULIMM,CPUM68K_HAS_32BITMUL,CPUM68K_HAS_64BITMUL,CPUM68K_HAS_16BITDIV,CPUM68K_HAS_32BITDIV,CPUM68K_HAS_64BITDIV,CPUM68K_HAS_INDEXSCALE,CPUM68K_HAS_INDEXSCALE8,CPUM68K_HAS_INDEXWORD,CPUM68K_HAS_BYTEWORDMATH],
  164. { cpu_68040 } [CPUM68K_HAS_DBRA,CPUM68K_HAS_RTD,CPUM68K_HAS_CAS,CPUM68K_HAS_TAS,CPUM68K_HAS_BRAL,CPUM68K_HAS_ROLROR,CPUM68K_HAS_UNALIGNED,CPUM68K_HAS_BASEDISP,CPUM68K_HAS_MULIMM,CPUM68K_HAS_32BITMUL,CPUM68K_HAS_64BITMUL,CPUM68K_HAS_16BITDIV,CPUM68K_HAS_32BITDIV,CPUM68K_HAS_64BITDIV,CPUM68K_HAS_MOVE16,CPUM68K_HAS_INDEXSCALE,CPUM68K_HAS_INDEXSCALE8,CPUM68K_HAS_INDEXWORD,CPUM68K_HAS_BYTEWORDMATH],
  165. { cpu_68060 } [CPUM68K_HAS_DBRA,CPUM68K_HAS_RTD,CPUM68K_HAS_CAS,CPUM68K_HAS_TAS,CPUM68K_HAS_BRAL,CPUM68K_HAS_ROLROR,CPUM68K_HAS_UNALIGNED,CPUM68K_HAS_BASEDISP,CPUM68K_HAS_MULIMM,CPUM68K_HAS_32BITMUL,CPUM68K_HAS_16BITDIV,CPUM68K_HAS_32BITDIV,CPUM68K_HAS_MOVE16,CPUM68K_HAS_INDEXSCALE,CPUM68K_HAS_INDEXSCALE8,CPUM68K_HAS_INDEXWORD,CPUM68K_HAS_BYTEWORDMATH],
  166. { cpu_isaa } [CPUM68K_HAS_UNALIGNED,CPUM68K_HAS_32BITMUL,CPUM68K_HAS_16BITDIV,CPUM68K_HAS_32BITDIV,CPUM68K_HAS_REMSREMU,CPUM68K_HAS_INDEXSCALE],
  167. { cpu_isaap } [CPUM68K_HAS_BRAL,CPUM68K_HAS_BYTEREV,CPUM68K_HAS_UNALIGNED,CPUM68K_HAS_32BITMUL,CPUM68K_HAS_16BITDIV,CPUM68K_HAS_32BITDIV,CPUM68K_HAS_REMSREMU,CPUM68K_HAS_INDEXSCALE],
  168. { cpu_isab } [CPUM68K_HAS_TAS,CPUM68K_HAS_BRAL,CPUM68K_HAS_MVSMVZ,CPUM68K_HAS_UNALIGNED,CPUM68K_HAS_32BITMUL,CPUM68K_HAS_16BITDIV,CPUM68K_HAS_32BITDIV,CPUM68K_HAS_REMSREMU,CPUM68K_HAS_INDEXSCALE],
  169. { cpu_isac } [CPUM68K_HAS_TAS,CPUM68K_HAS_BYTEREV,CPUM68K_HAS_MVSMVZ,CPUM68K_HAS_UNALIGNED,CPUM68K_HAS_32BITMUL,CPUM68K_HAS_16BITDIV,CPUM68K_HAS_32BITDIV,CPUM68K_HAS_REMSREMU,CPUM68K_HAS_INDEXSCALE],
  170. { cpu_cfv4e } [CPUM68K_HAS_TAS,CPUM68K_HAS_BRAL,CPUM68K_HAS_MVSMVZ,CPUM68K_HAS_UNALIGNED,CPUM68K_HAS_32BITMUL,CPUM68K_HAS_16BITDIV,CPUM68K_HAS_32BITDIV,CPUM68K_HAS_REMSREMU,CPUM68K_HAS_INDEXSCALE]
  171. );
  172. { on m68k, Motorola provided a software-library, which provides full '881/2 instruction set
  173. compatibility on 040/060 FPU types via emulation for user code compatibility. this is slow
  174. though, so this capabilities list contains the capabilities supported in the hardware itself }
  175. fpu_capabilities : array[tfputype] of set of tfpuflags =
  176. ( { fpu_none } [],
  177. { fpu_soft } [],
  178. { fpu_libgcc } [],
  179. { fpu_68881 } [FPUM68K_HAS_HARDWARE,FPUM68K_HAS_EXTENDED,FPUM68K_HAS_FLOATIMMEDIATE,FPUM68K_HAS_TRIGONOMETRY,FPUM68K_HAS_FINTRZ],
  180. { fpu_68040 } [FPUM68K_HAS_HARDWARE,FPUM68K_HAS_EXTENDED,FPUM68K_HAS_RESULTPRECISION,FPUM68K_HAS_FLOATIMMEDIATE],
  181. { fpu_68060 } [FPUM68K_HAS_HARDWARE,FPUM68K_HAS_EXTENDED,FPUM68K_HAS_RESULTPRECISION,FPUM68K_HAS_FLOATIMMEDIATE,FPUM68K_HAS_FINTRZ],
  182. { fpu_coldfire } [FPUM68K_HAS_HARDWARE,FPUM68K_HAS_RESULTPRECISION,FPUM68K_HAS_FINTRZ]
  183. );
  184. { all CPUs commonly called "coldfire" }
  185. cpu_coldfire = [cpu_isa_a,cpu_isa_a_p,cpu_isa_b,cpu_isa_c,cpu_cfv4e];
  186. { all CPUs commonly called "68020+" }
  187. cpu_mc68020p = [cpu_mc68020,cpu_mc68040,cpu_mc68060];
  188. { all FPUs commonly called "68881/2" }
  189. fpu_mc68881 = [fpu_68881,fpu_68040,fpu_68060];
  190. Implementation
  191. end.