psystem.pas 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Load the system unit, create required defs for systemunit
  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 psystem;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. symbase;
  22. procedure create_intern_symbols;
  23. procedure create_intern_types;
  24. procedure load_intern_types;
  25. procedure registernodes;
  26. procedure registertais;
  27. implementation
  28. uses
  29. globals,globtype,verbose,constexp,cpuinfo,
  30. systems,
  31. symconst,symtype,symsym,symdef,symtable,
  32. aasmtai,aasmdata,aasmcpu,
  33. ncgutil,ncgrtti,fmodule,
  34. node,nbas,nflw,nset,ncon,ncnv,nld,nmem,ncal,nmat,nadd,ninl,nopt
  35. ;
  36. procedure create_intern_symbols;
  37. {
  38. all intern procedures for the system unit
  39. }
  40. begin
  41. systemunit.insert(tsyssym.create('Concat',in_concat_x));
  42. systemunit.insert(tsyssym.create('Write',in_write_x));
  43. systemunit.insert(tsyssym.create('WriteLn',in_writeln_x));
  44. systemunit.insert(tsyssym.create('WriteStr',in_writestr_x));
  45. systemunit.insert(tsyssym.create('Assigned',in_assigned_x));
  46. systemunit.insert(tsyssym.create('Read',in_read_x));
  47. systemunit.insert(tsyssym.create('ReadLn',in_readln_x));
  48. systemunit.insert(tsyssym.create('ReadStr',in_readstr_x));
  49. systemunit.insert(tsyssym.create('Ofs',in_ofs_x));
  50. systemunit.insert(tsyssym.create('SizeOf',in_sizeof_x));
  51. systemunit.insert(tsyssym.create('BitSizeOf',in_bitsizeof_x));
  52. systemunit.insert(tsyssym.create('TypeOf',in_typeof_x));
  53. systemunit.insert(tsyssym.create('Low',in_low_x));
  54. systemunit.insert(tsyssym.create('High',in_high_x));
  55. systemunit.insert(tsyssym.create('Slice',in_slice_x));
  56. systemunit.insert(tsyssym.create('Seg',in_seg_x));
  57. systemunit.insert(tsyssym.create('Ord',in_ord_x));
  58. systemunit.insert(tsyssym.create('Pred',in_pred_x));
  59. systemunit.insert(tsyssym.create('Succ',in_succ_x));
  60. systemunit.insert(tsyssym.create('Exclude',in_exclude_x_y));
  61. systemunit.insert(tsyssym.create('Include',in_include_x_y));
  62. systemunit.insert(tsyssym.create('Pack',in_pack_x_y_z));
  63. systemunit.insert(tsyssym.create('Unpack',in_unpack_x_y_z));
  64. systemunit.insert(tsyssym.create('Break',in_break));
  65. systemunit.insert(tsyssym.create('Exit',in_exit));
  66. systemunit.insert(tsyssym.create('Continue',in_continue));
  67. systemunit.insert(tsyssym.create('Leave',in_leave)); {macpas only}
  68. systemunit.insert(tsyssym.create('Cycle',in_cycle)); {macpas only}
  69. systemunit.insert(tsyssym.create('Dec',in_dec_x));
  70. systemunit.insert(tsyssym.create('Inc',in_inc_x));
  71. systemunit.insert(tsyssym.create('Str',in_str_x_string));
  72. systemunit.insert(tsyssym.create('Assert',in_assert_x_y));
  73. systemunit.insert(tsyssym.create('Val',in_val_x));
  74. systemunit.insert(tsyssym.create('Addr',in_addr_x));
  75. systemunit.insert(tsyssym.create('TypeInfo',in_typeinfo_x));
  76. systemunit.insert(tsyssym.create('SetLength',in_setlength_x));
  77. systemunit.insert(tsyssym.create('Copy',in_copy_x));
  78. systemunit.insert(tsyssym.create('Initialize',in_initialize_x));
  79. systemunit.insert(tsyssym.create('Finalize',in_finalize_x));
  80. systemunit.insert(tsyssym.create('Length',in_length_x));
  81. systemunit.insert(tsyssym.create('New',in_new_x));
  82. systemunit.insert(tsyssym.create('Dispose',in_dispose_x));
  83. {$if defined(x86) or defined(arm) or defined(jvm)}
  84. systemunit.insert(tsyssym.create('Get_Frame',in_get_frame));
  85. {$endif defined(x86) or defined(arm) or defined(jvm)}
  86. systemunit.insert(tsyssym.create('Unaligned',in_unaligned_x));
  87. systemunit.insert(tsyssym.create('Aligned',in_aligned_x));
  88. systemunit.insert(tsyssym.create('ObjCSelector',in_objc_selector_x)); { objc only }
  89. systemunit.insert(tsyssym.create('ObjCEncode',in_objc_encode_x)); { objc only }
  90. systemunit.insert(tsyssym.create('Default',in_default_x));
  91. end;
  92. procedure set_default_int_types;
  93. begin
  94. {$ifdef cpu64bitaddr}
  95. uinttype:=u64inttype;
  96. sinttype:=s64inttype;
  97. ptruinttype:=u64inttype;
  98. ptrsinttype:=s64inttype;
  99. {$endif cpu64bitaddr}
  100. {$ifdef cpu32bitaddr}
  101. uinttype:=u32inttype;
  102. sinttype:=s32inttype;
  103. ptruinttype:=u32inttype;
  104. ptrsinttype:=s32inttype;
  105. {$endif cpu32bitaddr}
  106. {$ifdef cpu32bitalu}
  107. uinttype:=u32inttype;
  108. sinttype:=s32inttype;
  109. {$endif cpu32bitalu}
  110. {$ifdef cpu16bitaddr}
  111. ptruinttype:=u16inttype;
  112. ptrsinttype:=s16inttype;
  113. {$endif cpu16bitaddr}
  114. {$ifdef cpu16bitalu}
  115. uinttype:=u16inttype;
  116. sinttype:=s16inttype;
  117. {$endif cpu16bitalu}
  118. {$ifdef cpu8bitalu}
  119. uinttype:=u8inttype;
  120. sinttype:=s8inttype;
  121. {$endif cpu8bitalu}
  122. {$ifndef avr}
  123. osuinttype:=uinttype;
  124. ossinttype:=sinttype;
  125. {$else avr}
  126. osuinttype:=u16inttype;
  127. ossinttype:=s16inttype;
  128. {$endif avr}
  129. end;
  130. procedure create_intern_types;
  131. {
  132. all the types inserted into the system unit
  133. }
  134. function addtype(const s:string;def:tdef):ttypesym;
  135. begin
  136. result:=ttypesym.create(s,def);
  137. systemunit.insert(result);
  138. end;
  139. procedure addfield(recst:tabstractrecordsymtable;sym:tfieldvarsym);
  140. begin
  141. recst.insert(sym);
  142. recst.addfield(sym,vis_hidden);
  143. end;
  144. procedure create_fpu_types;
  145. begin
  146. if init_settings.fputype<>fpu_none then
  147. begin
  148. s32floattype:=tfloatdef.create(s32real);
  149. s64floattype:=tfloatdef.create(s64real);
  150. s80floattype:=tfloatdef.create(s80real);
  151. sc80floattype:=tfloatdef.create(sc80real);
  152. end else begin
  153. s32floattype:=nil;
  154. s64floattype:=nil;
  155. s80floattype:=nil;
  156. sc80floattype:=nil;
  157. end;
  158. end;
  159. var
  160. hrecst : trecordsymtable;
  161. begin
  162. symtablestack.push(systemunit);
  163. cundefinedtype:=tundefineddef.create;
  164. cformaltype:=tformaldef.create(false);
  165. ctypedformaltype:=tformaldef.create(true);
  166. voidtype:=torddef.create(uvoid,0,0);
  167. u8inttype:=torddef.create(u8bit,0,255);
  168. s8inttype:=torddef.create(s8bit,int64(-128),127);
  169. u16inttype:=torddef.create(u16bit,0,65535);
  170. s16inttype:=torddef.create(s16bit,int64(-32768),32767);
  171. u32inttype:=torddef.create(u32bit,0,high(longword));
  172. s32inttype:=torddef.create(s32bit,int64(low(longint)),int64(high(longint)));
  173. u64inttype:=torddef.create(u64bit,low(qword),high(qword));
  174. s64inttype:=torddef.create(s64bit,low(int64),high(int64));
  175. pasbool8type:=torddef.create(pasbool8,0,1);
  176. pasbool16type:=torddef.create(pasbool16,0,1);
  177. pasbool32type:=torddef.create(pasbool32,0,1);
  178. pasbool64type:=torddef.create(pasbool64,0,1);
  179. bool8type:=torddef.create(bool8bit,low(int64),high(int64));
  180. bool16type:=torddef.create(bool16bit,low(int64),high(int64));
  181. bool32type:=torddef.create(bool32bit,low(int64),high(int64));
  182. bool64type:=torddef.create(bool64bit,low(int64),high(int64));
  183. cansichartype:=torddef.create(uchar,0,255);
  184. cwidechartype:=torddef.create(uwidechar,0,65535);
  185. cshortstringtype:=tstringdef.createshort(255);
  186. { should we give a length to the default long and ansi string definition ?? }
  187. clongstringtype:=tstringdef.createlong(-1);
  188. cansistringtype:=tstringdef.createansi(0);
  189. if target_info.system in systems_windows then
  190. cwidestringtype:=tstringdef.createwide
  191. else
  192. cwidestringtype:=tstringdef.createunicode;
  193. cunicodestringtype:=tstringdef.createunicode;
  194. { length=0 for shortstring is open string (needed for readln(string) }
  195. openshortstringtype:=tstringdef.createshort(0);
  196. openchararraytype:=tarraydef.create(0,-1,s32inttype);
  197. tarraydef(openchararraytype).elementdef:=cansichartype;
  198. {$ifdef x86}
  199. create_fpu_types;
  200. {$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
  201. if target_info.system=system_x86_64_win64 then
  202. begin
  203. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  204. pbestrealtype:=@s64floattype;
  205. end
  206. else
  207. {$endif FPC_SUPPORT_X87_TYPES_ON_WIN64}
  208. s64currencytype:=tfloatdef.create(s64currency);
  209. {$endif x86}
  210. {$ifdef powerpc}
  211. create_fpu_types;
  212. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  213. {$endif powerpc}
  214. {$ifdef POWERPC64}
  215. create_fpu_types;
  216. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  217. {$endif POWERPC64}
  218. {$ifdef sparc}
  219. create_fpu_types;
  220. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  221. {$endif sparc}
  222. {$ifdef m68k}
  223. create_fpu_types;
  224. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  225. {$endif}
  226. {$ifdef arm}
  227. create_fpu_types;
  228. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  229. {$endif arm}
  230. {$ifdef avr}
  231. s32floattype:=tfloatdef.create(s32real);
  232. s64floattype:=tfloatdef.create(s64real);
  233. s80floattype:=tfloatdef.create(s80real);
  234. sc80floattype:=tfloatdef.create(sc80real);
  235. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  236. {$endif avr}
  237. {$ifdef mips}
  238. create_fpu_types;
  239. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  240. {$endif mips}
  241. {$ifdef jvm}
  242. create_fpu_types;
  243. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  244. {$endif jvm}
  245. set_default_int_types;
  246. { some other definitions }
  247. voidpointertype:=tpointerdef.create(voidtype);
  248. charpointertype:=tpointerdef.create(cansichartype);
  249. widecharpointertype:=tpointerdef.create(cwidechartype);
  250. {$ifdef x86}
  251. voidnearpointertype:=tpointerdef.createx86(voidtype,x86pt_near);
  252. voidnearcspointertype:=tpointerdef.createx86(voidtype,x86pt_near_cs);
  253. voidneardspointertype:=tpointerdef.createx86(voidtype,x86pt_near_ds);
  254. voidnearsspointertype:=tpointerdef.createx86(voidtype,x86pt_near_ss);
  255. voidnearespointertype:=tpointerdef.createx86(voidtype,x86pt_near_es);
  256. voidnearfspointertype:=tpointerdef.createx86(voidtype,x86pt_near_fs);
  257. voidneargspointertype:=tpointerdef.createx86(voidtype,x86pt_near_gs);
  258. {$ifdef i8086}
  259. voidfarpointertype:=tpointerdef.createx86(voidtype,x86pt_far);
  260. voidhugepointertype:=tpointerdef.createx86(voidtype,x86pt_huge);
  261. {$endif i8086}
  262. {$endif x86}
  263. cfiletype:=tfiledef.createuntyped;
  264. cvarianttype:=tvariantdef.create(vt_normalvariant);
  265. colevarianttype:=tvariantdef.create(vt_olevariant);
  266. {$ifdef cpufpemu}
  267. { Normal types }
  268. (* we use the same types as without emulator, the only
  269. difference is that direct calls to the emulator are generated
  270. if (cs_fp_emulation in current_settings.moduleswitches) then
  271. begin
  272. addtype('Single',s32floattype);
  273. { extended size is the best real type for the target }
  274. addtype('Real',s32floattype);
  275. pbestrealtype:=@s32floattype;
  276. { extended size is the best real type for the target }
  277. addtype('Extended',pbestrealtype^);
  278. end
  279. else
  280. *)
  281. {$endif cpufpemu}
  282. if init_settings.fputype <> fpu_none then
  283. begin
  284. addtype('Single',s32floattype);
  285. addtype('Double',s64floattype);
  286. { extended size is the best real type for the target }
  287. addtype('Extended',pbestrealtype^);
  288. { CExtended corresponds to the C version of the Extended type
  289. (either "long double" or "double") }
  290. if target_info.system in systems_android then
  291. { Android has "long double"="double" even for x86 }
  292. addtype('CExtended',s64floattype)
  293. else
  294. if tfloatdef(pbestrealtype^).floattype=s80real then
  295. addtype('CExtended',sc80floattype)
  296. else
  297. addtype('CExtended',pbestrealtype^);
  298. end;
  299. {$ifdef x86}
  300. {$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
  301. if target_info.system<>system_x86_64_win64 then
  302. {$endif FPC_SUPPORT_X87_TYPES_ON_WIN64}
  303. addtype('Comp',tfloatdef.create(s64comp));
  304. {$endif x86}
  305. addtype('Currency',s64currencytype);
  306. addtype('Pointer',voidpointertype);
  307. {$ifdef x86}
  308. addtype('NearPointer',voidnearpointertype);
  309. addtype('NearCsPointer',voidnearcspointertype);
  310. addtype('NearDsPointer',voidneardspointertype);
  311. addtype('NearSsPointer',voidnearsspointertype);
  312. addtype('NearEsPointer',voidnearespointertype);
  313. addtype('NearFsPointer',voidnearfspointertype);
  314. addtype('NearGsPointer',voidneargspointertype);
  315. {$ifdef i8086}
  316. addtype('FarPointer',voidfarpointertype);
  317. addtype('HugePointer',voidhugepointertype);
  318. {$endif i8086}
  319. {$endif x86}
  320. addtype('ShortString',cshortstringtype);
  321. {$ifdef support_longstring}
  322. addtype('LongString',clongstringtype);
  323. {$endif support_longstring}
  324. addtype('AnsiString',cansistringtype);
  325. addtype('WideString',cwidestringtype);
  326. addtype('UnicodeString',cunicodestringtype);
  327. addtype('OpenString',openshortstringtype);
  328. addtype('Boolean',pasbool8type);
  329. addtype('Boolean16',pasbool16type);
  330. addtype('Boolean32',pasbool32type);
  331. addtype('Boolean64',pasbool64type);
  332. addtype('ByteBool',bool8type);
  333. addtype('WordBool',bool16type);
  334. addtype('LongBool',bool32type);
  335. addtype('QWordBool',bool64type);
  336. addtype('Byte',u8inttype);
  337. addtype('ShortInt',s8inttype);
  338. addtype('Word',u16inttype);
  339. addtype('SmallInt',s16inttype);
  340. addtype('LongWord',u32inttype);
  341. addtype('LongInt',s32inttype);
  342. addtype('QWord',u64inttype);
  343. addtype('Int64',s64inttype);
  344. addtype('Char',cansichartype);
  345. addtype('WideChar',cwidechartype);
  346. addtype('Text',tfiledef.createtext);
  347. addtype('TypedFile',tfiledef.createtyped(voidtype));
  348. addtype('Variant',cvarianttype);
  349. addtype('OleVariant',colevarianttype);
  350. { Internal types }
  351. addtype('$undefined',cundefinedtype);
  352. addtype('$formal',cformaltype);
  353. addtype('$typedformal',ctypedformaltype);
  354. addtype('$void',voidtype);
  355. addtype('$byte',u8inttype);
  356. addtype('$shortint',s8inttype);
  357. addtype('$word',u16inttype);
  358. addtype('$smallint',s16inttype);
  359. addtype('$ulong',u32inttype);
  360. addtype('$longint',s32inttype);
  361. addtype('$qword',u64inttype);
  362. addtype('$int64',s64inttype);
  363. addtype('$char',cansichartype);
  364. addtype('$widechar',cwidechartype);
  365. addtype('$shortstring',cshortstringtype);
  366. addtype('$longstring',clongstringtype);
  367. addtype('$ansistring',cansistringtype);
  368. addtype('$widestring',cwidestringtype);
  369. addtype('$unicodestring',cunicodestringtype);
  370. addtype('$openshortstring',openshortstringtype);
  371. addtype('$boolean',pasbool8type);
  372. addtype('$boolean16',pasbool16type);
  373. addtype('$boolean32',pasbool32type);
  374. addtype('$boolean64',pasbool64type);
  375. addtype('$bytebool',bool8type);
  376. addtype('$wordbool',bool16type);
  377. addtype('$longbool',bool32type);
  378. addtype('$qwordbool',bool64type);
  379. addtype('$void_pointer',voidpointertype);
  380. addtype('$char_pointer',charpointertype);
  381. addtype('$widechar_pointer',widecharpointertype);
  382. {$ifdef x86}
  383. addtype('$void_nearpointer',voidnearpointertype);
  384. addtype('$void_nearcspointer',voidnearcspointertype);
  385. addtype('$void_neardspointer',voidneardspointertype);
  386. addtype('$void_nearsspointer',voidnearsspointertype);
  387. addtype('$void_nearespointer',voidnearespointertype);
  388. addtype('$void_nearfspointer',voidnearfspointertype);
  389. addtype('$void_neargspointer',voidneargspointertype);
  390. {$ifdef i8086}
  391. addtype('$void_farpointer',voidfarpointertype);
  392. addtype('$void_hugepointer',voidhugepointertype);
  393. {$endif i8086}
  394. {$endif x86}
  395. addtype('$openchararray',openchararraytype);
  396. addtype('$file',cfiletype);
  397. addtype('$variant',cvarianttype);
  398. addtype('$olevariant',colevarianttype);
  399. if init_settings.fputype<>fpu_none then
  400. begin
  401. addtype('$s32real',s32floattype);
  402. addtype('$s64real',s64floattype);
  403. addtype('$s80real',s80floattype);
  404. addtype('$sc80real',sc80floattype);
  405. end;
  406. addtype('$s64currency',s64currencytype);
  407. if not(target_info.system in systems_managed_vm) then
  408. begin
  409. { Add a type for virtual method tables }
  410. hrecst:=trecordsymtable.create('',current_settings.packrecords);
  411. vmttype:=trecorddef.create('',hrecst);
  412. pvmttype:=tpointerdef.create(vmttype);
  413. { can't use addtype for pvmt because the rtti of the pointed
  414. type is not available. The rtti for pvmt will be written implicitly
  415. by thev tblarray below }
  416. systemunit.insert(ttypesym.create('$pvmt',pvmttype));
  417. addfield(hrecst,tfieldvarsym.create('$length',vs_value,ptrsinttype,[]));
  418. addfield(hrecst,tfieldvarsym.create('$mlength',vs_value,ptrsinttype,[]));
  419. addfield(hrecst,tfieldvarsym.create('$parent',vs_value,pvmttype,[]));
  420. { it seems vmttype is used both for TP objects and Delphi classes,
  421. so the next entry could either be the first virtual method (vm1)
  422. (object) or the class name (class). We can't easily create separate
  423. vtable formats for both, as gdb is hard coded to search for
  424. __vtbl_ptr_type in all cases (JM) }
  425. addfield(hrecst,tfieldvarsym.create('$vm1_or_classname',vs_value,tpointerdef.create(cshortstringtype),[]));
  426. vmtarraytype:=tarraydef.create(0,0,s32inttype);
  427. tarraydef(vmtarraytype).elementdef:=voidpointertype;
  428. addfield(hrecst,tfieldvarsym.create('$__pfn',vs_value,vmtarraytype,[]));
  429. addtype('$__vtbl_ptr_type',vmttype);
  430. vmtarraytype:=tarraydef.create(0,1,s32inttype);
  431. tarraydef(vmtarraytype).elementdef:=pvmttype;
  432. addtype('$vtblarray',vmtarraytype);
  433. { Add a type for methodpointers }
  434. hrecst:=trecordsymtable.create('',1);
  435. addfield(hrecst,tfieldvarsym.create('$proc',vs_value,voidpointertype,[]));
  436. addfield(hrecst,tfieldvarsym.create('$self',vs_value,voidpointertype,[]));
  437. methodpointertype:=trecorddef.create('',hrecst);
  438. addtype('$methodpointer',methodpointertype);
  439. end;
  440. symtablestack.pop(systemunit);
  441. end;
  442. procedure load_intern_types;
  443. {
  444. Load all default definitions for consts from the system unit
  445. }
  446. procedure loadtype(const s:string;var def:tdef);
  447. var
  448. srsym : ttypesym;
  449. begin
  450. srsym:=search_system_type(s);
  451. def:=srsym.typedef;
  452. end;
  453. var
  454. oldcurrentmodule : tmodule;
  455. begin
  456. {$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
  457. if target_info.system=system_x86_64_win64 then
  458. pbestrealtype:=@s64floattype;
  459. {$endif FPC_SUPPORT_X87_TYPES_ON_WIN64}
  460. oldcurrentmodule:=current_module;
  461. set_current_module(nil);
  462. loadtype('byte',u8inttype);
  463. loadtype('shortint',s8inttype);
  464. loadtype('word',u16inttype);
  465. loadtype('smallint',s16inttype);
  466. loadtype('ulong',u32inttype);
  467. loadtype('longint',s32inttype);
  468. loadtype('qword',u64inttype);
  469. loadtype('int64',s64inttype);
  470. loadtype('undefined',cundefinedtype);
  471. loadtype('formal',cformaltype);
  472. loadtype('typedformal',ctypedformaltype);
  473. loadtype('void',voidtype);
  474. loadtype('char',cansichartype);
  475. loadtype('widechar',cwidechartype);
  476. loadtype('shortstring',cshortstringtype);
  477. loadtype('longstring',clongstringtype);
  478. loadtype('ansistring',cansistringtype);
  479. loadtype('widestring',cwidestringtype);
  480. loadtype('unicodestring',cunicodestringtype);
  481. loadtype('openshortstring',openshortstringtype);
  482. loadtype('openchararray',openchararraytype);
  483. if init_settings.fputype <> fpu_none then
  484. begin
  485. loadtype('s32real',s32floattype);
  486. loadtype('s64real',s64floattype);
  487. loadtype('s80real',s80floattype);
  488. loadtype('sc80real',sc80floattype);
  489. end;
  490. loadtype('s64currency',s64currencytype);
  491. loadtype('boolean',pasbool8type);
  492. loadtype('boolean16',pasbool16type);
  493. loadtype('boolean32',pasbool32type);
  494. loadtype('boolean64',pasbool64type);
  495. loadtype('bytebool',bool8type);
  496. loadtype('wordbool',bool16type);
  497. loadtype('longbool',bool32type);
  498. loadtype('qwordbool',bool64type);
  499. loadtype('void_pointer',voidpointertype);
  500. loadtype('char_pointer',charpointertype);
  501. loadtype('widechar_pointer',widecharpointertype);
  502. {$ifdef x86}
  503. loadtype('void_nearpointer',voidnearpointertype);
  504. loadtype('void_nearcspointer',voidnearcspointertype);
  505. loadtype('void_neardspointer',voidneardspointertype);
  506. loadtype('void_nearsspointer',voidnearsspointertype);
  507. loadtype('void_nearespointer',voidnearespointertype);
  508. loadtype('void_nearfspointer',voidnearfspointertype);
  509. loadtype('void_neargspointer',voidneargspointertype);
  510. {$ifdef i8086}
  511. loadtype('void_farpointer',voidfarpointertype);
  512. loadtype('void_hugepointer',voidhugepointertype);
  513. {$endif i8086}
  514. {$endif x86}
  515. loadtype('file',cfiletype);
  516. if not(target_info.system in systems_managed_vm) then
  517. begin
  518. loadtype('pvmt',pvmttype);
  519. loadtype('vtblarray',vmtarraytype);
  520. loadtype('__vtbl_ptr_type',vmttype);
  521. end;
  522. loadtype('variant',cvarianttype);
  523. loadtype('olevariant',colevarianttype);
  524. if not(target_info.system in systems_managed_vm) then
  525. loadtype('methodpointer',methodpointertype);
  526. loadtype('HRESULT',hresultdef);
  527. set_default_int_types;
  528. set_current_module(oldcurrentmodule);
  529. end;
  530. procedure registernodes;
  531. {
  532. Register all possible nodes in the nodeclass array that
  533. will be used for loading the nodes from a ppu
  534. }
  535. begin
  536. nodeclass[addn]:=caddnode;
  537. nodeclass[muln]:=caddnode;
  538. nodeclass[subn]:=caddnode;
  539. nodeclass[divn]:=cmoddivnode;
  540. nodeclass[symdifn]:=caddnode;
  541. nodeclass[modn]:=cmoddivnode;
  542. nodeclass[assignn]:=cassignmentnode;
  543. nodeclass[loadn]:=cloadnode;
  544. nodeclass[rangen]:=crangenode;
  545. nodeclass[ltn]:=caddnode;
  546. nodeclass[lten]:=caddnode;
  547. nodeclass[gtn]:=caddnode;
  548. nodeclass[gten]:=caddnode;
  549. nodeclass[equaln]:=caddnode;
  550. nodeclass[unequaln]:=caddnode;
  551. nodeclass[inn]:=cinnode;
  552. nodeclass[orn]:=caddnode;
  553. nodeclass[xorn]:=caddnode;
  554. nodeclass[shrn]:=cshlshrnode;
  555. nodeclass[shln]:=cshlshrnode;
  556. nodeclass[slashn]:=caddnode;
  557. nodeclass[andn]:=caddnode;
  558. nodeclass[subscriptn]:=csubscriptnode;
  559. nodeclass[derefn]:=cderefnode;
  560. nodeclass[addrn]:=caddrnode;
  561. nodeclass[ordconstn]:=cordconstnode;
  562. nodeclass[typeconvn]:=ctypeconvnode;
  563. nodeclass[calln]:=ccallnode;
  564. nodeclass[callparan]:=ccallparanode;
  565. nodeclass[realconstn]:=crealconstnode;
  566. nodeclass[unaryminusn]:=cunaryminusnode;
  567. nodeclass[unaryplusn]:=cunaryplusnode;
  568. nodeclass[asmn]:=casmnode;
  569. nodeclass[vecn]:=cvecnode;
  570. nodeclass[pointerconstn]:=cpointerconstnode;
  571. nodeclass[stringconstn]:=cstringconstnode;
  572. nodeclass[notn]:=cnotnode;
  573. nodeclass[inlinen]:=cinlinenode;
  574. nodeclass[niln]:=cnilnode;
  575. nodeclass[errorn]:=cerrornode;
  576. nodeclass[typen]:=ctypenode;
  577. nodeclass[setelementn]:=csetelementnode;
  578. nodeclass[setconstn]:=csetconstnode;
  579. nodeclass[blockn]:=cblocknode;
  580. nodeclass[statementn]:=cstatementnode;
  581. nodeclass[ifn]:=cifnode;
  582. nodeclass[breakn]:=cbreaknode;
  583. nodeclass[continuen]:=ccontinuenode;
  584. nodeclass[whilerepeatn]:=cwhilerepeatnode;
  585. nodeclass[forn]:=cfornode;
  586. nodeclass[exitn]:=cexitnode;
  587. nodeclass[withn]:=cwithnode;
  588. nodeclass[casen]:=ccasenode;
  589. nodeclass[labeln]:=clabelnode;
  590. nodeclass[goton]:=cgotonode;
  591. nodeclass[tryexceptn]:=ctryexceptnode;
  592. nodeclass[raisen]:=craisenode;
  593. nodeclass[tryfinallyn]:=ctryfinallynode;
  594. nodeclass[onn]:=connode;
  595. nodeclass[isn]:=cisnode;
  596. nodeclass[asn]:=casnode;
  597. nodeclass[starstarn]:=caddnode;
  598. nodeclass[arrayconstructorn]:=carrayconstructornode;
  599. nodeclass[arrayconstructorrangen]:=carrayconstructorrangenode;
  600. nodeclass[tempcreaten]:=ctempcreatenode;
  601. nodeclass[temprefn]:=ctemprefnode;
  602. nodeclass[tempdeleten]:=ctempdeletenode;
  603. nodeclass[addoptn]:=caddnode;
  604. nodeclass[nothingn]:=cnothingnode;
  605. nodeclass[loadvmtaddrn]:=cloadvmtaddrnode;
  606. nodeclass[guidconstn]:=cguidconstnode;
  607. nodeclass[rttin]:=crttinode;
  608. nodeclass[loadparentfpn]:=cloadparentfpnode;
  609. end;
  610. procedure registertais;
  611. {
  612. Register all possible tais in the taiclass array that
  613. will be used for loading the tais from a ppu
  614. }
  615. begin
  616. aiclass[ait_none]:=nil;
  617. aiclass[ait_align]:=tai_align;
  618. aiclass[ait_section]:=tai_section;
  619. aiclass[ait_comment]:=tai_comment;
  620. aiclass[ait_string]:=tai_string;
  621. aiclass[ait_instruction]:=taicpu;
  622. aiclass[ait_datablock]:=tai_datablock;
  623. aiclass[ait_symbol]:=tai_symbol;
  624. aiclass[ait_symbol_end]:=tai_symbol_end;
  625. aiclass[ait_directive]:=tai_directive;
  626. aiclass[ait_label]:=tai_label;
  627. aiclass[ait_const]:=tai_const;
  628. aiclass[ait_real_32bit]:=tai_real_32bit;
  629. aiclass[ait_real_64bit]:=tai_real_64bit;
  630. aiclass[ait_real_80bit]:=tai_real_80bit;
  631. aiclass[ait_comp_64bit]:=tai_comp_64bit;
  632. aiclass[ait_stab]:=tai_stab;
  633. aiclass[ait_force_line]:=tai_force_line;
  634. aiclass[ait_function_name]:=tai_function_name;
  635. aiclass[ait_ent]:=tai_ent;
  636. aiclass[ait_ent_end]:=tai_ent_end;
  637. {$ifdef alpha}
  638. { the follow is for the DEC Alpha }
  639. aiclass[ait_frame]:=tai_frame;
  640. {$endif alpha}
  641. {$ifdef m68k}
  642. { TODO: FIXME: tai_labeled_instruction doesn't exists}
  643. // aiclass[ait_labeled_instruction]:=tai_labeled_instruction;
  644. {$endif m68k}
  645. {$ifdef ia64}
  646. aiclass[ait_bundle]:=tai_bundle;
  647. aiclass[ait_stop]:=tai_stop;
  648. {$endif ia64}
  649. {$ifdef SPARC}
  650. // aiclass[ait_labeled_instruction]:=tai_labeled_instruction;
  651. {$endif SPARC}
  652. {$ifdef arm}
  653. aiclass[ait_thumb_func]:=tai_thumb_func;
  654. aiclass[ait_thumb_set]:=tai_thumb_set;
  655. {$endif arm}
  656. aiclass[ait_set]:=tai_set;
  657. aiclass[ait_weak]:=tai_weak;
  658. aiclass[ait_cutobject]:=tai_cutobject;
  659. aiclass[ait_regalloc]:=tai_regalloc;
  660. aiclass[ait_tempalloc]:=tai_tempalloc;
  661. aiclass[ait_marker]:=tai_marker;
  662. aiclass[ait_seh_directive]:=tai_seh_directive;
  663. {$ifdef JVM}
  664. aiclass[ait_jvar]:=tai_jvar;
  665. aiclass[ait_jcatch]:=tai_jcatch;
  666. {$endif JVM}
  667. end;
  668. end.