cpuinfo.pas 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. {
  2. Copyright (c) 1998-2002 by the Free Pascal development team
  3. Basic Processor information for the MIPS
  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 = type double;
  23. ts128real = type double;
  24. ts64comp = comp;
  25. pbestreal=^bestreal;
  26. { possible supported processors for this target }
  27. tcputype =
  28. (cpu_none,
  29. cpu_mips1,
  30. cpu_mips2,
  31. cpu_mips3,
  32. cpu_mips4,
  33. cpu_mips5,
  34. cpu_mips32,
  35. cpu_mips32r2,
  36. cpu_pic32mx
  37. );
  38. tfputype =(fpu_none,fpu_soft,fpu_mips2,fpu_mips3);
  39. tabitype =
  40. (
  41. abi_none,
  42. abi_default,
  43. abi_o32,
  44. abi_n32,
  45. abi_o64,
  46. abi_n64,
  47. abi_eabi
  48. );
  49. Const
  50. {# Size of native extended floating point type }
  51. extended_size = 8;
  52. { calling conventions supported by the code generator }
  53. supported_calling_conventions : tproccalloptions = [
  54. pocall_internproc,
  55. pocall_stdcall,
  56. pocall_safecall,
  57. { same as stdcall only different name mangling }
  58. pocall_cdecl,
  59. { same as stdcall only different name mangling }
  60. pocall_cppdecl
  61. ];
  62. { cpu strings as accepted by
  63. GNU assembler in -arch=XXX option
  64. this ilist needs to be uppercased }
  65. cputypestr : array[tcputype] of string[8] = ('',
  66. { cpu_mips1 } 'MIPS1',
  67. { cpu_mips2 } 'MIPS2',
  68. { cpu_mips3 } 'MIPS3',
  69. { cpu_mips4 } 'MIPS4',
  70. { cpu_mips5 } 'MIPS5',
  71. { cpu_mips32 } 'MIPS32',
  72. { cpu_mips32r2 } 'MIPS32R2',
  73. { cpu_pic32mx } 'PIC32MX'
  74. );
  75. fputypestr : array[tfputype] of string[9] = ('',
  76. 'SOFT',
  77. 'MIPS2','MIPS3'
  78. );
  79. { abi strings as accepted by
  80. GNU assembler in -abi=XXX option }
  81. abitypestr : array[tabitype] of string[4] =
  82. ({ abi_none } '',
  83. { abi_default } '32',
  84. { abi_o32 } '32',
  85. { abi_n32 } 'n32',
  86. { abi_o64 } 'o64',
  87. { abi_n64 } '64',
  88. { abi_eabi } 'eabi'
  89. );
  90. mips_abi : tabitype = abi_default;
  91. type
  92. tcpuflags=(
  93. CPUMIPS_HAS_CMOV, { conditional move instructions (mips4+) }
  94. CPUMIPS_HAS_ISA32R2 { mips32r2 instructions (also on PIC32) }
  95. );
  96. tcontrollerdatatype = record
  97. controllertypestr, controllerunitstr: string[20];
  98. cputype: tcputype; fputype: tfputype;
  99. flashbase, flashsize, srambase, sramsize, eeprombase, eepromsize, bootbase, bootsize: dword;
  100. end;
  101. const
  102. cpu_capabilities : array[tcputype] of set of tcpuflags =
  103. ( { cpu_none } [],
  104. { cpu_mips1 } [],
  105. { cpu_mips2 } [],
  106. { cpu_mips3 } [],
  107. { cpu_mips4 } [CPUMIPS_HAS_CMOV],
  108. { cpu_mips5 } [CPUMIPS_HAS_CMOV],
  109. { cpu_mips32 } [CPUMIPS_HAS_CMOV],
  110. { cpu_mips32r2 } [CPUMIPS_HAS_CMOV,CPUMIPS_HAS_ISA32R2],
  111. { cpu_pic32mx } [CPUMIPS_HAS_CMOV,CPUMIPS_HAS_ISA32R2]
  112. );
  113. {$ifndef MIPSEL}
  114. type
  115. tcontrollertype =
  116. (ct_none
  117. );
  118. Const
  119. { Is there support for dealing with multiple microcontrollers available }
  120. { for this platform? }
  121. ControllerSupport = false;
  122. { We know that there are fields after sramsize
  123. but we don't care about this warning }
  124. {$PUSH}
  125. {$WARN 3177 OFF}
  126. embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
  127. (
  128. (controllertypestr:''; controllerunitstr:''; cputype:cpu_none; fputype:fpu_none; flashbase:0; flashsize:0; srambase:0; sramsize:0));
  129. {$POP}
  130. {$ELSE MIPSEL}
  131. { Is there support for dealing with multiple microcontrollers available }
  132. { for this platform? }
  133. ControllerSupport = true;
  134. type
  135. tcontrollertype =
  136. (ct_none,
  137. { pic32mx }
  138. ct_pic32mx110f016b,
  139. ct_pic32mx110f016c,
  140. ct_pic32mx110f016d,
  141. ct_pic32mx120f032b,
  142. ct_pic32mx120f032c,
  143. ct_pic32mx120f032d,
  144. ct_pic32mx130f064b,
  145. ct_pic32mx130f064c,
  146. ct_pic32mx130f064d,
  147. ct_pic32mx150f128b,
  148. ct_pic32mx150f128c,
  149. ct_pic32mx150f128d,
  150. ct_pic32mx210f016b,
  151. ct_pic32mx210f016c,
  152. ct_pic32mx210f016d,
  153. ct_pic32mx220f032b,
  154. ct_pic32mx220f032c,
  155. ct_pic32mx220f032d,
  156. ct_pic32mx230f064b,
  157. ct_pic32mx230f064c,
  158. ct_pic32mx230f064d,
  159. ct_pic32mx250f128b,
  160. ct_pic32mx250f128c,
  161. ct_pic32mx250f128d,
  162. ct_pic32mx775f256h,
  163. ct_pic32mx775f256l,
  164. ct_pic32mx775f512h,
  165. ct_pic32mx775f512l,
  166. ct_pic32mx795f512h,
  167. ct_pic32mx795f512l
  168. );
  169. { We know that there are fields after sramsize
  170. but we don't care about this warning }
  171. {$WARN 3177 OFF}
  172. const
  173. embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
  174. (
  175. (controllertypestr:''; controllerunitstr:''; cputype: cpu_none; fputype: fpu_none; flashbase:0; flashsize:0; srambase:0; sramsize:0),
  176. { PIC32MX1xx Series}
  177. (controllertypestr:'PIC32MX110F016B'; controllerunitstr:'PIC32MX1xxFxxxB'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00004000; srambase:$A0000000; sramsize:$00001000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  178. (controllertypestr:'PIC32MX110F016C'; controllerunitstr:'PIC32MX1xxFxxxC'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00004000; srambase:$A0000000; sramsize:$00001000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  179. (controllertypestr:'PIC32MX110F016D'; controllerunitstr:'PIC32MX1xxFxxxD'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00004000; srambase:$A0000000; sramsize:$00001000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  180. (controllertypestr:'PIC32MX120F032B'; controllerunitstr:'PIC32MX1xxFxxxB'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00008000; srambase:$A0000000; sramsize:$00002000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  181. (controllertypestr:'PIC32MX120F032C'; controllerunitstr:'PIC32MX1xxFxxxC'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00008000; srambase:$A0000000; sramsize:$00002000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  182. (controllertypestr:'PIC32MX120F032D'; controllerunitstr:'PIC32MX1xxFxxxD'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00008000; srambase:$A0000000; sramsize:$00002000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  183. (controllertypestr:'PIC32MX130F064B'; controllerunitstr:'PIC32MX1xxFxxxB'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00010000; srambase:$A0000000; sramsize:$00004000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  184. (controllertypestr:'PIC32MX130F064C'; controllerunitstr:'PIC32MX1xxFxxxC'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00010000; srambase:$A0000000; sramsize:$00004000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  185. (controllertypestr:'PIC32MX130F064D'; controllerunitstr:'PIC32MX1xxFxxxD'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00010000; srambase:$A0000000; sramsize:$00004000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  186. (controllertypestr:'PIC32MX150F128B'; controllerunitstr:'PIC32MX1xxFxxxB'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00020000; srambase:$A0000000; sramsize:$00008000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  187. (controllertypestr:'PIC32MX150F128C'; controllerunitstr:'PIC32MX1xxFxxxC'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00020000; srambase:$A0000000; sramsize:$00008000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  188. (controllertypestr:'PIC32MX150F128D'; controllerunitstr:'PIC32MX1xxFxxxD'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00020000; srambase:$A0000000; sramsize:$00008000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  189. { PIC32MX2xx Series}
  190. (controllertypestr:'PIC32MX210F016B'; controllerunitstr:'PIC32MX2xxFxxxB'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00004000; srambase:$A0000000; sramsize:$00001000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  191. (controllertypestr:'PIC32MX210F016C'; controllerunitstr:'PIC32MX2xxFxxxC'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00004000; srambase:$A0000000; sramsize:$00001000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  192. (controllertypestr:'PIC32MX210F016D'; controllerunitstr:'PIC32MX2xxFxxxD'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00004000; srambase:$A0000000; sramsize:$00001000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  193. (controllertypestr:'PIC32MX220F032B'; controllerunitstr:'PIC32MX2xxFxxxB'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00008000; srambase:$A0000000; sramsize:$00002000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  194. (controllertypestr:'PIC32MX220F032C'; controllerunitstr:'PIC32MX2xxFxxxC'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00008000; srambase:$A0000000; sramsize:$00002000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  195. (controllertypestr:'PIC32MX220F032D'; controllerunitstr:'PIC32MX2xxFxxxD'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00008000; srambase:$A0000000; sramsize:$00002000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  196. (controllertypestr:'PIC32MX230F064B'; controllerunitstr:'PIC32MX2xxFxxxB'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00010000; srambase:$A0000000; sramsize:$00004000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  197. (controllertypestr:'PIC32MX230F064C'; controllerunitstr:'PIC32MX2xxFxxxC'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00010000; srambase:$A0000000; sramsize:$00004000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  198. (controllertypestr:'PIC32MX230F064D'; controllerunitstr:'PIC32MX2xxFxxxD'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00010000; srambase:$A0000000; sramsize:$00004000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  199. (controllertypestr:'PIC32MX250F128B'; controllerunitstr:'PIC32MX2xxFxxxB'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00020000; srambase:$A0000000; sramsize:$00008000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  200. (controllertypestr:'PIC32MX250F128C'; controllerunitstr:'PIC32MX2xxFxxxC'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00020000; srambase:$80000000; sramsize:$00008000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  201. (controllertypestr:'PIC32MX250F128D'; controllerunitstr:'PIC32MX2xxFxxxD'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00020000; srambase:$A0000000; sramsize:$00008000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00000BEF),
  202. { PIC32MX7x5 Series}
  203. (controllertypestr:'PIC32MX775F256H'; controllerunitstr:'PIC32MX7x5FxxxH'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00040000; srambase:$A0000000; sramsize:$00010000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00002FEF),
  204. (controllertypestr:'PIC32MX775F256L'; controllerunitstr:'PIC32MX7x5FxxxL'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00040000; srambase:$A0000000; sramsize:$00010000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00002FEF),
  205. (controllertypestr:'PIC32MX775F512H'; controllerunitstr:'PIC32MX7x5FxxxH'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00080000; srambase:$A0000000; sramsize:$00010000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00002FEF),
  206. (controllertypestr:'PIC32MX775F512L'; controllerunitstr:'PIC32MX7x5FxxxL'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00080000; srambase:$A0000000; sramsize:$00010000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00002FEF),
  207. (controllertypestr:'PIC32MX795F512H'; controllerunitstr:'PIC32MX7x5FxxxH'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00080000; srambase:$A0000000; sramsize:$00020000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00002FEF),
  208. (controllertypestr:'PIC32MX795F512L'; controllerunitstr:'PIC32MX7x5FxxxL'; cputype: cpu_pic32mx; fputype: fpu_soft; flashbase:$9d000000; flashsize:$00080000; srambase:$A0000000; sramsize:$00020000; eeprombase:0; eepromsize:0; bootbase:$BFC00000; bootsize:$00002FEF)
  209. );
  210. {$endif MIPSEL}
  211. { Supported optimizations, only used for information }
  212. supported_optimizerswitches = [cs_opt_regvar,cs_opt_loopunroll,cs_opt_nodecse,
  213. cs_opt_reorder_fields,cs_opt_fastmath];
  214. level1optimizerswitches = genericlevel1optimizerswitches;
  215. level2optimizerswitches = level1optimizerswitches + [cs_opt_regvar,cs_opt_stackframe,cs_opt_nodecse];
  216. level3optimizerswitches = level2optimizerswitches + [cs_opt_loopunroll];
  217. level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
  218. function SetMipsABIType(const s : string) : boolean;
  219. Implementation
  220. uses
  221. cutils;
  222. function SetMipsABIType(const s : string) : boolean;
  223. var
  224. abi : tabitype;
  225. begin
  226. SetMipsABIType:=false;
  227. for abi := low(tabitype) to high(tabitype) do
  228. if (lower(s)=abitypestr[abi]) then
  229. begin
  230. mips_abi:=abi;
  231. SetMipsABIType:=true;
  232. break;
  233. end;
  234. end;
  235. end.