symcpu.pas 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. {
  2. Copyright (c) 2014 by Florian Klaempfl
  3. Symbol table overrides for PowerPC64
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit symcpu;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. symtype,symdef,symsym;
  22. type
  23. { defs }
  24. tcpufiledef = class(tfiledef)
  25. end;
  26. tcpufiledefclass = class of tcpufiledef;
  27. tcpuvariantdef = class(tvariantdef)
  28. end;
  29. tcpuvariantdefclass = class of tcpuvariantdef;
  30. tcpuformaldef = class(tformaldef)
  31. end;
  32. tcpuformaldefclass = class of tcpuformaldef;
  33. tcpuforwarddef = class(tforwarddef)
  34. end;
  35. tcpuforwarddefclass = class of tcpuforwarddef;
  36. tcpuundefineddef = class(tundefineddef)
  37. end;
  38. tcpuundefineddefclass = class of tcpuundefineddef;
  39. tcpuerrordef = class(terrordef)
  40. end;
  41. tcpuerrordefclass = class of tcpuerrordef;
  42. tcpupointerdef = class(tpointerdef)
  43. end;
  44. tcpupointerdefclass = class of tcpupointerdef;
  45. tcpurecorddef = class(trecorddef)
  46. { returns whether the record's elements (including arrays) all have
  47. the same floating point or vector type; returns that type in the "def"
  48. parameter if so }
  49. function has_single_type_elfv2(out def: tdef): boolean;
  50. end;
  51. tcpurecorddefclass = class of tcpurecorddef;
  52. tcpuimplementedinterface = class(timplementedinterface)
  53. end;
  54. tcpuimplementedinterfaceclass = class of tcpuimplementedinterface;
  55. tcpuobjectdef = class(tobjectdef)
  56. end;
  57. tcpuobjectdefclass = class of tcpuobjectdef;
  58. tcpuclassrefdef = class(tclassrefdef)
  59. end;
  60. tcpuclassrefdefclass = class of tcpuclassrefdef;
  61. tcpuarraydef = class(tarraydef)
  62. { see tcpurecorddef.has_single_type_elfv2 }
  63. function has_single_type_elfv2(out def: tdef): boolean;
  64. end;
  65. tcpuarraydefclass = class of tcpuarraydef;
  66. tcpuorddef = class(torddef)
  67. end;
  68. tcpuorddefclass = class of tcpuorddef;
  69. tcpufloatdef = class(tfloatdef)
  70. end;
  71. tcpufloatdefclass = class of tcpufloatdef;
  72. tcpuprocvardef = class(tprocvardef)
  73. end;
  74. tcpuprocvardefclass = class of tcpuprocvardef;
  75. tcpuprocdef = class(tprocdef)
  76. end;
  77. tcpuprocdefclass = class of tcpuprocdef;
  78. tcpustringdef = class(tstringdef)
  79. end;
  80. tcpustringdefclass = class of tcpustringdef;
  81. tcpuenumdef = class(tenumdef)
  82. end;
  83. tcpuenumdefclass = class of tcpuenumdef;
  84. tcpusetdef = class(tsetdef)
  85. end;
  86. tcpusetdefclass = class of tcpusetdef;
  87. { syms }
  88. tcpulabelsym = class(tlabelsym)
  89. end;
  90. tcpulabelsymclass = class of tcpulabelsym;
  91. tcpuunitsym = class(tunitsym)
  92. end;
  93. tcpuunitsymclass = class of tcpuunitsym;
  94. tcpunamespacesym = class(tnamespacesym)
  95. end;
  96. tcpunamespacesymclass = class of tcpunamespacesym;
  97. tcpuprocsym = class(tprocsym)
  98. end;
  99. tcpuprocsymclass = class of tcpuprocsym;
  100. tcputypesym = class(ttypesym)
  101. end;
  102. tcpuypesymclass = class of tcputypesym;
  103. tcpufieldvarsym = class(tfieldvarsym)
  104. end;
  105. tcpufieldvarsymclass = class of tcpufieldvarsym;
  106. tcpulocalvarsym = class(tlocalvarsym)
  107. end;
  108. tcpulocalvarsymclass = class of tcpulocalvarsym;
  109. tcpuparavarsym = class(tparavarsym)
  110. end;
  111. tcpuparavarsymclass = class of tcpuparavarsym;
  112. tcpustaticvarsym = class(tstaticvarsym)
  113. end;
  114. tcpustaticvarsymclass = class of tcpustaticvarsym;
  115. tcpuabsolutevarsym = class(tabsolutevarsym)
  116. end;
  117. tcpuabsolutevarsymclass = class of tcpuabsolutevarsym;
  118. tcpupropertysym = class(tpropertysym)
  119. end;
  120. tcpupropertysymclass = class of tcpupropertysym;
  121. tcpuconstsym = class(tconstsym)
  122. end;
  123. tcpuconstsymclass = class of tcpuconstsym;
  124. tcpuenumsym = class(tenumsym)
  125. end;
  126. tcpuenumsymclass = class of tcpuenumsym;
  127. tcpusyssym = class(tsyssym)
  128. end;
  129. tcpusyssymclass = class of tcpusyssym;
  130. const
  131. pbestrealtype : ^tdef = @s64floattype;
  132. implementation
  133. uses
  134. symconst, defutil, defcmp;
  135. { tcpurecorddef }
  136. function tcpurecorddef.has_single_type_elfv2(out def: tdef): boolean;
  137. var
  138. i: longint;
  139. checkdef, tmpdef: tdef;
  140. begin
  141. def:=nil;
  142. tmpdef:=nil;
  143. result:=false;
  144. for i:=0 to symtable.SymList.Count-1 do
  145. begin
  146. if (tsym(symtable.symlist[i]).typ=fieldvarsym) and
  147. not(sp_static in tsym(symtable.symlist[i]).symoptions) then
  148. begin
  149. checkdef:=tfieldvarsym(symtable.symlist[i]).vardef;
  150. repeat
  151. case checkdef.typ of
  152. floatdef:
  153. ;
  154. arraydef:
  155. if not is_special_array(checkdef) then
  156. checkdef:=tarraydef(checkdef).elementdef
  157. else
  158. exit;
  159. recorddef:
  160. if not tcpurecorddef(checkdef).has_single_type_elfv2(checkdef) then
  161. exit;
  162. else
  163. exit;
  164. end;
  165. until checkdef.typ=floatdef;
  166. if not assigned(def) then
  167. def:=checkdef
  168. else if not equal_defs(def,checkdef) then
  169. exit;
  170. end;
  171. end;
  172. if assigned(def) then
  173. result:=true;
  174. end;
  175. { tcpuarraydef }
  176. function tcpuarraydef.has_single_type_elfv2(out def: tdef): boolean;
  177. var
  178. checkdef: tdef;
  179. begin
  180. result:=false;
  181. checkdef:=self;
  182. while (checkdef.typ=arraydef) and
  183. not is_special_array(checkdef) do
  184. checkdef:=tarraydef(checkdef).elementdef;
  185. case checkdef.typ of
  186. recorddef:
  187. result:=tcpurecorddef(checkdef).has_single_type_elfv2(def);
  188. floatdef:
  189. begin
  190. def:=checkdef;
  191. result:=true;
  192. exit;
  193. end;
  194. else
  195. exit;
  196. end;
  197. end;
  198. begin
  199. { used tdef classes }
  200. cfiledef:=tcpufiledef;
  201. cvariantdef:=tcpuvariantdef;
  202. cformaldef:=tcpuformaldef;
  203. cforwarddef:=tcpuforwarddef;
  204. cundefineddef:=tcpuundefineddef;
  205. cerrordef:=tcpuerrordef;
  206. cpointerdef:=tcpupointerdef;
  207. crecorddef:=tcpurecorddef;
  208. cimplementedinterface:=tcpuimplementedinterface;
  209. cobjectdef:=tcpuobjectdef;
  210. cclassrefdef:=tcpuclassrefdef;
  211. carraydef:=tcpuarraydef;
  212. corddef:=tcpuorddef;
  213. cfloatdef:=tcpufloatdef;
  214. cprocvardef:=tcpuprocvardef;
  215. cprocdef:=tcpuprocdef;
  216. cstringdef:=tcpustringdef;
  217. cenumdef:=tcpuenumdef;
  218. csetdef:=tcpusetdef;
  219. { used tsym classes }
  220. clabelsym:=tcpulabelsym;
  221. cunitsym:=tcpuunitsym;
  222. cnamespacesym:=tcpunamespacesym;
  223. cprocsym:=tcpuprocsym;
  224. ctypesym:=tcputypesym;
  225. cfieldvarsym:=tcpufieldvarsym;
  226. clocalvarsym:=tcpulocalvarsym;
  227. cparavarsym:=tcpuparavarsym;
  228. cstaticvarsym:=tcpustaticvarsym;
  229. cabsolutevarsym:=tcpuabsolutevarsym;
  230. cpropertysym:=tcpupropertysym;
  231. cconstsym:=tcpuconstsym;
  232. cenumsym:=tcpuenumsym;
  233. csyssym:=tcpusyssym;
  234. end.