symllvm.pas 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. {
  2. Copyright (c) 2014 by Florian Klaempfl
  3. Symbol table overrides for LLVM
  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 symllvm;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,
  22. symcpu;
  23. type
  24. { defs }
  25. tllvmfiledef = class(tcpufiledef)
  26. end;
  27. tllvmvariantdef = class(tcpuvariantdef)
  28. end;
  29. tllvmformaldef = class(tcpuformaldef)
  30. end;
  31. tllvmforwarddef = class(tcpuforwarddef)
  32. end;
  33. tllvmundefineddef = class(tcpuundefineddef)
  34. end;
  35. tllvmerrordef = class(tcpuerrordef)
  36. end;
  37. tllvmpointerdef = class(tcpupointerdef)
  38. end;
  39. tllvmrecorddef = class(tcpurecorddef)
  40. end;
  41. tllvmimplementedinterface = class(tcpuimplementedinterface)
  42. end;
  43. tllvmobjectdef = class(tcpuobjectdef)
  44. end;
  45. tllvmclassrefdef = class(tcpuclassrefdef)
  46. end;
  47. tllvmarraydef = class(tcpuarraydef)
  48. end;
  49. tllvmorddef = class(tcpuorddef)
  50. end;
  51. tllvmfloatdef = class(tcpufloatdef)
  52. end;
  53. tllvmprocvardef = class(tcpuprocvardef)
  54. end;
  55. { tllvmprocdef }
  56. tllvmprocdef = class(tcpuprocdef)
  57. protected
  58. external_decl_mangled_name: TSymStr;
  59. public
  60. { overried the mangled name of external functions }
  61. function mangledname: TSymStr; override;
  62. { provide access to the original mangled name of external functions }
  63. function external_mangledname: TSymStr;
  64. end;
  65. tllvmstringdef = class(tcpustringdef)
  66. end;
  67. tllvmenumdef = class(tcpuenumdef)
  68. end;
  69. tllvmsetdef = class(tcpusetdef)
  70. end;
  71. { syms }
  72. tllvmlabelsym = class(tcpulabelsym)
  73. end;
  74. tllvmunitsym = class(tcpuunitsym)
  75. end;
  76. tllvmprogramparasym = class(tcpuprogramparasym)
  77. end;
  78. tllvmnamespacesym = class(tcpunamespacesym)
  79. end;
  80. tllvmprocsym = class(tcpuprocsym)
  81. end;
  82. tllvmtypesym = class(tcputypesym)
  83. end;
  84. tllvmfieldvarsym = class(tcpufieldvarsym)
  85. end;
  86. tllvmlocalvarsym = class(tcpulocalvarsym)
  87. end;
  88. tllvmparavarsym = class(tcpuparavarsym)
  89. end;
  90. tllvmstaticvarsym = class(tcpustaticvarsym)
  91. end;
  92. tllvmabsolutevarsym = class(tcpuabsolutevarsym)
  93. end;
  94. tllvmpropertysym = class(tcpupropertysym)
  95. end;
  96. tllvmconstsym = class(tcpuconstsym)
  97. end;
  98. tllvmenumsym = class(tcpuenumsym)
  99. end;
  100. tllvmsyssym = class(tcpusyssym)
  101. end;
  102. implementation
  103. uses
  104. symconst,symdef,symsym;
  105. { tllvmprocdef }
  106. function tllvmprocdef.mangledname: TSymStr;
  107. begin
  108. { External declarations are handled separately for the LLVM target and need
  109. a different mangled name than on other targets, because we have to
  110. create a declaration based on the declared name that redirects to the
  111. external name in order to deal with potential different signatures between
  112. the external declaration the symbol that's referred.
  113. There's no need to store the external_decl_mangled_name in the ppu file,
  114. since it can always be regenerated on the fly. }
  115. if not(po_external in procoptions) then
  116. result:=inherited
  117. else
  118. begin
  119. if external_decl_mangled_name='' then
  120. begin
  121. result:=defaultmangledname;
  122. external_decl_mangled_name:=result;
  123. end
  124. else
  125. result:=external_decl_mangled_name;
  126. end;
  127. end;
  128. function tllvmprocdef.external_mangledname: TSymStr;
  129. begin
  130. result:=inherited mangledname;
  131. end;
  132. begin
  133. { used tdef classes }
  134. cfiledef:=tllvmfiledef;
  135. cvariantdef:=tllvmvariantdef;
  136. cformaldef:=tllvmformaldef;
  137. cforwarddef:=tllvmforwarddef;
  138. cundefineddef:=tllvmundefineddef;
  139. cerrordef:=tllvmerrordef;
  140. cpointerdef:=tllvmpointerdef;
  141. crecorddef:=tllvmrecorddef;
  142. cimplementedinterface:=tllvmimplementedinterface;
  143. cobjectdef:=tllvmobjectdef;
  144. cclassrefdef:=tllvmclassrefdef;
  145. carraydef:=tllvmarraydef;
  146. corddef:=tllvmorddef;
  147. cfloatdef:=tllvmfloatdef;
  148. cprocvardef:=tllvmprocvardef;
  149. cprocdef:=tllvmprocdef;
  150. cstringdef:=tllvmstringdef;
  151. cenumdef:=tllvmenumdef;
  152. csetdef:=tllvmsetdef;
  153. { used tsym classes }
  154. clabelsym:=tllvmlabelsym;
  155. cunitsym:=tllvmunitsym;
  156. cprogramparasym:=tllvmprogramparasym;
  157. cnamespacesym:=tllvmnamespacesym;
  158. cprocsym:=tllvmprocsym;
  159. ctypesym:=tllvmtypesym;
  160. cfieldvarsym:=tllvmfieldvarsym;
  161. clocalvarsym:=tllvmlocalvarsym;
  162. cparavarsym:=tllvmparavarsym;
  163. cstaticvarsym:=tllvmstaticvarsym;
  164. cabsolutevarsym:=tllvmabsolutevarsym;
  165. cpropertysym:=tllvmpropertysym;
  166. cconstsym:=tllvmconstsym;
  167. cenumsym:=tllvmenumsym;
  168. csyssym:=tllvmsyssym;
  169. end.