psystem.pas 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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)}
  84. systemunit.insert(tsyssym.create('Get_Frame',in_get_frame));
  85. {$endif defined(x86) or defined(arm)}
  86. systemunit.insert(tsyssym.create('Unaligned',in_unaligned_x));
  87. systemunit.insert(tsyssym.create('ObjCSelector',in_objc_selector_x)); { objc only }
  88. systemunit.insert(tsyssym.create('ObjCEncode',in_objc_encode_x)); { objc only }
  89. end;
  90. procedure create_intern_types;
  91. {
  92. all the types inserted into the system unit
  93. }
  94. function addtype(const s:string;def:tdef):ttypesym;
  95. begin
  96. result:=ttypesym.create(s,def);
  97. systemunit.insert(result);
  98. end;
  99. procedure addfield(recst:tabstractrecordsymtable;sym:tfieldvarsym);
  100. begin
  101. recst.insert(sym);
  102. recst.addfield(sym,vis_hidden);
  103. end;
  104. procedure create_fpu_types;
  105. begin
  106. if init_settings.fputype<>fpu_none then
  107. begin
  108. s32floattype:=tfloatdef.create(s32real);
  109. s64floattype:=tfloatdef.create(s64real);
  110. s80floattype:=tfloatdef.create(s80real);
  111. sc80floattype:=tfloatdef.create(sc80real);
  112. end else begin
  113. s32floattype:=nil;
  114. s64floattype:=nil;
  115. s80floattype:=nil;
  116. sc80floattype:=nil;
  117. end;
  118. end;
  119. var
  120. hrecst : trecordsymtable;
  121. begin
  122. symtablestack.push(systemunit);
  123. cundefinedtype:=tundefineddef.create;
  124. cformaltype:=tformaldef.create(false);
  125. ctypedformaltype:=tformaldef.create(true);
  126. voidtype:=torddef.create(uvoid,0,0);
  127. u8inttype:=torddef.create(u8bit,0,255);
  128. s8inttype:=torddef.create(s8bit,int64(-128),127);
  129. u16inttype:=torddef.create(u16bit,0,65535);
  130. s16inttype:=torddef.create(s16bit,int64(-32768),32767);
  131. u32inttype:=torddef.create(u32bit,0,high(longword));
  132. s32inttype:=torddef.create(s32bit,int64(low(longint)),int64(high(longint)));
  133. u64inttype:=torddef.create(u64bit,low(qword),high(qword));
  134. s64inttype:=torddef.create(s64bit,low(int64),high(int64));
  135. pasbool8type:=torddef.create(pasbool8,0,1);
  136. pasbool16type:=torddef.create(pasbool16,0,1);
  137. pasbool32type:=torddef.create(pasbool32,0,1);
  138. pasbool64type:=torddef.create(pasbool64,0,1);
  139. bool8type:=torddef.create(bool8bit,low(int64),high(int64));
  140. bool16type:=torddef.create(bool16bit,low(int64),high(int64));
  141. bool32type:=torddef.create(bool32bit,low(int64),high(int64));
  142. bool64type:=torddef.create(bool64bit,low(int64),high(int64));
  143. cchartype:=torddef.create(uchar,0,255);
  144. cwidechartype:=torddef.create(uwidechar,0,65535);
  145. cshortstringtype:=tstringdef.createshort(255);
  146. { should we give a length to the default long and ansi string definition ?? }
  147. clongstringtype:=tstringdef.createlong(-1);
  148. cansistringtype:=tstringdef.createansi;
  149. if target_info.system in systems_windows then
  150. cwidestringtype:=tstringdef.createwide
  151. else
  152. cwidestringtype:=tstringdef.createunicode;
  153. cunicodestringtype:=tstringdef.createunicode;
  154. { length=0 for shortstring is open string (needed for readln(string) }
  155. openshortstringtype:=tstringdef.createshort(0);
  156. openchararraytype:=tarraydef.create(0,-1,s32inttype);
  157. tarraydef(openchararraytype).elementdef:=cchartype;
  158. {$ifdef x86}
  159. create_fpu_types;
  160. if target_info.system<>system_x86_64_win64 then
  161. s64currencytype:=tfloatdef.create(s64currency)
  162. else
  163. begin
  164. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  165. pbestrealtype:=@s64floattype;
  166. end;
  167. {$endif x86}
  168. {$ifdef powerpc}
  169. create_fpu_types;
  170. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  171. {$endif powerpc}
  172. {$ifdef POWERPC64}
  173. create_fpu_types;
  174. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  175. {$endif POWERPC64}
  176. {$ifdef sparc}
  177. create_fpu_types;
  178. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  179. {$endif sparc}
  180. {$ifdef m68k}
  181. create_fpu_types;
  182. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  183. {$endif}
  184. {$ifdef arm}
  185. create_fpu_types;
  186. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  187. {$endif arm}
  188. {$ifdef avr}
  189. s32floattype:=tfloatdef.create(s32real);
  190. s64floattype:=tfloatdef.create(s64real);
  191. s80floattype:=tfloatdef.create(s80real);
  192. sc80floattype:=tfloatdef.create(sc80real);
  193. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  194. {$endif avr}
  195. {$ifdef jvm}
  196. create_fpu_types;
  197. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  198. {$endif POWERPC64}
  199. {$ifdef cpu64bitaddr}
  200. uinttype:=u64inttype;
  201. sinttype:=s64inttype;
  202. ptruinttype:=u64inttype;
  203. ptrsinttype:=s64inttype;
  204. {$endif cpu64bitaddr}
  205. {$ifdef cpu32bitaddr}
  206. uinttype:=u32inttype;
  207. sinttype:=s32inttype;
  208. ptruinttype:=u32inttype;
  209. ptrsinttype:=s32inttype;
  210. {$endif cpu32bitaddr}
  211. {$ifdef cpu32bitalu}
  212. uinttype:=u32inttype;
  213. sinttype:=s32inttype;
  214. {$endif cpu32bitalu}
  215. {$ifdef cpu16bitaddr}
  216. ptruinttype:=u16inttype;
  217. ptrsinttype:=s16inttype;
  218. {$endif cpu16bitaddr}
  219. {$ifdef cpu16bitalu}
  220. uinttype:=u16inttype;
  221. sinttype:=s16inttype;
  222. {$endif cpu16bitalu}
  223. {$ifdef cpu8bitalu}
  224. uinttype:=u8inttype;
  225. sinttype:=s8inttype;
  226. {$endif cpu8bitalu}
  227. { some other definitions }
  228. voidpointertype:=tpointerdef.create(voidtype);
  229. charpointertype:=tpointerdef.create(cchartype);
  230. widecharpointertype:=tpointerdef.create(cwidechartype);
  231. voidfarpointertype:=tpointerdef.createfar(voidtype);
  232. cfiletype:=tfiledef.createuntyped;
  233. cvarianttype:=tvariantdef.create(vt_normalvariant);
  234. colevarianttype:=tvariantdef.create(vt_olevariant);
  235. {$ifdef cpufpemu}
  236. { Normal types }
  237. (* we use the same types as without emulator, the only
  238. difference is that direct calls to the emulator are generated
  239. if (cs_fp_emulation in current_settings.moduleswitches) then
  240. begin
  241. addtype('Single',s32floattype);
  242. { extended size is the best real type for the target }
  243. addtype('Real',s32floattype);
  244. pbestrealtype:=@s32floattype;
  245. { extended size is the best real type for the target }
  246. addtype('Extended',pbestrealtype^);
  247. end
  248. else
  249. *)
  250. {$endif cpufpemu}
  251. if init_settings.fputype <> fpu_none then
  252. begin
  253. addtype('Single',s32floattype);
  254. addtype('Double',s64floattype);
  255. { extended size is the best real type for the target }
  256. addtype('Extended',pbestrealtype^);
  257. { CExtended corresponds to the C version of the Extended type
  258. (either "long double" or "double") }
  259. if tfloatdef(pbestrealtype^).floattype=s80real then
  260. addtype('CExtended',sc80floattype)
  261. else
  262. addtype('CExtended',pbestrealtype^);
  263. end;
  264. {$ifdef x86}
  265. if target_info.system<>system_x86_64_win64 then
  266. addtype('Comp',tfloatdef.create(s64comp));
  267. {$endif x86}
  268. addtype('Currency',s64currencytype);
  269. addtype('Pointer',voidpointertype);
  270. {$ifdef x86}
  271. addtype('FarPointer',voidfarpointertype);
  272. {$endif x86}
  273. addtype('ShortString',cshortstringtype);
  274. {$ifdef support_longstring}
  275. addtype('LongString',clongstringtype);
  276. {$endif support_longstring}
  277. addtype('AnsiString',cansistringtype);
  278. addtype('WideString',cwidestringtype);
  279. addtype('UnicodeString',cunicodestringtype);
  280. addtype('OpenString',openshortstringtype);
  281. addtype('Boolean',pasbool8type);
  282. addtype('Boolean16',pasbool16type);
  283. addtype('Boolean32',pasbool32type);
  284. addtype('Boolean64',pasbool64type);
  285. addtype('ByteBool',bool8type);
  286. addtype('WordBool',bool16type);
  287. addtype('LongBool',bool32type);
  288. addtype('QWordBool',bool64type);
  289. addtype('Byte',u8inttype);
  290. addtype('ShortInt',s8inttype);
  291. addtype('Word',u16inttype);
  292. addtype('SmallInt',s16inttype);
  293. addtype('LongWord',u32inttype);
  294. addtype('LongInt',s32inttype);
  295. addtype('QWord',u64inttype);
  296. addtype('Int64',s64inttype);
  297. addtype('Char',cchartype);
  298. addtype('WideChar',cwidechartype);
  299. addtype('Text',tfiledef.createtext);
  300. addtype('TypedFile',tfiledef.createtyped(voidtype));
  301. addtype('Variant',cvarianttype);
  302. addtype('OleVariant',colevarianttype);
  303. { Internal types }
  304. addtype('$undefined',cundefinedtype);
  305. addtype('$formal',cformaltype);
  306. addtype('$typedformal',ctypedformaltype);
  307. addtype('$void',voidtype);
  308. addtype('$byte',u8inttype);
  309. addtype('$shortint',s8inttype);
  310. addtype('$word',u16inttype);
  311. addtype('$smallint',s16inttype);
  312. addtype('$ulong',u32inttype);
  313. addtype('$longint',s32inttype);
  314. addtype('$qword',u64inttype);
  315. addtype('$int64',s64inttype);
  316. addtype('$char',cchartype);
  317. addtype('$widechar',cwidechartype);
  318. addtype('$shortstring',cshortstringtype);
  319. addtype('$longstring',clongstringtype);
  320. addtype('$ansistring',cansistringtype);
  321. addtype('$widestring',cwidestringtype);
  322. addtype('$unicodestring',cunicodestringtype);
  323. addtype('$openshortstring',openshortstringtype);
  324. addtype('$boolean',pasbool8type);
  325. addtype('$boolean16',pasbool16type);
  326. addtype('$boolean32',pasbool32type);
  327. addtype('$boolean64',pasbool64type);
  328. addtype('$bytebool',bool8type);
  329. addtype('$wordbool',bool16type);
  330. addtype('$longbool',bool32type);
  331. addtype('$qwordbool',bool64type);
  332. addtype('$void_pointer',voidpointertype);
  333. addtype('$char_pointer',charpointertype);
  334. addtype('$widechar_pointer',widecharpointertype);
  335. addtype('$void_farpointer',voidfarpointertype);
  336. addtype('$openchararray',openchararraytype);
  337. addtype('$file',cfiletype);
  338. addtype('$variant',cvarianttype);
  339. addtype('$olevariant',cvarianttype);
  340. if init_settings.fputype<>fpu_none then
  341. begin
  342. addtype('$s32real',s32floattype);
  343. addtype('$s64real',s64floattype);
  344. addtype('$s80real',s80floattype);
  345. addtype('$sc80real',sc80floattype);
  346. end;
  347. addtype('$s64currency',s64currencytype);
  348. if not(target_info.system in systems_managed_vm) then
  349. begin
  350. { Add a type for virtual method tables }
  351. hrecst:=trecordsymtable.create('',current_settings.packrecords);
  352. vmttype:=trecorddef.create('',hrecst);
  353. pvmttype:=tpointerdef.create(vmttype);
  354. { can't use addtype for pvmt because the rtti of the pointed
  355. type is not available. The rtti for pvmt will be written implicitly
  356. by thev tblarray below }
  357. systemunit.insert(ttypesym.create('$pvmt',pvmttype));
  358. addfield(hrecst,tfieldvarsym.create('$length',vs_value,ptrsinttype,[]));
  359. addfield(hrecst,tfieldvarsym.create('$mlength',vs_value,ptrsinttype,[]));
  360. addfield(hrecst,tfieldvarsym.create('$parent',vs_value,pvmttype,[]));
  361. { it seems vmttype is used both for TP objects and Delphi classes,
  362. so the next entry could either be the first virtual method (vm1)
  363. (object) or the class name (class). We can't easily create separate
  364. vtable formats for both, as gdb is hard coded to search for
  365. __vtbl_ptr_type in all cases (JM) }
  366. addfield(hrecst,tfieldvarsym.create('$vm1_or_classname',vs_value,tpointerdef.create(cshortstringtype),[]));
  367. vmtarraytype:=tarraydef.create(0,0,s32inttype);
  368. tarraydef(vmtarraytype).elementdef:=voidpointertype;
  369. addfield(hrecst,tfieldvarsym.create('$__pfn',vs_value,vmtarraytype,[]));
  370. addtype('$__vtbl_ptr_type',vmttype);
  371. vmtarraytype:=tarraydef.create(0,1,s32inttype);
  372. tarraydef(vmtarraytype).elementdef:=pvmttype;
  373. addtype('$vtblarray',vmtarraytype);
  374. { Add a type for methodpointers }
  375. hrecst:=trecordsymtable.create('',1);
  376. addfield(hrecst,tfieldvarsym.create('$proc',vs_value,voidpointertype,[]));
  377. addfield(hrecst,tfieldvarsym.create('$self',vs_value,voidpointertype,[]));
  378. methodpointertype:=trecorddef.create('',hrecst);
  379. addtype('$methodpointer',methodpointertype);
  380. end;
  381. symtablestack.pop(systemunit);
  382. end;
  383. procedure load_intern_types;
  384. {
  385. Load all default definitions for consts from the system unit
  386. }
  387. procedure loadtype(const s:string;var def:tdef);
  388. var
  389. srsym : ttypesym;
  390. begin
  391. srsym:=search_system_type(s);
  392. def:=srsym.typedef;
  393. end;
  394. var
  395. oldcurrentmodule : tmodule;
  396. begin
  397. if target_info.system=system_x86_64_win64 then
  398. pbestrealtype:=@s64floattype;
  399. oldcurrentmodule:=current_module;
  400. set_current_module(nil);
  401. loadtype('byte',u8inttype);
  402. loadtype('shortint',s8inttype);
  403. loadtype('word',u16inttype);
  404. loadtype('smallint',s16inttype);
  405. loadtype('ulong',u32inttype);
  406. loadtype('longint',s32inttype);
  407. loadtype('qword',u64inttype);
  408. loadtype('int64',s64inttype);
  409. loadtype('undefined',cundefinedtype);
  410. loadtype('formal',cformaltype);
  411. loadtype('typedformal',ctypedformaltype);
  412. loadtype('void',voidtype);
  413. loadtype('char',cchartype);
  414. loadtype('widechar',cwidechartype);
  415. loadtype('shortstring',cshortstringtype);
  416. loadtype('longstring',clongstringtype);
  417. loadtype('ansistring',cansistringtype);
  418. loadtype('widestring',cwidestringtype);
  419. loadtype('unicodestring',cunicodestringtype);
  420. loadtype('openshortstring',openshortstringtype);
  421. loadtype('openchararray',openchararraytype);
  422. if init_settings.fputype <> fpu_none then
  423. begin
  424. loadtype('s32real',s32floattype);
  425. loadtype('s64real',s64floattype);
  426. loadtype('s80real',s80floattype);
  427. loadtype('sc80real',sc80floattype);
  428. end;
  429. loadtype('s64currency',s64currencytype);
  430. loadtype('boolean',pasbool8type);
  431. loadtype('boolean16',pasbool16type);
  432. loadtype('boolean32',pasbool32type);
  433. loadtype('boolean64',pasbool64type);
  434. loadtype('bytebool',bool8type);
  435. loadtype('wordbool',bool16type);
  436. loadtype('longbool',bool32type);
  437. loadtype('qwordbool',bool64type);
  438. loadtype('void_pointer',voidpointertype);
  439. loadtype('char_pointer',charpointertype);
  440. loadtype('widechar_pointer',widecharpointertype);
  441. loadtype('void_farpointer',voidfarpointertype);
  442. loadtype('file',cfiletype);
  443. if not(target_info.system in systems_managed_vm) then
  444. begin
  445. loadtype('pvmt',pvmttype);
  446. loadtype('vtblarray',vmtarraytype);
  447. loadtype('__vtbl_ptr_type',vmttype);
  448. end;
  449. loadtype('variant',cvarianttype);
  450. loadtype('olevariant',colevarianttype);
  451. if not(target_info.system in systems_managed_vm) then
  452. loadtype('methodpointer',methodpointertype);
  453. loadtype('HRESULT',hresultdef);
  454. {$ifdef cpu64bitaddr}
  455. uinttype:=u64inttype;
  456. sinttype:=s64inttype;
  457. ptruinttype:=u64inttype;
  458. ptrsinttype:=s64inttype;
  459. {$endif cpu64bitaddr}
  460. {$ifdef cpu32bit}
  461. uinttype:=u32inttype;
  462. sinttype:=s32inttype;
  463. ptruinttype:=u32inttype;
  464. ptrsinttype:=s32inttype;
  465. {$endif cpu32bit}
  466. {$ifdef cpu16bit}
  467. uinttype:=u16inttype;
  468. sinttype:=s16inttype;
  469. ptruinttype:=u16inttype;
  470. ptrsinttype:=s16inttype;
  471. {$endif cpu16bit}
  472. set_current_module(oldcurrentmodule);
  473. end;
  474. procedure registernodes;
  475. {
  476. Register all possible nodes in the nodeclass array that
  477. will be used for loading the nodes from a ppu
  478. }
  479. begin
  480. nodeclass[addn]:=caddnode;
  481. nodeclass[muln]:=caddnode;
  482. nodeclass[subn]:=caddnode;
  483. nodeclass[divn]:=cmoddivnode;
  484. nodeclass[symdifn]:=caddnode;
  485. nodeclass[modn]:=cmoddivnode;
  486. nodeclass[assignn]:=cassignmentnode;
  487. nodeclass[loadn]:=cloadnode;
  488. nodeclass[rangen]:=crangenode;
  489. nodeclass[ltn]:=caddnode;
  490. nodeclass[lten]:=caddnode;
  491. nodeclass[gtn]:=caddnode;
  492. nodeclass[gten]:=caddnode;
  493. nodeclass[equaln]:=caddnode;
  494. nodeclass[unequaln]:=caddnode;
  495. nodeclass[inn]:=cinnode;
  496. nodeclass[orn]:=caddnode;
  497. nodeclass[xorn]:=caddnode;
  498. nodeclass[shrn]:=cshlshrnode;
  499. nodeclass[shln]:=cshlshrnode;
  500. nodeclass[slashn]:=caddnode;
  501. nodeclass[andn]:=caddnode;
  502. nodeclass[subscriptn]:=csubscriptnode;
  503. nodeclass[derefn]:=cderefnode;
  504. nodeclass[addrn]:=caddrnode;
  505. nodeclass[ordconstn]:=cordconstnode;
  506. nodeclass[typeconvn]:=ctypeconvnode;
  507. nodeclass[calln]:=ccallnode;
  508. nodeclass[callparan]:=ccallparanode;
  509. nodeclass[realconstn]:=crealconstnode;
  510. nodeclass[unaryminusn]:=cunaryminusnode;
  511. nodeclass[unaryplusn]:=cunaryplusnode;
  512. nodeclass[asmn]:=casmnode;
  513. nodeclass[vecn]:=cvecnode;
  514. nodeclass[pointerconstn]:=cpointerconstnode;
  515. nodeclass[stringconstn]:=cstringconstnode;
  516. nodeclass[notn]:=cnotnode;
  517. nodeclass[inlinen]:=cinlinenode;
  518. nodeclass[niln]:=cnilnode;
  519. nodeclass[errorn]:=cerrornode;
  520. nodeclass[typen]:=ctypenode;
  521. nodeclass[setelementn]:=csetelementnode;
  522. nodeclass[setconstn]:=csetconstnode;
  523. nodeclass[blockn]:=cblocknode;
  524. nodeclass[statementn]:=cstatementnode;
  525. nodeclass[ifn]:=cifnode;
  526. nodeclass[breakn]:=cbreaknode;
  527. nodeclass[continuen]:=ccontinuenode;
  528. nodeclass[whilerepeatn]:=cwhilerepeatnode;
  529. nodeclass[forn]:=cfornode;
  530. nodeclass[exitn]:=cexitnode;
  531. nodeclass[withn]:=cwithnode;
  532. nodeclass[casen]:=ccasenode;
  533. nodeclass[labeln]:=clabelnode;
  534. nodeclass[goton]:=cgotonode;
  535. nodeclass[tryexceptn]:=ctryexceptnode;
  536. nodeclass[raisen]:=craisenode;
  537. nodeclass[tryfinallyn]:=ctryfinallynode;
  538. nodeclass[onn]:=connode;
  539. nodeclass[isn]:=cisnode;
  540. nodeclass[asn]:=casnode;
  541. nodeclass[starstarn]:=caddnode;
  542. nodeclass[arrayconstructorn]:=carrayconstructornode;
  543. nodeclass[arrayconstructorrangen]:=carrayconstructorrangenode;
  544. nodeclass[tempcreaten]:=ctempcreatenode;
  545. nodeclass[temprefn]:=ctemprefnode;
  546. nodeclass[tempdeleten]:=ctempdeletenode;
  547. nodeclass[addoptn]:=caddnode;
  548. nodeclass[nothingn]:=cnothingnode;
  549. nodeclass[loadvmtaddrn]:=cloadvmtaddrnode;
  550. nodeclass[guidconstn]:=cguidconstnode;
  551. nodeclass[rttin]:=crttinode;
  552. nodeclass[loadparentfpn]:=cloadparentfpnode;
  553. end;
  554. procedure registertais;
  555. {
  556. Register all possible tais in the taiclass array that
  557. will be used for loading the tais from a ppu
  558. }
  559. begin
  560. aiclass[ait_none]:=nil;
  561. aiclass[ait_align]:=tai_align;
  562. aiclass[ait_section]:=tai_section;
  563. aiclass[ait_comment]:=tai_comment;
  564. aiclass[ait_string]:=tai_string;
  565. aiclass[ait_instruction]:=taicpu;
  566. aiclass[ait_datablock]:=tai_datablock;
  567. aiclass[ait_symbol]:=tai_symbol;
  568. aiclass[ait_symbol_end]:=tai_symbol_end;
  569. aiclass[ait_directive]:=tai_directive;
  570. aiclass[ait_label]:=tai_label;
  571. aiclass[ait_const]:=tai_const;
  572. aiclass[ait_real_32bit]:=tai_real_32bit;
  573. aiclass[ait_real_64bit]:=tai_real_64bit;
  574. aiclass[ait_real_80bit]:=tai_real_80bit;
  575. aiclass[ait_comp_64bit]:=tai_comp_64bit;
  576. aiclass[ait_stab]:=tai_stab;
  577. aiclass[ait_force_line]:=tai_force_line;
  578. aiclass[ait_function_name]:=tai_function_name;
  579. {$ifdef alpha}
  580. { the follow is for the DEC Alpha }
  581. aiclass[ait_frame]:=tai_frame;
  582. aiclass[ait_ent]:=tai_ent;
  583. {$endif alpha}
  584. {$ifdef m68k}
  585. { TODO: FIXME: tai_labeled_instruction doesn't exists}
  586. // aiclass[ait_labeled_instruction]:=tai_labeled_instruction;
  587. {$endif m68k}
  588. {$ifdef ia64}
  589. aiclass[ait_bundle]:=tai_bundle;
  590. aiclass[ait_stop]:=tai_stop;
  591. {$endif ia64}
  592. {$ifdef SPARC}
  593. // aiclass[ait_labeled_instruction]:=tai_labeled_instruction;
  594. {$endif SPARC}
  595. {$ifdef arm}
  596. aiclass[ait_thumb_func]:=tai_thumb_func;
  597. {$endif arm}
  598. aiclass[ait_cutobject]:=tai_cutobject;
  599. aiclass[ait_regalloc]:=tai_regalloc;
  600. aiclass[ait_tempalloc]:=tai_tempalloc;
  601. aiclass[ait_marker]:=tai_marker;
  602. aiclass[ait_jvar]:=tai_jvar;
  603. aiclass[ait_jcatch]:=tai_jcatch;
  604. end;
  605. end.