cpuinfo.pas 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. {
  2. Copyright (c) 1998-2002 by the Free Pascal development team
  3. Basic Processor information for AArch64
  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. bestrealrec = TDoubleRec;
  18. ts32real = single;
  19. ts64real = double;
  20. ts80real = type extended;
  21. ts128real = type extended;
  22. ts64comp = comp;
  23. pbestreal=^bestreal;
  24. { possible supported processors for this target }
  25. tcputype =
  26. (cpu_none,
  27. cpu_armv8,
  28. cpu_armv8a,
  29. cpu_armv81a,
  30. cpu_armv82a,
  31. cpu_armv83a,
  32. cpu_armv84a,
  33. cpu_armv85a,
  34. cpu_armv86a
  35. );
  36. Type
  37. tfputype =
  38. (fpu_none,
  39. fpu_vfp
  40. );
  41. tcontrollertype =
  42. (ct_none,
  43. { Raspberry Pi 3/4 }
  44. ct_raspi3,
  45. ct_raspi4
  46. );
  47. tcontrollerdatatype = record
  48. controllertypestr, controllerunitstr: string[20];
  49. cputype: tcputype; fputype: tfputype;
  50. flashbase, flashsize, srambase, sramsize, eeprombase, eepromsize, bootbase, bootsize: dword;
  51. end;
  52. Const
  53. fputypestrllvm : array[tfputype] of string[6] = ('',
  54. ''
  55. );
  56. { Is there support for dealing with multiple microcontrollers available }
  57. { for this platform? }
  58. ControllerSupport = true; (* Not yet at least ;-) *)
  59. {# Size of native extended floating point type }
  60. extended_size = 8;
  61. { target cpu string (used by compiler options) }
  62. target_cpu_string = 'aarch64';
  63. { We know that there are fields after sramsize
  64. but we don't care about this warning }
  65. {$PUSH}
  66. {$WARN 3177 OFF}
  67. embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
  68. (
  69. (controllertypestr:''; controllerunitstr:''; cputype:cpu_none; fputype:fpu_none; flashbase:0; flashsize:0; srambase:0; sramsize:0),
  70. { Raspberry Pi 3/4 }
  71. (controllertypestr:'RASPI3'; controllerunitstr:'RASPI3'; cputype:cpu_armv8a; fputype:fpu_vfp; flashbase:$00000000; flashsize:$00000000; srambase:$00080000; sramsize:$10000000),
  72. (controllertypestr:'RASPI4'; controllerunitstr:'RASPI4'; cputype:cpu_armv8a; fputype:fpu_vfp; flashbase:$00000000; flashsize:$00000000; srambase:$00080000; sramsize:$10000000)
  73. );
  74. {$POP}
  75. { calling conventions supported by the code generator }
  76. supported_calling_conventions : tproccalloptions = [
  77. pocall_internproc,
  78. pocall_safecall,
  79. pocall_stdcall,
  80. { same as stdcall only different name mangling }
  81. pocall_cdecl,
  82. { same as stdcall only different name mangling }
  83. pocall_cppdecl,
  84. { same as stdcall but floating point numbers are handled like equal sized integers }
  85. pocall_softfloat,
  86. { same as stdcall (requires that all const records are passed by
  87. reference, but that's already done for stdcall) }
  88. pocall_mwpascal,
  89. { used for interrupt handling }
  90. pocall_interrupt
  91. ];
  92. cputypestr : array[tcputype] of string[9] = ('',
  93. 'ARMV8',
  94. 'ARMV8-A',
  95. 'ARMV8.1-A',
  96. 'ARMV8.2-A',
  97. 'ARMV8.3-A',
  98. 'ARMV8.4-A',
  99. 'ARMV8.5-A',
  100. 'ARMV8.6-A'
  101. );
  102. fputypestr : array[tfputype] of string[9] = ('',
  103. 'VFP'
  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_nodecse,cs_opt_reorder_fields,cs_opt_fastmath];
  113. level1optimizerswitches = genericlevel1optimizerswitches;
  114. level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
  115. [{$ifndef llvm}cs_opt_regvar,{$endif}cs_opt_stackframe,cs_opt_tailrecursion,cs_opt_nodecse,cs_opt_consts];
  116. level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches;
  117. level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
  118. type
  119. tcpuflags =
  120. (CPUAARCH64_HAS_LSE, { CPU supports Large System Extensions }
  121. CPUAARCH64_HAS_DOTPROD, { CPU supports dotprod extension }
  122. CPUAARCH64_HAS_CRYPTO, { CPU supports the crypto extension }
  123. CPUAARCH64_HAS_AES, { CPU supports the AES extension }
  124. CPUAARCH64_HAS_SHA2, { CPU supports the SHA2 extension }
  125. CPUAARCH64_HAS_SHA3, { CPU supports the SHA3 extension }
  126. CPUAARCH64_HAS_SM4, { CPU supports the SM3 and SM4 extension }
  127. CPUAARCH64_HAS_PROFILE, { CPU supports the profile extension }
  128. CPUAARCH64_HAS_MEMTAG, { CPU supports the memtag extension }
  129. CPUAARCH64_HAS_TME, { CPU supports the tme extension }
  130. CPUAARCH64_HAS_PAUTH { CPU supports the pauth extension }
  131. );
  132. tfpuflags =
  133. (CPUAARCH64_HAS_VFP { CPU supports VFP }
  134. );
  135. const
  136. cpu_capabilities : array[tcputype] of set of tcpuflags =
  137. ( { cpu_none } [],
  138. { cpu_armv8 } [],
  139. { cpu_armv8a } [],
  140. { cpu_armv81a } [CPUAARCH64_HAS_LSE],
  141. { cpu_armv82a } [CPUAARCH64_HAS_LSE],
  142. { cpu_armv83a } [CPUAARCH64_HAS_LSE],
  143. { cpu_armv84a } [CPUAARCH64_HAS_LSE],
  144. { cpu_armv85a } [CPUAARCH64_HAS_LSE],
  145. { cpu_armv86a } [CPUAARCH64_HAS_LSE]
  146. );
  147. fpu_capabilities : array[tfputype] of set of tfpuflags =
  148. ( { fpu_none } [],
  149. { fpu_vfp } [CPUAARCH64_HAS_VFP]
  150. );
  151. Implementation
  152. end.