Commit Graph

635 Commits

Author SHA1 Message Date
svenbarth
f69b365b77 * declare various symbols as external assembler symbols: RTTI references, parent VMT, FPC_EMPTYMETHOD (all three only if it's used from a different unit), threadvar lists and symbols declared as "external"
git-svn-id: trunk@34176 -
2016-07-22 13:34:38 +00:00
Jonas Maebe
1cb8c0d00c * specify the def of assembler level symbols defined via
tasmdata.DefineAsmSymbol() and all routines that call it
   o will be used to automatically generate AB_INDIRECT sybols when
     necessary

git-svn-id: trunk@34164 -
2016-07-20 20:52:59 +00:00
Jonas Maebe
cd5817a689 * also emit a tai_varloc() when regvars are initially assigned
o removed separate writing of the local variable/parameter location from
     psub, as that is now triggered by thise tai_varloc

git-svn-id: trunk@34084 -
2016-07-08 07:46:45 +00:00
Jonas Maebe
98ac6c4797 * converted gen_stack_check_call() to the high level code generator
git-svn-id: trunk@33990 -
2016-06-15 18:31:52 +00:00
svenbarth
e527b6fe4f psub.pas, read_proc:
* always register implementation-only, public routines as they might only be called from other units using an external declaration

git-svn-id: trunk@33967 -
2016-06-12 13:47:08 +00:00
svenbarth
af26a31251 psub.pas, read_proc_body:
* reset _FAIL directly after parsing the routine

git-svn-id: trunk@33881 -
2016-06-02 19:31:47 +00:00
svenbarth
ac95dcd7fa Improve inlining of generic routines (no matter whether they belong to a generic type or a generics themselves).
psub.pas, read_proc_body: 
  * also try to generate pending specializations before generating a routine's code so that these might be inlined as well

git-svn-id: trunk@33827 -
2016-05-26 18:57:55 +00:00
svenbarth
f27ce0b159 Rework the way the method bodies for specializations are generated: instead of walking the global and local symboltable all pending specializations are kept in a list of the current module which is (for now) walked at the end of a unit/program to generate the method bodies as before.
fmodule.pas, tmodule:
  + new list pendingspecializations which keeps track of all pending specializations of the current module
psub.pas:
  * move generate_specialization_procs and related routines to pgenutil
  + new procedure read_proc_body to read a routine's body, cause generate_specialization_procs needs it (unlike the already existing overload in the implementation section, this one can only handle bodies of non-nested routines) 
pgenutil.pas:
  * generate_specialization_phase2: add the newly specialized generic to the current module's pending specializations
  * generate_specialization_procs: reworked so that it uses the new pendingspecializations field instead of walking the global and local symboltable of the current unit
pmodules.pas:
  + add pgenutil to uses due to the moved generate_specialization_procs

+ added test

git-svn-id: trunk@33826 -
2016-05-26 18:56:16 +00:00
Jonas Maebe
0e9d232d2a * fixed indentation in previous commit
git-svn-id: trunk@33738 -
2016-05-21 14:51:24 +00:00
Jonas Maebe
fe5cf94e10 * moved generation of initialisation/finalisation nodes from the code
generator to psub and ngenutil
   o removed dependence of hlcgobj on pass_1

git-svn-id: trunk@33737 -
2016-05-21 14:48:34 +00:00
florian
3c2dab9878 * i386 peephole assembler uses largely the common peephole optimizer infrastructure, the resulting code is besides a few improvements the same
git-svn-id: trunk@33542 -
2016-04-21 20:14:01 +00:00
svenbarth
0a8d531b8d Merged revision(s) 32582-32583, 32635, 32637, 32639 from branches/svenbarth/packages:
pkgutil.pas, createimportlibfromexternals:
  * findpackagewithsym: ignore other (weak) external symbols
........
pkgutil.pas, createimportlibfromexternals:
  * import_proc_symbol: at least import the mangled name if there is no alias available
........
pkgutil.pas:
  * exportabstractrecordsymproc & insert_export: don't try to export a typedef if it doesn't belong to the current symtable, happens for cross unit type aliases
........
psub.pas:
  * read_proc: extract the code that creates an import library entry into its own function import_external_proc so that the same code can be used from other locations as well
........
Correctly handle external functions that are used from other units.

pkgutil.pas, createimportlibfromexternals:
  * processasmsyms: also check the import name when checking for duplicates (just for safety, the cache check should have caught these already)
  * processimportedsyms: if we have a routine imported from a library of whihc the symbol resides in a unit loaded from a package we need to import the routine ourselves instead of trying to import it from the package; also add an entry in the cache to speed up finding it again in processasmsyms()
........

git-svn-id: trunk@33519 -
2016-04-15 15:09:37 +00:00
svenbarth
35f8d5427f Revert r31262. Not doing type checking on generics leads to strange warnings (e.g. because variables are not considered as written). I better deal with the compile time errors one at a time than the warnings.
The added test shows such a bogus warning (sadly the test suite can handle the occurence or absense of certain messages yet :/ )

git-svn-id: trunk@33324 -
2016-03-24 20:58:04 +00:00
svenbarth
e9fab1bfee Fix for Mantis #29080.
psub.pas, tcgprocinfo.parse_body:
  * ensure that parse_generic and current_genericdef are set correctly when parsing a generic routine
pgenutil.pas, generate_specialization_phase2:
  * when we're specializing inside a generic we don't want to have the routine definitions, so let the compiler assume that the routine is no longer a forward definition

+ added test

git-svn-id: trunk@33275 -
2016-03-18 16:31:23 +00:00
svenbarth
557f74cdbd (Note to self: always include the root of the working copy in the commit when dealing with merges -.-)
Merged revision(s) 28793, 28903, 31951 from branches/svenbarth/packages:
psub.pas, read_proc:
  * don't generate assembler symbols for compiler internal code
........
Ensure that unneeded initialization/finalization procedures don't leave assembler symbols.

ncgutil.pas:
  + new function release_proc_symbol which removes all assembler symbols of a procdef
pmodules.pas, proc_unit:
  * if the initialization or finalization procedure is empty also remove their assembler symbols so they are exported
........
Ensure that readonly sections that need relocations are indeed declared as such.
Thanks to Jonas for this.

ncgvmt.pas, TVMTWriter:
  * writeinterfaceids: use sec_rodata instead of sec_rodata_norel

........

git-svn-id: trunk@32982 -
2016-01-22 16:58:33 +00:00
Jonas Maebe
8164d5aaf4 * don't make all procdef symbols global if we are using section-based
smartlinkin

git-svn-id: trunk@32803 -
2015-12-30 21:55:32 +00:00
Jonas Maebe
31bd38c45b * only add the procdef's parentfpinitblock if there are any statements in it
* internalerror if we try to add a non-empty parentfpinitblock to a
    pure assembler routine

git-svn-id: trunk@32740 -
2015-12-26 20:01:25 +00:00
Jonas Maebe
7a8079cfb4 * removed DLLsource global variable and replaced its uses with
current_module.islibrary

git-svn-id: trunk@32676 -
2015-12-17 15:23:05 +00:00
svenbarth
8bd79f95be Fix a few typos discovered by Blaise
git-svn-id: trunk@32640 -
2015-12-11 16:31:00 +00:00
yury
17358aa3ed * Removed unused local vars.
git-svn-id: trunk@32537 -
2015-11-26 17:15:04 +00:00
svenbarth
3c41e50f2f Implement generation of method bodies for generic functions.
psub.pas, specialize_objectdefs:
  + new nested procedure process_procdef() to handle the generation of method bodies for procdefs both in generic types as well as of generic functions
  + new nested procedure process_procsym() to handle the generation of method bodies for each specialization procdef of a procsym
  * allow all procsyms and recursively walk all non-generic types to find all method bodies that need to be generated

git-svn-id: trunk@32383 -
2015-11-20 18:01:18 +00:00
svenbarth
d3660fec31 Implement support for parsing "generic [class] procedure" and "generic [class] function" in non-Delphi modes. Since "generic" is a prefix it is quite ugly to implement, but from a Pascal language point of view it fits better than "procedure generic xyz".
Supporting such a prefix of course means that all section handling code ("var", "type", etc.) needs to respect the case of a "generic" token followed by "function", "procedure" or "class" and thus abort doing its own business.
Maybe I'll find the time somewhen in the future to rework the parser (plus scanner?) a bit so that code like this gets more easy to add and more importantly less ugly.

pdecsub.pas:
  * extend parse_proc_dec() and parse_record_method_dec() so that they can be told that they are supposed to handle the to be parsed function/procedure/method header as a generic
pdecvar.pas:
  + new entry for tvar_dec_option named "vd_check_generic" to tell read_var_decls() and read_record_fields() to look out for "generic"
  * extend read_var_decls() and read_record_fields() to check for "generic" if needed and to clean up correctly if it is encountered
pdecl.pas:
  * the section handling procedures types_dec(), resourcestring_dec(), var_dec(), threadvar_dec() and consts_dec() all return whether they had encountered a "generic" token that was followed by one of $
pdecobj.pas:
  * extend method_dec() to take a parameter that says whether the method is supposed to be a generic one
  * parse_object_members: while read_record_fields() can handle "generic" we also need to handle the case of "generic" if no fields are allowed anymore
psub.pas:
  * extend read_proc() by the possibility to tell it that the procedure/function to be parsed is supposed to be generic
  * adjust read_declarations() and read_interface_declarations() to keep track of parsed "generic" tokens and to pass them on accordingly
ptype.pas:
  * parse_record_members: same remark as for pdecobj.parse_object_members

git-svn-id: trunk@32380 -
2015-11-20 16:50:58 +00:00
Jonas Maebe
1e1e4b96e0 * don't store node trees for inline generic routines, as they contain
references to defs that are not stored in the ppu files (causing
    errors) and are never used for inlining (only the specialisations
    may be inlined) (fixes webtbs/tw27658.pp after r32031)

git-svn-id: trunk@32050 -
2015-10-13 15:59:18 +00:00
svenbarth
529677cc79 ncal.pas:
* extend tcallnode with the ability to pass a tspecializationcontext so that tcallcandidates can do a final specialization
  * the final procdef is registered at the end of tcallnode.pass_typecheck

git-svn-id: trunk@31763 -
2015-09-18 14:48:54 +00:00
yury
11a9ff4a43 * Removed unused vars for mipsel compiler.
git-svn-id: trunk@31745 -
2015-09-17 15:46:30 +00:00
yury
432248cbf1 * Removed lot of unused vars.
git-svn-id: trunk@31732 -
2015-09-17 12:48:58 +00:00
Jonas Maebe
2205549316 * changed fix for webtbs/tw20075 so that we don't check the need for
parameter/local finalization at all in pure assembler routines;
    the routines that check this also set pi_needs_got, which should
    not be set either for pure assembler routines (fixes tw20075 on
    Darwin/i386, where PIC code is enabled by default)

git-svn-id: trunk@31622 -
2015-09-12 23:31:50 +00:00
svenbarth
e8fca1c9c0 * move tspecializationstate from pgenutil.pas into a new unit named pgentype.pas which contains types related to generics with as few dependencies as possible.
git-svn-id: trunk@31507 -
2015-09-04 13:37:06 +00:00
Jonas Maebe
a58504990a * fixed llvm handling of routines that are normally declared in the
interface of a unit, or forward declared, and then the implementation turns
    out to be external. We now properly generate a wrapper routine at the
    Pascal level for the original declaration that calls through to the
    external routine

git-svn-id: trunk@31285 -
2015-08-05 21:05:55 +00:00
florian
9a55e8fa3c * do not call typecheckpass unncessarily in generic definitions, it might cause only errors, resolves #28058
git-svn-id: trunk@31262 -
2015-08-02 20:29:30 +00:00
Jonas Maebe
b39bc5888a * moved the import name handling entirely to hlcgobj so it can be
overridden

git-svn-id: trunk@31053 -
2015-06-13 22:48:17 +00:00
Jonas Maebe
2cdf969649 * don't define asmsymbols for weak external functions as local/global
git-svn-id: trunk@31048 -
2015-06-13 22:48:02 +00:00
florian
420309ec59 * reduce dependencies of the procinfo unit
git-svn-id: trunk@30871 -
2015-05-16 21:49:42 +00:00
florian
f972398a8c + main program never returns
git-svn-id: trunk@30656 -
2015-04-19 08:10:06 +00:00
Jonas Maebe
67b8aceaee * synchronized with privatetrunk till r30095
git-svn-id: branches/hlcgllvm@30101 -
2015-03-05 20:32:15 +00:00
florian
932b68310e * do not warn about internally generated parameters, resolves #25914
git-svn-id: trunk@29636 -
2015-02-06 20:44:24 +00:00
sergei
adeb8c93e9 * Set pi_do_call flag explicitly when procedure has a parameter or local var that require finalization. Normally it is set by implicit try..finally node, but this node is absent when compiling in {$implicitexceptions off} mode. This may cause internal errors in pass 2 if pi_do_call has not been set by other means.
Fixes IE when compiling Lazarus for MIPS target.
+ Test.

git-svn-id: trunk@29590 -
2015-01-31 13:33:36 +00:00
Jonas Maebe
eb419b58c5 - disable inlining of routines that contain a call to a C-style varargs
function, as we don't save/restore the synthetic paravarsyms that
    are created for this

git-svn-id: trunk@29584 -
2015-01-30 19:31:22 +00:00
florian
69ac7dd7ef * limit initialization to register variables which really need to be initialized
git-svn-id: trunk@29569 -
2015-01-27 21:51:29 +00:00
svenbarth
af43e5e3e9 Fix for Mantis #24872.
psub.pas, tcgprocinfo.parse_body:
  * also check record symtables besides object symtables to determine whether the staticsymtable is accessed from a globally declared generic
  * use a translateable message if the static symtable is accessed if it should not
msg/errore.msg:
  + add new error message for when the static symtable is accessed from a global generic
msgidx.inc & msgtixt.inc:
  * regenerated

+ added test

git-svn-id: trunk@29427 -
2015-01-06 20:46:12 +00:00
florian
f1eb00a450 * do not issue a hint about uninitialized var-parameters, resolves #25916
git-svn-id: trunk@29289 -
2014-12-14 17:54:37 +00:00
sergei
0b4d54fcb9 - Delete all position markers from assembler code before optimization. Markers of this kind are not used by optimizer and are expected to be ignored, but ignoring them requires numerous checks in all target-specific optimizers and currently isn't done correctly. In turn, failure to ignore markers prevents optimization of procedure prologues and epilogues.
git-svn-id: trunk@28647 -
2014-09-12 23:15:23 +00:00
Jonas Maebe
bacd303208 * synchronized with trunk up to r27758
git-svn-id: branches/hlcgllvm@27779 -
2014-05-12 16:12:34 +00:00
Jonas Maebe
362ff5ad01 * only check for _PROPERTY as a regular token, so that
{$modeswitch properties-} also affects global properties
    (mantis #25861)

git-svn-id: trunk@27758 -
2014-05-10 16:03:02 +00:00
sergei
96dd464bf2 * Moved fixup_jmps to target-specific classes for powerpc,powerpc64 and MIPS, cleaned out remaining $ifdef's. A slight functionality change is that fixup_jmps is now called before adding the procedure end symbol, not after, but that should not matter.
git-svn-id: trunk@27450 -
2014-04-02 14:17:23 +00:00
sergei
eeb15fc445 * Added virtual method tprocinfo.postprocess_code and moved target-specific processing from base class into target-specific descendant classes (ARM and AVR, other targets still to do).
git-svn-id: trunk@27449 -
2014-04-02 13:14:06 +00:00
Jonas Maebe
d020a32b9a - removed no longer used tprocdef.fpu_used field for i386/i8086 (the one
place where it was used, we now handle the consequence directly)

git-svn-id: trunk@27435 -
2014-04-01 21:41:18 +00:00
Jonas Maebe
b57c95043f + support overriding tdef/tsym methods with target-specific functionality:
o made all (non-abstract) tdef and tsym constructors virtual
   o added c*def/c*sym classref types for every (non-abstract) t*def/t*sym
     class
   o added cpusym unit for every architecture that derives a tcpu*def/tcpu*sym
     class from the base classes, and initialises the c*def/c*sym classes with
     them. This is done so that the llvm target will be able to derive from
     the tcpu*def/sym classes without umpteen ifdefs, and it also means that
     the WPO can devirtualise everything because the c* variables are only
     initialised with one class type
   o replaced all t*def/t*sym constructor calls with c*def/c*sym constructor
     calls

git-svn-id: trunk@27361 -
2014-03-29 22:31:55 +00:00
florian
686a2d2f3f + Support omitting the frame pointer on arm even in procedures with incoming parameters
on the stack, this can be enabled by -OoFORCENOSTACKFRAME. This reduces the required
  entry/exit code and makes an extra register available to the compiler. However, since this is
  based on an estimation of the required stack size, it might have two drawbacks:
  either the stack frame is estimated to big, the program requires a bigger stack than needed
  or it is estimated too small, then the compiler throws an internalerror during compilation. These
  issues can be overcome as soon as the compiler supports recompiling subroutines if needed.

git-svn-id: trunk@27239 -
2014-03-23 14:38:53 +00:00
florian
04464b8622 * do not create an fpc_zeromem node if size=0
git-svn-id: trunk@27224 -
2014-03-21 16:34:35 +00:00