cpuinfo.pas 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. {
  2. Copyright (c) 1998-2002 by the Free Pascal development team
  3. Basic Processor information for the Risc-V32
  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 = extended;
  21. ts128real = extended;
  22. ts64comp = comp;
  23. pbestreal=^bestreal;
  24. { possible supported processors for this target }
  25. tcputype =
  26. (cpu_none,
  27. cpu_rv32imac,
  28. cpu_rv32ima,
  29. cpu_rv32im,
  30. cpu_rv32i
  31. );
  32. tfputype =
  33. (fpu_none,
  34. fpu_libgcc,
  35. fpu_soft,
  36. fpu_fd
  37. );
  38. tcontrollertype =
  39. (ct_none,
  40. ct_fe310g000,
  41. ct_fe310g002,
  42. ct_hifive1,
  43. ct_hifive1revb,
  44. ct_redfive,
  45. ct_redfivething,
  46. ct_gd32vf103c4,
  47. ct_gd32vf103c6,
  48. ct_gd32vf103c8,
  49. ct_gd32vf103cb,
  50. ct_gd32vf103r4,
  51. ct_gd32vf103r6,
  52. ct_gd32vf103r8,
  53. ct_gd32vf103rb,
  54. ct_gd32vf103t4,
  55. ct_gd32vf103t6,
  56. ct_gd32vf103t8,
  57. ct_gd32vf103tb,
  58. ct_gd32vf103v8,
  59. ct_gd32vf103vb
  60. );
  61. tcontrollerdatatype = record
  62. controllertypestr, controllerunitstr: string[20];
  63. cputype: tcputype; fputype: tfputype;
  64. flashbase, flashsize, srambase, sramsize, eeprombase, eepromsize, bootbase, bootsize: dword;
  65. end;
  66. Const
  67. { Is there support for dealing with multiple microcontrollers available }
  68. { for this platform? }
  69. ControllerSupport = true;
  70. { We know that there are fields after sramsize
  71. but we don't care about this warning }
  72. {$PUSH}
  73. {$WARN 3177 OFF}
  74. embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
  75. (
  76. (controllertypestr:'' ; controllerunitstr:''; cputype:cpu_none; fputype:fpu_none; flashbase:0; flashsize:0; srambase:0; sramsize:0),
  77. (controllertypestr:'FE310G000' ; controllerunitstr:'FE310G000'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$20400000; flashsize:$01000000; srambase:$80000000; sramsize:$00004000),
  78. (controllertypestr:'FE310G002' ; controllerunitstr:'FE310G002'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$20010000; flashsize:$00400000; srambase:$80000000; sramsize:$00004000),
  79. (controllertypestr:'HIFIVE1' ; controllerunitstr:'FE310G000'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$20400000; flashsize:$01000000; srambase:$80000000; sramsize:$00004000),
  80. (controllertypestr:'HIFIVE1REVB' ; controllerunitstr:'FE310G002'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$20010000; flashsize:$00400000; srambase:$80000000; sramsize:$00004000),
  81. (controllertypestr:'REDFIVE' ; controllerunitstr:'FE310G002'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$20010000; flashsize:$00400000; srambase:$80000000; sramsize:$00004000),
  82. (controllertypestr:'REDFIVETHING'; controllerunitstr:'FE310G002'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$20010000; flashsize:$02400000; srambase:$80000000; sramsize:$00004000),
  83. (controllertypestr:'GD32VF103C4' ; controllerunitstr:'GD32VF103XX'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$08000000; flashsize:$00004000; srambase:$20000000; sramsize:$00001800),
  84. (controllertypestr:'GD32VF103C6' ; controllerunitstr:'GD32VF103XX'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$08000000; flashsize:$00008000; srambase:$20000000; sramsize:$00002800),
  85. (controllertypestr:'GD32VF103C8' ; controllerunitstr:'GD32VF103XX'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$08000000; flashsize:$00010000; srambase:$20000000; sramsize:$00005000),
  86. (controllertypestr:'GD32VF103CB' ; controllerunitstr:'GD32VF103XX'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$08000000; flashsize:$00020000; srambase:$20000000; sramsize:$00008000),
  87. (controllertypestr:'GD32VF103R4' ; controllerunitstr:'GD32VF103XX'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$08000000; flashsize:$00004000; srambase:$20000000; sramsize:$00001800),
  88. (controllertypestr:'GD32VF103R6' ; controllerunitstr:'GD32VF103XX'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$08000000; flashsize:$00008000; srambase:$20000000; sramsize:$00002800),
  89. (controllertypestr:'GD32VF103R8' ; controllerunitstr:'GD32VF103XX'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$08000000; flashsize:$00010000; srambase:$20000000; sramsize:$00005000),
  90. (controllertypestr:'GD32VF103RB' ; controllerunitstr:'GD32VF103XX'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$08000000; flashsize:$00020000; srambase:$20000000; sramsize:$00008000),
  91. (controllertypestr:'GD32VF103T4' ; controllerunitstr:'GD32VF103XX'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$08000000; flashsize:$00004000; srambase:$20000000; sramsize:$00001800),
  92. (controllertypestr:'GD32VF103T6' ; controllerunitstr:'GD32VF103XX'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$08000000; flashsize:$00008000; srambase:$20000000; sramsize:$00002800),
  93. (controllertypestr:'GD32VF103T8' ; controllerunitstr:'GD32VF103XX'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$08000000; flashsize:$00010000; srambase:$20000000; sramsize:$00005000),
  94. (controllertypestr:'GD32VF103TB' ; controllerunitstr:'GD32VF103XX'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$08000000; flashsize:$00020000; srambase:$20000000; sramsize:$00008000),
  95. (controllertypestr:'GD32VF103V8' ; controllerunitstr:'GD32VF103XX'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$08000000; flashsize:$00010000; srambase:$20000000; sramsize:$00005000),
  96. (controllertypestr:'GD32VF103VB' ; controllerunitstr:'GD32VF103XX'; cputype:cpu_rv32imac; fputype:fpu_none; flashbase:$08000000; flashsize:$00020000; srambase:$20000000; sramsize:$00008000)
  97. );
  98. {$POP}
  99. { calling conventions supported by the code generator }
  100. supported_calling_conventions : tproccalloptions = [
  101. pocall_internproc,
  102. pocall_stdcall,
  103. { the difference to stdcall is only the name mangling }
  104. pocall_cdecl,
  105. { the difference to stdcall is only the name mangling }
  106. pocall_cppdecl,
  107. { pass all const records by reference }
  108. pocall_mwpascal
  109. ];
  110. cputypestr : array[tcputype] of string[10] = ('',
  111. 'RV32IMAC',
  112. 'RV32IMA',
  113. 'RV32IM',
  114. 'RV32I'
  115. );
  116. fputypestr : array[tfputype] of string[8] = (
  117. 'LIBGCC',
  118. 'NONE',
  119. 'SOFT',
  120. 'FD'
  121. );
  122. { Supported optimizations, only used for information }
  123. supported_optimizerswitches = genericlevel1optimizerswitches+
  124. genericlevel2optimizerswitches+
  125. genericlevel3optimizerswitches-
  126. { no need to write info about those }
  127. [cs_opt_level1,cs_opt_level2,cs_opt_level3]+
  128. [{$ifndef llvm}cs_opt_regvar,{$endif}cs_opt_loopunroll,cs_opt_nodecse,
  129. cs_opt_tailrecursion,cs_opt_reorder_fields,cs_opt_fastmath,
  130. cs_opt_stackframe];
  131. level1optimizerswitches = genericlevel1optimizerswitches;
  132. level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + [{$ifndef llvm}cs_opt_regvar,{$endif}cs_opt_nodecse,cs_opt_tailrecursion];
  133. level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
  134. level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [cs_opt_stackframe];
  135. type
  136. tcpuflags =
  137. (CPURV_HAS_MUL,
  138. CPURV_HAS_ATOMIC,
  139. CPURV_HAS_COMPACT
  140. );
  141. const
  142. cpu_capabilities : array[tcputype] of set of tcpuflags =
  143. ( { cpu_none } [],
  144. { cpu_rv32imac } [CPURV_HAS_MUL,CPURV_HAS_ATOMIC,CPURV_HAS_COMPACT],
  145. { cpu_rv32ima } [CPURV_HAS_MUL,CPURV_HAS_ATOMIC],
  146. { cpu_rv32im } [CPURV_HAS_MUL],
  147. { cpu_rv32i } []
  148. );
  149. Implementation
  150. end.