cpuinfo.pas 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. {
  2. Copyright (c) 1998-2002 by the Free Pascal development team
  3. Basic Processor information for the Xtensa
  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. systems;
  16. Type
  17. bestreal = double;
  18. bestrealrec = TDoubleRec;
  19. ts32real = single;
  20. ts64real = double;
  21. ts80real = type extended;
  22. ts128real = type extended;
  23. ts64comp = comp;
  24. pbestreal=^bestreal;
  25. { possible supported processors for this target }
  26. tcputype =
  27. (cpu_none,
  28. cpu_lx106,
  29. cpu_lx6,
  30. cpu_lx7,
  31. cpu_lx7hf
  32. );
  33. Type
  34. tfputype =
  35. (fpu_none,
  36. fpu_soft,
  37. fpu_libgcc,
  38. fpu_hard
  39. );
  40. Type
  41. tcontrollertype =
  42. (ct_none,
  43. ct_esp8266,
  44. ct_esp32,
  45. ct_esp32_d0wd,
  46. ct_esp32_d2wd,
  47. ct_esp32_sOwd,
  48. ct_esp32s2,
  49. ct_esp32s3
  50. );
  51. tcontrollerdatatype = record
  52. controllertypestr, controllerunitstr: string[20];
  53. cputype: tcputype; fputype: tfputype; abi: tabi;
  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 = true;
  60. {# Size of native extended floating point type }
  61. extended_size = 12;
  62. { target cpu string (used by compiler options) }
  63. target_cpu_string = 'xtensa';
  64. { calling conventions supported by the code generator }
  65. supported_calling_conventions : tproccalloptions = [
  66. pocall_internproc,
  67. pocall_safecall,
  68. pocall_stdcall,
  69. { same as stdcall only different name mangling }
  70. pocall_cdecl,
  71. { same as stdcall only different name mangling }
  72. pocall_cppdecl,
  73. { same as stdcall but floating point numbers are handled like equal sized integers }
  74. pocall_softfloat,
  75. { used for interrupt handling }
  76. pocall_interrupt
  77. ];
  78. cputypestr : array[tcputype] of string[8] = (
  79. '',
  80. 'LX106',
  81. 'LX6',
  82. 'LX7',
  83. 'LX7HF'
  84. );
  85. fputypestr : array[tfputype] of string[10] = (
  86. 'NONE',
  87. 'SOFT',
  88. 'LIBGCC',
  89. 'HARD'
  90. );
  91. { We know that there are fields after sramsize
  92. but we don't care about this warning }
  93. {$WARN 3177 OFF}
  94. embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
  95. (
  96. (controllertypestr:''; controllerunitstr:''; cputype:cpu_none; fputype:fpu_soft; abi: abi_default; flashbase:0),
  97. (controllertypestr:'ESP8266'; controllerunitstr:'ESP8266'; cputype:cpu_lx106; fputype:fpu_soft; abi: abi_xtensa_call0; flashbase:$40000000; flashsize:1024*1024; srambase:$40070000; sramsize: 520*1024),
  98. (controllertypestr:'ESP32'; controllerunitstr:'ESP32'; cputype:cpu_lx6; fputype:fpu_hard; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:2*1024*1024),
  99. (controllertypestr:'ESP32_D0WD'; controllerunitstr:'ESP32_D0WD'; cputype:cpu_lx6; fputype:fpu_hard; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:448*1024; srambase:$40070000; sramsize: 520*1024),
  100. (controllertypestr:'ESP32_D2WD'; controllerunitstr:'ESP32_D2WD'; cputype:cpu_lx6; fputype:fpu_hard; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:448*1024; srambase:$40070000; sramsize: 520*1024),
  101. (controllertypestr:'ESP32_S0WD'; controllerunitstr:'ESP32_S0WD'; cputype:cpu_lx6; fputype:fpu_hard; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:448*1024; srambase:$40070000; sramsize: 520*1024),
  102. (controllertypestr:'ESP32S2'; controllerunitstr:'ESP32S2'; cputype:cpu_lx7; fputype:fpu_soft; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:4*1024*1024),
  103. (controllertypestr:'ESP32S3'; controllerunitstr:'ESP32S3'; cputype:cpu_lx7hf; fputype:fpu_hard; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:4*1024*1024)
  104. );
  105. { Supported optimizations, only used for information }
  106. supported_optimizerswitches = genericlevel1optimizerswitches+
  107. genericlevel2optimizerswitches+
  108. genericlevel3optimizerswitches-
  109. { no need to write info about those }
  110. [cs_opt_level1,cs_opt_level2,cs_opt_level3]+
  111. [{$ifndef llvm}cs_opt_regvar,{$endif}cs_opt_loopunroll,cs_opt_tailrecursion,
  112. cs_opt_stackframe,cs_opt_nodecse,cs_opt_reorder_fields,cs_opt_fastmath,cs_opt_forcenostackframe];
  113. level1optimizerswitches = genericlevel1optimizerswitches;
  114. level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
  115. [{$ifndef llvm}cs_opt_regvar,{$endif}cs_opt_stackframe,cs_opt_tailrecursion,cs_opt_nodecse];
  116. level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches;
  117. level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
  118. type
  119. tcpuflags =
  120. (
  121. CPUXTENSA_REGWINDOW,
  122. CPUXTENSA_HAS_SEXT,
  123. CPUXTENSA_HAS_NSAx,
  124. CPUXTENSA_HAS_BOOLEAN_OPTION,
  125. CPUXTENSA_HAS_MUL32HIGH,
  126. CPUXTENSA_HAS_DIV,
  127. CPUXTENSA_HAS_LOOPS,
  128. CPUXTENSA_HAS_MINMAX
  129. );
  130. tfpuflags =
  131. (
  132. FPUXTENSA_SINGLE, { FPU has single support }
  133. FPUXTENSA_DOUBLE { FPU has double support, this is a dummy so far for easier checking what code to generate }
  134. );
  135. const
  136. cpu_capabilities : array[tcputype] of set of tcpuflags =
  137. (
  138. { cpu_none } [],
  139. { cpu_lx106 } [],
  140. { cpu_lx6 } [CPUXTENSA_REGWINDOW, CPUXTENSA_HAS_SEXT, CPUXTENSA_HAS_NSAx, CPUXTENSA_HAS_BOOLEAN_OPTION, CPUXTENSA_HAS_MUL32HIGH, CPUXTENSA_HAS_DIV, CPUXTENSA_HAS_LOOPS, CPUXTENSA_HAS_MINMAX],
  141. { cpu_lxf } [CPUXTENSA_REGWINDOW, CPUXTENSA_HAS_SEXT, CPUXTENSA_HAS_NSAx, CPUXTENSA_HAS_BOOLEAN_OPTION, CPUXTENSA_HAS_MUL32HIGH, CPUXTENSA_HAS_DIV, CPUXTENSA_HAS_MINMAX],
  142. { cpu_lx7hf } [CPUXTENSA_REGWINDOW, CPUXTENSA_HAS_SEXT, CPUXTENSA_HAS_NSAx, CPUXTENSA_HAS_BOOLEAN_OPTION, CPUXTENSA_HAS_MUL32HIGH, CPUXTENSA_HAS_DIV, CPUXTENSA_HAS_MINMAX]
  143. );
  144. fpu_capabilities : array[tfputype] of set of tfpuflags =
  145. (
  146. { fpu_none } [],
  147. { fpu_soft } [],
  148. { fpu_libgcc } [],
  149. { fpu_hard } [FPUXTENSA_SINGLE]
  150. );
  151. Implementation
  152. end.