Commit Graph

614 Commits

Author SHA1 Message Date
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
Jonas Maebe
f936a48afa * don't change the forward/interface definition of regular forward/interface
functions whose implementation is declared "external". This results in less
    efficient code (all calls will go through a stub), but it prevents interface
    crc changes (-> no recompilations in case of circular dependencies) and it
    also keeps the interface stable (if the external implementation is changed
    afterwards to another external routine or to a local implementation, the
    mangled name of the routine does not change) (mantis #24121)

git-svn-id: trunk@27213 -
2014-03-20 21:03:07 +00:00
Jonas Maebe
1ac4021178 * moved po_has_inlininginfo from procoptions to procimploptions so that
the availability of the body of a function declared as "inline" no
    longer changes the CRC and hence no longer triggers recompilations
    (mantis #24121)

git-svn-id: trunk@27192 -
2014-03-19 21:53:10 +00:00
Jonas Maebe
e9268a0a14 * synchronised with trunk up till r26975
git-svn-id: branches/hlcgllvm@26976 -
2014-03-06 21:36:58 +00:00
sergei
52af9a2c89 * Changed passing of hidden parameters to constructors of class-style objects: VMT is always passed in the first ('self') parameter, and the second one ('vmt', although this name is now misleading) contains flag specifying the constructor behavior and meaning of 'self'. Together with r26656 this removes methodpointer sharing between two parameter node trees, it becomes possible not to put methodpointer into temp, but use node tree below 'self' parameter to do virtual calls. This also matches behavior of Delphi.
git-svn-id: trunk@26683 -
2014-02-06 12:26:47 +00:00
sergei
a1dfaa54dd * Fixed exception handling in constructors of TP-style objects to correctly handle cases of statically allocated objects (must call destructor but do not free memory) and objects without destructor (must free memory if it was allocated dynamically).
+ Test extended.

git-svn-id: trunk@26676 -
2014-02-05 18:19:13 +00:00
florian
b1f54b2853 * indentation fixed
git-svn-id: trunk@26627 -
2014-01-30 17:34:31 +00:00
florian
fc7dc9e54c * do cse after the init/final code has been inserted, this might enable new cse opportunities
git-svn-id: trunk@26623 -
2014-01-30 17:19:01 +00:00
florian
6e63272ab7 * added missing parenthesis
git-svn-id: trunk@26438 -
2014-01-12 20:17:54 +00:00
nickysn
338d72f564 * extracted the code from psub.translate_registers for generating the name of
the registers from a tlocation to a new function called location_reg2string
+ added support for 16-bit and 8-bit ALUs in location_reg2string

git-svn-id: trunk@26275 -
2013-12-23 22:58:32 +00:00
sergei
6ea9ce1077 * Force managed types to be always returned in parameters, independent of target (primitive types were already handled that way; the patch affects small records with fields of managed types).
* Generating code to finalize result on exception at callee side is no longer necessary.

git-svn-id: trunk@26228 -
2013-12-13 19:54:46 +00:00
florian
99eadb91b3 * run CheckAndWarn to get proper locations for warnings about uninitialized variables
* several fixes to liveness analysis
* get rid of old version defines
+ tests

git-svn-id: trunk@26159 -
2013-12-01 17:01:51 +00:00
Jonas Maebe
044e133067 * override hlcgcpu.create_codegen with hlcgllvm.create_codegen when building
an llvm-targeting compiler

git-svn-id: branches/hlcgllvm@26056 -
2013-11-11 11:16:32 +00:00
florian
8be7cfa05f * check the scope of a variable when checking dfa based uninitialized variables,
dfa is procedure local only so consider only variables of the current scope

git-svn-id: trunk@26016 -
2013-11-10 20:20:38 +00:00
florian
57586b69c7 * implicit try...finally frames are added after dfa so we don't have to take care if the subroutine needs/uses those or not
git-svn-id: trunk@26015 -
2013-11-10 20:20:36 +00:00
florian
3cb747f4a7 * mark the node which is the entry of the user code with a flag
* check for uninitialized variables at the node which is marked as the start of the user code

git-svn-id: trunk@26014 -
2013-11-10 20:20:27 +00:00
florian
cca520abd9 + warn for uninitialized out parameters when dfa is enabled
git-svn-id: trunk@25977 -
2013-11-06 21:11:03 +00:00
florian
1a4584f4c6 + dead store elimination, based on a patch by Jeppe Johansen
git-svn-id: trunk@25962 -
2013-11-06 21:10:26 +00:00
florian
e8787c4b48 + constant propagation, based on a patch by Jeppe Johansen
git-svn-id: trunk@25958 -
2013-11-06 21:10:15 +00:00
svenbarth
68a3827539 Fix for Mantis #21051. Correctly handle specializations that occur during the specialization of methods.
cclasses.pas:
  + TFPHashList & TFPHashObjectList: add WhileEachCall methods that walk the list like ForEachCall does, but uses a while-loop instead of a for-loop
psub.pas, generate_specialization_procs:
  * use WhileEachCall instead of ForEachCall as new defs can be added during the specialization that need to be specialized as well

+ added test

git-svn-id: trunk@25577 -
2013-09-26 08:15:58 +00:00
sergei
7fbcf64608 * Disabled r25488 for ARM targets since it causes crashes there, Mantis #25050.
git-svn-id: trunk@25520 -
2013-09-18 18:55:24 +00:00
sergei
1bd43f0ea1 * Outgoing parameters on stack do not need to inhibit stack frame optimization on targets with fixed stack, because there they do not modify stack pointer in the middle of routine.
git-svn-id: trunk@25488 -
2013-09-15 12:19:11 +00:00