cpuinfo.pas 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. );
  31. Type
  32. tfputype =
  33. (fpu_none,
  34. fpu_soft,
  35. fpu_libgcc,
  36. fpu_hard
  37. );
  38. Type
  39. tcontrollertype =
  40. (ct_none,
  41. ct_esp8266,
  42. ct_esp32,
  43. ct_esp32_d0wd,
  44. ct_esp32_d2wd,
  45. ct_esp32_sOwd
  46. );
  47. tcontrollerdatatype = record
  48. controllertypestr, controllerunitstr: string[20];
  49. cputype: tcputype; fputype: tfputype; abi: tabi;
  50. flashbase, flashsize, srambase, sramsize, eeprombase, eepromsize, bootbase, bootsize: dword;
  51. end;
  52. Const
  53. { Is there support for dealing with multiple microcontrollers available }
  54. { for this platform? }
  55. ControllerSupport = true;
  56. {# Size of native extended floating point type }
  57. extended_size = 12;
  58. { target cpu string (used by compiler options) }
  59. target_cpu_string = 'xtensa';
  60. { calling conventions supported by the code generator }
  61. supported_calling_conventions : tproccalloptions = [
  62. pocall_internproc,
  63. pocall_safecall,
  64. pocall_stdcall,
  65. { same as stdcall only different name mangling }
  66. pocall_cdecl,
  67. { same as stdcall only different name mangling }
  68. pocall_cppdecl,
  69. { same as stdcall but floating point numbers are handled like equal sized integers }
  70. pocall_softfloat,
  71. { used for interrupt handling }
  72. pocall_interrupt
  73. ];
  74. cputypestr : array[tcputype] of string[8] = (
  75. '',
  76. 'LX106',
  77. 'LX6'
  78. );
  79. fputypestr : array[tfputype] of string[10] = (
  80. 'NONE',
  81. 'SOFT',
  82. 'LIBGCC',
  83. 'HARD'
  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:''; controllerunitstr:''; cputype:cpu_none; fputype:fpu_soft; abi: abi_default; flashbase:0),
  91. (controllertypestr:'ESP8266'; controllerunitstr:'ESP8266'; cputype:cpu_lx106; fputype:fpu_soft; abi: abi_xtensa_call0; flashbase:$40000000; flashsize:1024*1024; srambase:$40070000; sramsize: 520*1024),
  92. (controllertypestr:'ESP32'; controllerunitstr:'ESP32'; cputype:cpu_lx6; fputype:fpu_hard; abi: abi_xtensa_windowed; flashbase:$40000000; flashsize:2*1024*1024),
  93. (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),
  94. (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),
  95. (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)
  96. );
  97. { Supported optimizations, only used for information }
  98. supported_optimizerswitches = genericlevel1optimizerswitches+
  99. genericlevel2optimizerswitches+
  100. genericlevel3optimizerswitches-
  101. { no need to write info about those }
  102. [cs_opt_level1,cs_opt_level2,cs_opt_level3]+
  103. [{$ifndef llvm}cs_opt_regvar,{$endif}cs_opt_loopunroll,cs_opt_tailrecursion,
  104. cs_opt_stackframe,cs_opt_nodecse,cs_opt_reorder_fields,cs_opt_fastmath,cs_opt_forcenostackframe];
  105. level1optimizerswitches = genericlevel1optimizerswitches;
  106. level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
  107. [{$ifndef llvm}cs_opt_regvar,{$endif}cs_opt_stackframe,cs_opt_tailrecursion,cs_opt_nodecse];
  108. level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches;
  109. level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
  110. type
  111. tcpuflags =
  112. (
  113. CPUXTENSA_REGWINDOW,
  114. CPUXTENSA_HAS_SEXT,
  115. CPUXTENSA_HAS_NSAx,
  116. CPUXTENSA_HAS_BOOLEAN_OPTION,
  117. CPUXTENSA_HAS_MUL32HIGH,
  118. CPUXTENSA_HAS_DIV,
  119. CPUXTENSA_HAS_LOOPS,
  120. CPUXTENSA_HAS_MINMAX
  121. );
  122. tfpuflags =
  123. (
  124. FPUXTENSA_SINGLE, { FPU has single support }
  125. FPUXTENSA_DOUBLE { FPU has double support, this is a dummy so far for easier checking what code to generate }
  126. );
  127. const
  128. cpu_capabilities : array[tcputype] of set of tcpuflags =
  129. (
  130. { cpu_none } [],
  131. { cpu_lx106 } [],
  132. { 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]
  133. );
  134. fpu_capabilities : array[tfputype] of set of tfpuflags =
  135. (
  136. { fpu_none } [],
  137. { fpu_soft } [],
  138. { fpu_libgcc } [],
  139. { fpu_hard } [FPUXTENSA_SINGLE]
  140. );
  141. Implementation
  142. end.