symcpu.pas 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. tcpuprogramparasym = class(tprogramparasym)
  95. end;
  96. tcpuprogramparasymclass = class(tprogramparasym);
  97. tcpunamespacesym = class(tnamespacesym)
  98. end;
  99. tcpunamespacesymclass = class of tcpunamespacesym;
  100. tcpuprocsym = class(tprocsym)
  101. end;
  102. tcpuprocsymclass = class of tcpuprocsym;
  103. tcputypesym = class(ttypesym)
  104. end;
  105. tcpuypesymclass = class of tcputypesym;
  106. tcpufieldvarsym = class(tfieldvarsym)
  107. end;
  108. tcpufieldvarsymclass = class of tcpufieldvarsym;
  109. tcpulocalvarsym = class(tlocalvarsym)
  110. end;
  111. tcpulocalvarsymclass = class of tcpulocalvarsym;
  112. tcpuparavarsym = class(tparavarsym)
  113. end;
  114. tcpuparavarsymclass = class of tcpuparavarsym;
  115. tcpustaticvarsym = class(tstaticvarsym)
  116. end;
  117. tcpustaticvarsymclass = class of tcpustaticvarsym;
  118. tcpuabsolutevarsym = class(tabsolutevarsym)
  119. end;
  120. tcpuabsolutevarsymclass = class of tcpuabsolutevarsym;
  121. tcpupropertysym = class(tpropertysym)
  122. end;
  123. tcpupropertysymclass = class of tcpupropertysym;
  124. tcpuconstsym = class(tconstsym)
  125. end;
  126. tcpuconstsymclass = class of tcpuconstsym;
  127. tcpuenumsym = class(tenumsym)
  128. end;
  129. tcpuenumsymclass = class of tcpuenumsym;
  130. tcpusyssym = class(tsyssym)
  131. end;
  132. tcpusyssymclass = class of tcpusyssym;
  133. const
  134. pbestrealtype : ^tdef = @s64floattype;
  135. implementation
  136. uses
  137. symconst, symutil, defutil, defcmp;
  138. { tcpurecorddef }
  139. function tcpurecorddef.has_single_type_elfv2(out def: tdef): boolean;
  140. var
  141. i: longint;
  142. checkdef, tmpdef: tdef;
  143. begin
  144. def:=nil;
  145. tmpdef:=nil;
  146. result:=false;
  147. for i:=0 to symtable.SymList.Count-1 do
  148. begin
  149. if is_normal_fieldvarsym(tsym(symtable.symlist[i])) then
  150. begin
  151. checkdef:=tfieldvarsym(symtable.symlist[i]).vardef;
  152. repeat
  153. case checkdef.typ of
  154. floatdef:
  155. ;
  156. arraydef:
  157. if not is_special_array(checkdef) then
  158. checkdef:=tarraydef(checkdef).elementdef
  159. else
  160. exit;
  161. recorddef:
  162. if not tcpurecorddef(checkdef).has_single_type_elfv2(checkdef) then
  163. exit;
  164. else
  165. exit;
  166. end;
  167. until checkdef.typ=floatdef;
  168. if not assigned(def) then
  169. def:=checkdef
  170. else if not equal_defs(def,checkdef) then
  171. exit;
  172. end;
  173. end;
  174. if assigned(def) then
  175. result:=true;
  176. end;
  177. { tcpuarraydef }
  178. function tcpuarraydef.has_single_type_elfv2(out def: tdef): boolean;
  179. var
  180. checkdef: tdef;
  181. begin
  182. result:=false;
  183. checkdef:=self;
  184. while (checkdef.typ=arraydef) and
  185. not is_special_array(checkdef) do
  186. checkdef:=tarraydef(checkdef).elementdef;
  187. case checkdef.typ of
  188. recorddef:
  189. result:=tcpurecorddef(checkdef).has_single_type_elfv2(def);
  190. floatdef:
  191. begin
  192. def:=checkdef;
  193. result:=true;
  194. exit;
  195. end;
  196. else
  197. exit;
  198. end;
  199. end;
  200. begin
  201. { used tdef classes }
  202. cfiledef:=tcpufiledef;
  203. cvariantdef:=tcpuvariantdef;
  204. cformaldef:=tcpuformaldef;
  205. cforwarddef:=tcpuforwarddef;
  206. cundefineddef:=tcpuundefineddef;
  207. cerrordef:=tcpuerrordef;
  208. cpointerdef:=tcpupointerdef;
  209. crecorddef:=tcpurecorddef;
  210. cimplementedinterface:=tcpuimplementedinterface;
  211. cobjectdef:=tcpuobjectdef;
  212. cclassrefdef:=tcpuclassrefdef;
  213. carraydef:=tcpuarraydef;
  214. corddef:=tcpuorddef;
  215. cfloatdef:=tcpufloatdef;
  216. cprocvardef:=tcpuprocvardef;
  217. cprocdef:=tcpuprocdef;
  218. cstringdef:=tcpustringdef;
  219. cenumdef:=tcpuenumdef;
  220. csetdef:=tcpusetdef;
  221. { used tsym classes }
  222. clabelsym:=tcpulabelsym;
  223. cunitsym:=tcpuunitsym;
  224. cprogramparasym:=tcpuprogramparasym;
  225. cnamespacesym:=tcpunamespacesym;
  226. cprocsym:=tcpuprocsym;
  227. ctypesym:=tcputypesym;
  228. cfieldvarsym:=tcpufieldvarsym;
  229. clocalvarsym:=tcpulocalvarsym;
  230. cparavarsym:=tcpuparavarsym;
  231. cstaticvarsym:=tcpustaticvarsym;
  232. cabsolutevarsym:=tcpuabsolutevarsym;
  233. cpropertysym:=tcpupropertysym;
  234. cconstsym:=tcpuconstsym;
  235. cenumsym:=tcpuenumsym;
  236. csyssym:=tcpusyssym;
  237. end.