cpuinfo.pas 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. {
  2. Copyright (c) 2008 by the Free Pascal development team
  3. Basic Processor information for the AVR
  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. Interface
  12. uses
  13. globtype;
  14. Type
  15. bestreal = double;
  16. ts32real = single;
  17. ts64real = double;
  18. ts80real = type extended;
  19. ts128real = type extended;
  20. ts64comp = comp;
  21. pbestreal=^bestreal;
  22. { possible supported processors for this target }
  23. tcputype =
  24. (cpu_none,
  25. cpu_avr1,
  26. cpu_avr2,
  27. cpu_avr25,
  28. cpu_avr3,
  29. cpu_avr31,
  30. cpu_avr35,
  31. cpu_avr4,
  32. cpu_avr5,
  33. cpu_avr51,
  34. cpu_avr6
  35. );
  36. tfputype =
  37. (fpu_none,
  38. fpu_soft,
  39. fp_libgcc
  40. );
  41. tcontrollertype =
  42. (ct_none,
  43. ct_atmega16,
  44. ct_atmega32,
  45. ct_atmega48,
  46. ct_atmega64,
  47. ct_atmega128
  48. );
  49. Const
  50. {# Size of native extended floating point type }
  51. extended_size = 12;
  52. {# Size of a multimedia register }
  53. mmreg_size = 16;
  54. { target cpu string (used by compiler options) }
  55. target_cpu_string = 'avr';
  56. { calling conventions supported by the code generator }
  57. supported_calling_conventions : tproccalloptions = [
  58. pocall_internproc,
  59. pocall_safecall,
  60. pocall_stdcall,
  61. { same as stdcall only different name mangling }
  62. pocall_cdecl,
  63. { same as stdcall only different name mangling }
  64. pocall_cppdecl,
  65. { same as stdcall but floating point numbers are handled like equal sized integers }
  66. pocall_softfloat
  67. ];
  68. cputypestr : array[tcputype] of string[5] = ('',
  69. 'AVR1',
  70. 'AVR2',
  71. 'AVR25',
  72. 'AVR3',
  73. 'AVR31',
  74. 'AVR35',
  75. 'AVR4',
  76. 'AVR5',
  77. 'AVR51',
  78. 'AVR6'
  79. );
  80. fputypestr : array[tfputype] of string[6] = (
  81. 'NONE',
  82. 'SOFT',
  83. 'LIBGCC'
  84. );
  85. { We know that there are fields after sramsize
  86. but we don't care about this warning }
  87. {$WARN 3177 OFF}
  88. embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
  89. ((
  90. controllertypestr:'';
  91. controllerunitstr:'';
  92. flashbase:0;
  93. flashsize:0;
  94. srambase:0;
  95. sramsize:0;
  96. eeprombase:0;
  97. eepromsize:0
  98. ),
  99. (
  100. controllertypestr:'ATMEGA16';
  101. controllerunitstr:'ATMEGA16';
  102. flashbase:0;
  103. flashsize:$4000;
  104. srambase:0;
  105. sramsize:1024;
  106. eeprombase:0;
  107. eepromsize:512
  108. ),
  109. (
  110. controllertypestr:'ATMEGA32';
  111. controllerunitstr:'ATMEGA32';
  112. flashbase:0;
  113. flashsize:$8000;
  114. srambase:0;
  115. sramsize:1024;
  116. eeprombase:0;
  117. eepromsize:512
  118. ),
  119. (
  120. controllertypestr:'ATMEGA48';
  121. controllerunitstr:'ATMEGA48';
  122. flashbase:0;
  123. flashsize:$1000;
  124. srambase:0;
  125. sramsize:512;
  126. eeprombase:0;
  127. eepromsize:256;
  128. ),
  129. (
  130. controllertypestr:'ATMEGA64';
  131. controllerunitstr:'ATMEGA64';
  132. flashbase:0;
  133. flashsize:$10000;
  134. srambase:0;
  135. sramsize:4096;
  136. eeprombase:0;
  137. eepromsize:2048;
  138. ),
  139. (
  140. controllertypestr:'ATMEGA128';
  141. controllerunitstr:'ATMEGA128';
  142. flashbase:0;
  143. flashsize:$20000;
  144. srambase:0;
  145. sramsize:4096;
  146. eeprombase:0;
  147. eepromsize:4096;
  148. )
  149. );
  150. { Supported optimizations, only used for information }
  151. supported_optimizerswitches = genericlevel1optimizerswitches+
  152. genericlevel2optimizerswitches+
  153. genericlevel3optimizerswitches-
  154. { no need to write info about those }
  155. [cs_opt_level1,cs_opt_level2,cs_opt_level3]+
  156. [cs_opt_regvar,cs_opt_loopunroll,cs_opt_tailrecursion,
  157. cs_opt_stackframe,cs_opt_nodecse,cs_opt_reorder_fields,cs_opt_fastmath];
  158. level1optimizerswitches = genericlevel1optimizerswitches;
  159. level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
  160. [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion];
  161. level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
  162. level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
  163. type
  164. tcpuflags =
  165. (CPUAVR_HAS_JMP_CALL,
  166. CPUAVR_HAS_MOVW,
  167. CPUAVR_HAS_LPMX,
  168. CPUAVR_HAS_MUL,
  169. CPUAVR_HAS_RAMPZ,
  170. CPUAVR_HAS_ELPM,
  171. CPUAVR_HAS_ELPMX,
  172. CPUAVR_2_BYTE_PC,
  173. CPUAVR_3_BYTE_PC
  174. );
  175. const
  176. cpu_capabilities : array[tcputype] of set of tcpuflags =
  177. ( { cpu_none } [],
  178. { cpu_avr1 } [CPUAVR_2_BYTE_PC],
  179. { cpu_avr2 } [CPUAVR_2_BYTE_PC],
  180. { cpu_avr25 } [CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_2_BYTE_PC],
  181. { cpu_avr3 } [CPUAVR_HAS_JMP_CALL,CPUAVR_2_BYTE_PC],
  182. { cpu_avr31 } [CPUAVR_HAS_JMP_CALL,CPUAVR_HAS_RAMPZ,CPUAVR_HAS_ELPM,CPUAVR_2_BYTE_PC],
  183. { cpu_avr35 } [CPUAVR_HAS_JMP_CALL,CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_2_BYTE_PC],
  184. { cpu_avr4 } [CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_HAS_MUL,CPUAVR_2_BYTE_PC],
  185. { cpu_avr5 } [CPUAVR_HAS_JMP_CALL,CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_HAS_MUL,CPUAVR_2_BYTE_PC],
  186. { cpu_avr51 } [CPUAVR_HAS_JMP_CALL,CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_HAS_MUL,CPUAVR_HAS_RAMPZ,CPUAVR_HAS_ELPM,CPUAVR_HAS_ELPMX,CPUAVR_2_BYTE_PC],
  187. { cpu_avr6 } [CPUAVR_HAS_JMP_CALL,CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_HAS_MUL,CPUAVR_HAS_RAMPZ,CPUAVR_HAS_ELPM,CPUAVR_HAS_ELPMX,CPUAVR_3_BYTE_PC]
  188. );
  189. Implementation
  190. end.