psystem.pas 25 KB

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