globtype.pas 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
  3. Global types
  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 globtype;
  18. {$i fpcdefs.inc}
  19. interface
  20. const
  21. maxidlen = 127;
  22. type
  23. { TCmdStr is used to pass command line parameters to an external program to be
  24. executed from the FPC application. In some circomstances, this can be more
  25. than 255 characters. That's why using Ansi Strings}
  26. TCmdStr = AnsiString;
  27. TPathStr = String;
  28. { Integer type corresponding to pointer size }
  29. {$ifdef cpu64bitaddr}
  30. PUint = qword;
  31. PInt = int64;
  32. {$else cpu64bitaddr}
  33. PUint = cardinal;
  34. PInt = longint;
  35. {$endif cpu64bitaddr}
  36. { Natural integer register type and size for the target machine }
  37. {$ifdef cpu64bitalu}
  38. AWord = qword;
  39. AInt = Int64;
  40. Const
  41. AIntBits = 64;
  42. {$else cpu64bitalu}
  43. AWord = longword;
  44. AInt = longint;
  45. Const
  46. AIntBits = 32;
  47. {$endif cpu64bitalu}
  48. Type
  49. PAWord = ^AWord;
  50. PAInt = ^AInt;
  51. { This must be an ordinal type with the same size as a pointer
  52. Note: Must be unsigned! Otherwise, ugly code like
  53. pointer(-1) will result in a pointer with the value
  54. $fffffffffffffff on a 32bit machine if the compiler uses
  55. int64 constants internally (JM) }
  56. TConstPtrUInt = AWord;
  57. { Use a variant record to be sure that the array if aligned correctly }
  58. tdoublerec=record
  59. case byte of
  60. 0 : (bytes:array[0..7] of byte);
  61. 1 : (value:double);
  62. end;
  63. textendedrec=record
  64. case byte of
  65. 0 : (bytes:array[0..9] of byte);
  66. 1 : (value:extended);
  67. end;
  68. pconstset = ^tconstset;
  69. tconstset = set of 0..255;
  70. { Switches which can be changed locally }
  71. tlocalswitch = (cs_localnone,
  72. { codegen }
  73. cs_check_overflow,cs_check_range,cs_check_object,
  74. cs_check_io,cs_check_stack,
  75. cs_checkpointer,cs_check_ordinal_size,
  76. cs_generate_stackframes,cs_do_assertion,cs_generate_rtti,
  77. cs_full_boolean_eval,cs_typed_const_writable,cs_allow_enum_calc,
  78. cs_do_inline,cs_fpu_fwait,
  79. { mmx }
  80. cs_mmx,cs_mmx_saturation,
  81. { parser }
  82. cs_typed_addresses,cs_strict_var_strings,cs_ansistrings,cs_bitpacking,
  83. { macpas specific}
  84. cs_external_var, cs_externally_visible
  85. );
  86. tlocalswitches = set of tlocalswitch;
  87. { Switches which can be changed only at the beginning of a new module }
  88. tmoduleswitch = (cs_modulenone,
  89. { parser }
  90. cs_fp_emulation,cs_extsyntax,cs_openstring,
  91. { support }
  92. cs_support_goto,cs_support_macro,
  93. cs_support_c_operators,cs_static_keyword,
  94. { generation }
  95. cs_profile,cs_debuginfo,cs_compilesystem,
  96. cs_lineinfo,cs_implicit_exceptions,
  97. { linking }
  98. cs_create_smart,cs_create_dynamic,cs_create_pic,
  99. { browser switches are back }
  100. cs_browser,cs_local_browser
  101. );
  102. tmoduleswitches = set of tmoduleswitch;
  103. { Switches which can be changed only for a whole program/compilation,
  104. mostly set with commandline }
  105. tglobalswitch = (cs_globalnone,
  106. { parameter switches }
  107. cs_check_unit_name,cs_constructor_name,cs_support_exceptions,
  108. { units }
  109. cs_load_objpas_unit,
  110. cs_load_gpc_unit,
  111. cs_load_fpcylix_unit,
  112. cs_support_vectors,
  113. { debuginfo }
  114. cs_use_heaptrc,cs_use_lineinfo,
  115. cs_gdb_valgrind,cs_no_regalloc,cs_stabs_preservecase,
  116. { assembling }
  117. cs_asm_leave,cs_asm_extern,cs_asm_pipe,cs_asm_source,
  118. cs_asm_regalloc,cs_asm_tempalloc,cs_asm_nodes,
  119. { linking }
  120. cs_link_nolink,cs_link_static,cs_link_smart,cs_link_shared,cs_link_deffile,
  121. cs_link_strip,cs_link_staticflag,cs_link_on_target,cs_link_extern,cs_link_opt_vtable,
  122. cs_link_opt_used_sections,cs_link_separate_dbg_file,
  123. cs_link_map,cs_link_pthread,cs_link_no_default_lib_order
  124. );
  125. tglobalswitches = set of tglobalswitch;
  126. { global switches specific to debug information }
  127. tdebugswitch = (ds_none,
  128. { enable set support in dwarf debug info, breaks gdb versions }
  129. { without support for that tag (they refuse to parse the rest }
  130. { of the debug information) }
  131. ds_dwarf_sets
  132. );
  133. tdebugswitches = set of tdebugswitch;
  134. { adding a new entry here requires also adding the appropriate define in
  135. systemh.inc (FK)
  136. }
  137. tfeature = (
  138. f_heap,f_init_final,f_rtti,f_classes,f_exceptions,f_exitcode,
  139. f_ansistrings,f_widestrings,f_textio,f_consoleio,f_fileio,
  140. f_random,f_variants,f_objects,f_dynarrays,f_threading,f_commandargs,
  141. f_processes,f_stackcheck
  142. );
  143. tfeatures = set of tfeature;
  144. type
  145. { optimizer }
  146. toptimizerswitch = (cs_opt_none,
  147. cs_opt_level1,cs_opt_level2,cs_opt_level3,
  148. cs_opt_regvar,cs_opt_uncertain,cs_opt_size,cs_opt_stackframe,
  149. cs_opt_peephole,cs_opt_asmcse,cs_opt_loopunroll,cs_opt_tailrecursion,cs_opt_nodecse,
  150. cs_opt_nodedfa
  151. );
  152. toptimizerswitches = set of toptimizerswitch;
  153. const
  154. OptimizerSwitchStr : array[toptimizerswitch] of string[10] = ('',
  155. 'LEVEL1','LEVEL2','LEVEL3',
  156. 'REGVAR','UNCERTAIN','SIZE','STACKFRAME',
  157. 'PEEPHOLE','ASMCSE','LOOPUNROLL','TAILREC','CSE','DFA'
  158. );
  159. DebugSwitchStr : array[tdebugswitch] of string[9] = ('',
  160. 'DWARFSETS');
  161. { switches being applied to all CPUs at the given level }
  162. genericlevel1optimizerswitches = [cs_opt_level1];
  163. genericlevel2optimizerswitches = [cs_opt_level2];
  164. genericlevel3optimizerswitches = [cs_opt_level3];
  165. featurestr : array[tfeature] of string[12] = (
  166. 'HEAP','INITFINAL','RTTI','CLASSES','EXCEPTIONS','EXITCODE',
  167. 'ANSISTRINGS','WIDESTRINGS','TEXTIO','CONSOLEIO','FILEIO',
  168. 'RANDOM','VARIANTS','OBJECTS','DYNARRAYS','THREADING','COMMANDARGS',
  169. 'PROCESSES','STACKCHECK'
  170. );
  171. type
  172. { Switches which can be changed by a mode (fpc,tp7,delphi) }
  173. tmodeswitch = (m_none,m_all, { needed for keyword }
  174. { generic }
  175. m_fpc,m_objfpc,m_delphi,m_tp7,m_mac,
  176. {$ifdef fpc_mode}m_gpc,{$endif}
  177. { more specific }
  178. m_class, { delphi class model }
  179. m_objpas, { load objpas unit }
  180. m_result, { result in functions }
  181. m_string_pchar, { pchar 2 string conversion }
  182. m_cvar_support, { cvar variable directive }
  183. m_nested_comment, { nested comments }
  184. m_tp_procvar, { tp style procvars (no @ needed) }
  185. m_mac_procvar, { macpas style procvars }
  186. m_repeat_forward, { repeating forward declarations is needed }
  187. m_pointer_2_procedure, { allows the assignement of pointers to
  188. procedure variables }
  189. m_autoderef, { does auto dereferencing of struct. vars }
  190. m_initfinal, { initialization/finalization for units }
  191. m_add_pointer, { allow pointer add/sub operations }
  192. m_default_ansistring, { ansistring turned on by default }
  193. m_out, { support the calling convention OUT }
  194. m_default_para, { support default parameters }
  195. m_hintdirective, { support hint directives }
  196. m_duplicate_names, { allow locals/paras to have duplicate names of globals }
  197. m_property, { allow properties }
  198. m_default_inline, { allow inline proc directive }
  199. m_except { allow exception-related keywords }
  200. );
  201. tmodeswitches = set of tmodeswitch;
  202. { Win32, OS/2 & MacOS application types }
  203. tapptype = (
  204. app_none,
  205. app_native,
  206. app_gui, { graphic user-interface application}
  207. app_cui, { console application}
  208. app_fs, { full-screen type application (OS/2 and EMX only) }
  209. app_tool, { tool application, (MPW tool for MacOS, MacOS only)}
  210. app_arm7,
  211. app_arm9,
  212. app_bundle { dynamically loadable bundle, Darwin only }
  213. );
  214. { interface types }
  215. tinterfacetypes = (
  216. it_interfacecom,
  217. it_interfacecorba
  218. );
  219. { currently parsed block type }
  220. tblock_type = (bt_none,
  221. bt_general,bt_type,bt_const,bt_except,bt_body,bt_specialize
  222. );
  223. { Temp types }
  224. ttemptype = (tt_none,
  225. tt_free,tt_normal,tt_persistent,
  226. tt_noreuse,tt_freenoreuse);
  227. ttemptypeset = set of ttemptype;
  228. { calling convention for tprocdef and tprocvardef }
  229. tproccalloption=(pocall_none,
  230. { procedure uses C styled calling }
  231. pocall_cdecl,
  232. { C++ calling conventions }
  233. pocall_cppdecl,
  234. { Far16 for OS/2 }
  235. pocall_far16,
  236. { Old style FPC default calling }
  237. pocall_oldfpccall,
  238. { Procedure has compiler magic}
  239. pocall_internproc,
  240. { procedure is a system call, applies e.g. to MorphOS and PalmOS }
  241. pocall_syscall,
  242. { pascal standard left to right }
  243. pocall_pascal,
  244. { procedure uses register (fastcall) calling }
  245. pocall_register,
  246. { safe call calling conventions }
  247. pocall_safecall,
  248. { procedure uses stdcall call }
  249. pocall_stdcall,
  250. { Special calling convention for cpus without a floating point
  251. unit. Floating point numbers are passed in integer registers
  252. instead of floating point registers. Depending on the other
  253. available calling conventions available for the cpu
  254. this replaces either pocall_fastcall or pocall_stdcall.
  255. }
  256. pocall_softfloat,
  257. { Metrowerks Pascal. Special case on Mac OS (X): passes all }
  258. { constant records by reference. }
  259. pocall_mwpascal
  260. );
  261. tproccalloptions = set of tproccalloption;
  262. const
  263. proccalloptionStr : array[tproccalloption] of string[14]=('',
  264. 'CDecl',
  265. 'CPPDecl',
  266. 'Far16',
  267. 'OldFPCCall',
  268. 'InternProc',
  269. 'SysCall',
  270. 'Pascal',
  271. 'Register',
  272. 'SafeCall',
  273. 'StdCall',
  274. 'SoftFloat',
  275. 'MWPascal'
  276. );
  277. { Default calling convention }
  278. {$ifdef x86}
  279. pocall_default = pocall_register;
  280. {$else}
  281. pocall_default = pocall_stdcall;
  282. {$endif}
  283. type
  284. tprocinfoflag=(
  285. { procedure has at least one assembler block }
  286. pi_has_assembler_block,
  287. { procedure does a call }
  288. pi_do_call,
  289. { procedure has a try statement = no register optimization }
  290. pi_uses_exceptions,
  291. { procedure is declared as @var(assembler), don't optimize}
  292. pi_is_assembler,
  293. { procedure contains data which needs to be finalized }
  294. pi_needs_implicit_finally,
  295. { procedure has the implicit try..finally generated }
  296. pi_has_implicit_finally,
  297. { procedure uses fpu}
  298. pi_uses_fpu,
  299. { procedure uses GOT for PIC code }
  300. pi_needs_got,
  301. { references var/proc/type/const in static symtable,
  302. i.e. not allowed for inlining from other units }
  303. pi_uses_static_symtable,
  304. { set if the procedure has to push parameters onto the stack }
  305. pi_has_stackparameter,
  306. { set if the procedure has at least one got }
  307. pi_has_goto,
  308. { calls itself recursive }
  309. pi_is_recursive,
  310. { stack frame optimization not possible (only on x86 probably) }
  311. pi_needs_stackframe,
  312. { set if the procedure has at least one register saved on the stack }
  313. pi_has_saved_regs
  314. );
  315. tprocinfoflags=set of tprocinfoflag;
  316. type
  317. { float types }
  318. tfloattype = (
  319. s32real,s64real,s80real,
  320. s64comp,s64currency,s128real
  321. );
  322. type
  323. { register allocator live range extension direction }
  324. TRADirection = (rad_forward, rad_backwards, rad_backwards_reinit);
  325. type
  326. TIDString = string[maxidlen];
  327. tnormalset = set of byte; { 256 elements set }
  328. pnormalset = ^tnormalset;
  329. pboolean = ^boolean;
  330. pdouble = ^double;
  331. pbyte = ^byte;
  332. pword = ^word;
  333. plongint = ^longint;
  334. plongintarray = plongint;
  335. pfileposinfo = ^tfileposinfo;
  336. tfileposinfo = record
  337. line : longint;
  338. column : word;
  339. fileindex : word;
  340. moduleindex : word;
  341. end;
  342. {$ifndef xFPC}
  343. type
  344. pguid = ^tguid;
  345. tguid = packed record
  346. D1: LongWord;
  347. D2: Word;
  348. D3: Word;
  349. D4: array[0..7] of Byte;
  350. end;
  351. {$endif}
  352. const
  353. { link options }
  354. link_none = $0;
  355. link_always = $1;
  356. link_static = $2;
  357. link_smart = $4;
  358. link_shared = $8;
  359. implementation
  360. end.