globtype.pas 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
  4. Global types
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit globtype;
  19. {$i fpcdefs.inc}
  20. interface
  21. const
  22. maxidlen = 64;
  23. type
  24. { Switches which can be changed locally }
  25. tlocalswitch = (cs_localnone,
  26. { codegen }
  27. cs_check_overflow,cs_check_range,cs_check_object,
  28. cs_check_io,cs_check_stack,
  29. cs_omitstackframe,cs_do_assertion,cs_generate_rtti,
  30. cs_full_boolean_eval,cs_typed_const_writable,
  31. { mmx }
  32. cs_mmx,cs_mmx_saturation,
  33. { parser }
  34. cs_typed_addresses,cs_strict_var_strings,cs_ansistrings
  35. );
  36. tlocalswitches = set of tlocalswitch;
  37. { Switches which can be changed only at the beginning of a new module }
  38. tmoduleswitch = (cs_modulenone,
  39. { parser }
  40. cs_fp_emulation,cs_extsyntax,cs_openstring,
  41. { support }
  42. cs_support_inline,cs_support_goto,cs_support_macro,
  43. cs_support_c_operators,cs_static_keyword,
  44. { generation }
  45. cs_profile,cs_debuginfo,cs_browser,cs_local_browser,cs_compilesystem,
  46. cs_lineinfo,cs_threading,cs_implicit_exceptions,
  47. { linking }
  48. cs_create_smart,cs_create_dynamic,cs_create_pic
  49. );
  50. tmoduleswitches = set of tmoduleswitch;
  51. { Switches which can be changed only for a whole program/compilation,
  52. mostly set with commandline }
  53. tglobalswitch = (cs_globalnone,
  54. { parameter switches }
  55. cs_check_unit_name,cs_constructor_name,
  56. { units }
  57. cs_load_objpas_unit,
  58. cs_load_gpc_unit,
  59. { optimizer }
  60. cs_regvars,cs_no_regalloc,cs_uncertainopts,cs_littlesize,
  61. cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_align,
  62. { browser }
  63. cs_browser_log,
  64. { debugger }
  65. cs_gdb_dbx,cs_gdb_gsym,cs_gdb_heaptrc,cs_gdb_lineinfo,
  66. cs_checkpointer,cs_gdb_valgrind,
  67. { assembling }
  68. cs_asm_leave,cs_asm_extern,cs_asm_pipe,cs_asm_source,
  69. cs_asm_regalloc,cs_asm_tempalloc,cs_asm_nodes,
  70. { linking }
  71. cs_link_extern,cs_link_static,cs_link_smart,cs_link_shared,cs_link_deffile,
  72. cs_link_strip,cs_link_staticflag,cs_link_on_target,cs_link_internal,
  73. cs_link_map,cs_link_pthread
  74. );
  75. tglobalswitches = set of tglobalswitch;
  76. { Switches which can be changed by a mode (fpc,tp7,delphi) }
  77. tmodeswitch = (m_none,m_all, { needed for keyword }
  78. { generic }
  79. m_fpc,m_objfpc,m_delphi,m_tp7,m_gpc,m_mac,
  80. { more specific }
  81. m_class, { delphi class model }
  82. m_objpas, { load objpas unit }
  83. m_result, { result in functions }
  84. m_string_pchar, { pchar 2 string conversion }
  85. m_cvar_support, { cvar variable directive }
  86. m_nested_comment, { nested comments }
  87. m_tp_procvar, { tp style procvars (no @ needed) }
  88. m_repeat_forward, { repeating forward declarations is needed }
  89. m_pointer_2_procedure, { allows the assignement of pointers to
  90. procedure variables }
  91. m_autoderef, { does auto dereferencing of struct. vars }
  92. m_initfinal, { initialization/finalization for units }
  93. m_add_pointer, { allow pointer add/sub operations }
  94. m_default_ansistring, { ansistring turned on by default }
  95. m_out, { support the calling convention OUT }
  96. m_default_para, { support default parameters }
  97. m_hintdirective, { support hint directives }
  98. m_duplicate_names { allow locals/paras to have duplicate names of globals }
  99. );
  100. tmodeswitches = set of tmodeswitch;
  101. { Win32, OS/2 & MacOS application types }
  102. tapptype = (
  103. app_none,
  104. app_gui, { graphic user-interface application}
  105. app_cui, { console application}
  106. app_fs, { full-screen type application (OS/2 and EMX only) }
  107. app_tool { tool application, (MPW tool for MacOS, MacOS only)}
  108. );
  109. { interface types }
  110. tinterfacetypes = (
  111. it_interfacecom,
  112. it_interfacecorba
  113. );
  114. { currently parsed block type }
  115. tblock_type = (bt_none,
  116. bt_general,bt_type,bt_const,bt_except,bt_body
  117. );
  118. { calling convention for tprocdef and tprocvardef }
  119. tproccalloption=(pocall_none,
  120. { procedure uses C styled calling }
  121. pocall_cdecl,
  122. { C++ calling conventions }
  123. pocall_cppdecl,
  124. { Procedure is used for internal compiler calls }
  125. pocall_compilerproc,
  126. { Far16 for OS/2 }
  127. pocall_far16,
  128. { Old style FPC default calling }
  129. pocall_oldfpccall,
  130. { Procedure is an assembler macro }
  131. pocall_inline,
  132. { Procedure has compiler magic}
  133. pocall_internproc,
  134. { procedure is a PalmOS system call }
  135. pocall_palmossyscall,
  136. { pascal standard left to right }
  137. pocall_pascal,
  138. { procedure uses register (fastcall) calling }
  139. pocall_register,
  140. { safe call calling conventions }
  141. pocall_safecall,
  142. { procedure uses stdcall call }
  143. pocall_stdcall,
  144. { Special calling convention for cpus without a floating point
  145. unit. Floating point numbers are passed in integer registers
  146. instead of floating point registers. Depending on the other
  147. available calling conventions available for the cpu
  148. this replaces either pocall_fastcall or pocall_stdcall.
  149. }
  150. pocall_softfloat
  151. );
  152. tproccalloptions = set of tproccalloption;
  153. const
  154. proccalloptionStr : array[tproccalloption] of string[14]=('',
  155. 'CDecl',
  156. 'CPPDecl',
  157. 'CompilerProc',
  158. 'Far16',
  159. 'OldFPCCall',
  160. 'Inline',
  161. 'InternProc',
  162. 'PalmOSSysCall',
  163. 'Pascal',
  164. 'Register',
  165. 'SafeCall',
  166. 'StdCall',
  167. 'SoftFloat'
  168. );
  169. { Default calling convention }
  170. {$ifdef x86}
  171. pocall_default = pocall_register;
  172. {$else}
  173. pocall_default = pocall_stdcall;
  174. {$endif}
  175. type
  176. stringid = string[maxidlen];
  177. tnormalset = set of byte; { 256 elements set }
  178. pnormalset = ^tnormalset;
  179. pboolean = ^boolean;
  180. pdouble = ^double;
  181. pbyte = ^byte;
  182. pword = ^word;
  183. plongint = ^longint;
  184. plongintarray = plongint;
  185. Tconstant=record
  186. case signed:boolean of
  187. false:
  188. (valueu:cardinal);
  189. true:
  190. (values:longint);
  191. end;
  192. {$ifndef Delphi}
  193. {$ifndef xFPC}
  194. type
  195. pguid = ^tguid;
  196. tguid = packed record
  197. D1: LongWord;
  198. D2: Word;
  199. D3: Word;
  200. D4: array[0..7] of Byte;
  201. end;
  202. {$endif}
  203. {$endif}
  204. const
  205. { link options }
  206. link_none = $0;
  207. link_allways = $1;
  208. link_static = $2;
  209. link_smart = $4;
  210. link_shared = $8;
  211. implementation
  212. end.
  213. {
  214. $Log$
  215. Revision 1.51 2004-04-04 18:46:09 olle
  216. + added $APPTYPE TOOL for MPW tools on MacOS
  217. Revision 1.50 2004/03/10 22:52:57 peter
  218. * more stabs fixes
  219. * special mode -gv for valgrind compatible stabs
  220. Revision 1.49 2004/02/15 16:34:18 marco
  221. * pthread on -CURRENT related fixes.
  222. Revision 1.48 2003/12/23 23:22:35 peter
  223. * register calling is now default for i386
  224. Revision 1.47 2003/12/14 20:51:17 daniel
  225. * Register calling disabled again
  226. Revision 1.46 2003/12/14 20:24:28 daniel
  227. * Register allocator speed optimizations
  228. - Worklist no longer a ringbuffer
  229. - No find operations are left
  230. - Simplify now done in constant time
  231. - unusedregs is now a Tsuperregisterworklist
  232. - Microoptimizations
  233. Revision 1.45 2003/12/04 23:27:32 peter
  234. * remove redundant calls to add_edge_used
  235. Revision 1.44 2003/11/07 15:58:32 florian
  236. * Florian's culmutative nr. 1; contains:
  237. - invalid calling conventions for a certain cpu are rejected
  238. - arm softfloat calling conventions
  239. - -Sp for cpu dependend code generation
  240. - several arm fixes
  241. - remaining code for value open array paras on heap
  242. Revision 1.43 2003/09/28 13:39:58 peter
  243. * default calling convention changed to stdcall
  244. Revision 1.42 2003/09/07 22:09:35 peter
  245. * preparations for different default calling conventions
  246. * various RA fixes
  247. Revision 1.41 2003/09/04 21:37:29 olle
  248. + added new lagnuage mode: MAC
  249. Revision 1.40 2003/09/03 15:55:00 peter
  250. * NEWRA branch merged
  251. Revision 1.39 2003/08/09 18:56:54 daniel
  252. * cs_regalloc renamed to cs_regvars to avoid confusion with register
  253. allocator
  254. * Some preventive changes to i386 spillinh code
  255. Revision 1.38 2003/04/27 11:21:32 peter
  256. * aktprocdef renamed to current_procdef
  257. * procinfo renamed to current_procinfo
  258. * procinfo will now be stored in current_module so it can be
  259. cleaned up properly
  260. * gen_main_procsym changed to create_main_proc and release_main_proc
  261. to also generate a tprocinfo structure
  262. * fixed unit implicit initfinal
  263. Revision 1.37 2003/04/27 07:29:50 peter
  264. * current_procdef cleanup, current_procdef is now always nil when parsing
  265. a new procdef declaration
  266. * aktprocsym removed
  267. * lexlevel removed, use symtable.symtablelevel instead
  268. * implicit init/final code uses the normal genentry/genexit
  269. * funcret state checking updated for new funcret handling
  270. Revision 1.36 2003/04/22 23:50:22 peter
  271. * firstpass uses expectloc
  272. * checks if there are differences between the expectloc and
  273. location.loc from secondpass in EXTDEBUG
  274. Revision 1.35 2003/03/08 08:59:07 daniel
  275. + $define newra will enable new register allocator
  276. + getregisterint will return imaginary registers with $newra
  277. + -sr switch added, will skip register allocation so you can see
  278. the direct output of the code generator before register allocation
  279. Revision 1.34 2002/10/16 19:01:43 peter
  280. + $IMPLICITEXCEPTIONS switch to turn on/off generation of the
  281. implicit exception frames for procedures with initialized variables
  282. and for constructors. The default is on for compatibility
  283. Revision 1.33 2002/10/14 19:43:41 peter
  284. * threading switch, defines the symbol FPC_THREADING
  285. Revision 1.32 2002/10/05 12:43:24 carl
  286. * fixes for Delphi 6 compilation
  287. (warning : Some features do not work under Delphi)
  288. Revision 1.31 2002/08/19 19:36:42 peter
  289. * More fixes for cross unit inlining, all tnodes are now implemented
  290. * Moved pocall_internconst to po_internconst because it is not a
  291. calling type at all and it conflicted when inlining of these small
  292. functions was requested
  293. Revision 1.30 2002/08/12 15:08:39 carl
  294. + stab register indexes for powerpc (moved from gdb to cpubase)
  295. + tprocessor enumeration moved to cpuinfo
  296. + linker in target_info is now a class
  297. * many many updates for m68k (will soon start to compile)
  298. - removed some ifdef or correct them for correct cpu
  299. Revision 1.29 2002/08/06 20:55:20 florian
  300. * first part of ppc calling conventions fix
  301. Revision 1.28 2002/07/04 20:43:00 florian
  302. * first x86-64 patches
  303. Revision 1.27 2002/07/01 18:46:22 peter
  304. * internal linker
  305. * reorganized aasm layer
  306. Revision 1.26 2002/05/18 13:34:08 peter
  307. * readded missing revisions
  308. Revision 1.25 2002/05/16 19:46:36 carl
  309. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  310. + try to fix temp allocation (still in ifdef)
  311. + generic constructor calls
  312. + start of tassembler / tmodulebase class cleanup
  313. Revision 1.23 2002/05/12 16:53:05 peter
  314. * moved entry and exitcode to ncgutil and cgobj
  315. * foreach gets extra argument for passing local data to the
  316. iterator function
  317. * -CR checks also class typecasts at runtime by changing them
  318. into as
  319. * fixed compiler to cycle with the -CR option
  320. * fixed stabs with elf writer, finally the global variables can
  321. be watched
  322. * removed a lot of routines from cga unit and replaced them by
  323. calls to cgobj
  324. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  325. u32bit then the other is typecasted also to u32bit without giving
  326. a rangecheck warning/error.
  327. * fixed pascal calling method with reversing also the high tree in
  328. the parast, detected by tcalcst3 test
  329. Revision 1.22 2002/04/21 19:02:03 peter
  330. * removed newn and disposen nodes, the code is now directly
  331. inlined from pexpr
  332. * -an option that will write the secondpass nodes to the .s file, this
  333. requires EXTDEBUG define to actually write the info
  334. * fixed various internal errors and crashes due recent code changes
  335. Revision 1.21 2002/03/24 19:05:59 carl
  336. + patch for SPARC from Mazen NEIFER
  337. Revision 1.20 2002/01/24 18:25:48 peter
  338. * implicit result variable generation for assembler routines
  339. * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
  340. }