Commit Graph

588 Commits

Author SHA1 Message Date
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
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
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
florian
d4968e054b + arm: tsettings.instructionset
* the selected instruction set is now independent from the cpu type: e.g. armv7-a can perfectly execute thumb(2) code

git-svn-id: trunk@25370 -
2013-08-25 21:56:12 +00:00
sergei
ac2006898f * Mark procedures with shortstring value parameters as non-leaf, because such parameters generate a call (to fpc_shortstr_assign).
git-svn-id: trunk@25082 -
2013-07-11 08:21:45 +00:00
svenbarth
fc79d47b09 Fix for Mantis #24651. Allow pointer comparison for internal expressions (in this case check for valid VMT).
nadd.pas, taddnode:
  + add new constructor "create_internal" which adds "nf_internal" to the node's "flags"
  * pass_typecheck_internal: allow pointer comparisons other than "=" and "<>" for nodes which have "nf_internal" set
psub.pas, generate_bodyentry_block:
  * create the addnode using "create_internal" instead of "create" to allow the pointer comparison

+ added test 

git-svn-id: trunk@25069 -
2013-07-09 08:04:11 +00:00
sergei
1419a12865 - Removed MIPS-specific code which has been copied to TMIPSProcinfo.set_first_temp_offset in r23885.
git-svn-id: trunk@24963 -
2013-06-24 12:02:17 +00:00
sergei
4e873d0561 + Determine early (before pass 2) whether managed parameters/locals/temps will cause the procedure to reference RTTI labels and, therefore, need GOT.
+ trttinode also sets pi_needs_got flag.

git-svn-id: trunk@24767 -
2013-06-02 13:09:47 +00:00
Jonas Maebe
a1bc04bbb3 * don't omit stack frame generation when generating gprof information, as
mcount expects the frame pointer to be valid

git-svn-id: trunk@24642 -
2013-05-30 13:43:51 +00:00
florian
c087d97b96 * typo fixed
git-svn-id: trunk@24431 -
2013-05-04 19:37:34 +00:00
florian
0e41df598e * merge i8086 branch by Nikolay Nikolov
git-svn-id: trunk@24324 -
2013-04-25 20:23:51 +00:00
florian
52070e26e1 * arm thumb uses always the stack pointer as frame pointer
git-svn-id: trunk@24192 -
2013-04-07 21:00:58 +00:00
florian
b231c049c9 * arm thumb knows only positively growing stacks
git-svn-id: trunk@24000 -
2013-03-25 17:56:13 +00:00
nickysn
30d661734c + enable tprocdef.fpu_used for i8086 also
git-svn-id: branches/i8086@23835 -
2013-03-14 16:33:37 +00:00
florian
8c24a85462 * turn off stack frame stripping for i8086 for now, it cannot do sp relative addressing
git-svn-id: branches/i8086@23783 -
2013-03-10 18:53:49 +00:00
sergei
2caa05ccd1 * Make Win64 SEH support enabled by default. If necessary to disable, compiler should be cycled with OPT=-dDISABLE_WIN64_SEH. Mantis #24012.
git-svn-id: trunk@23732 -
2013-03-08 16:58:05 +00:00
florian
63f6afffd5 + make empty proc. removal switchable by removeemptyprocs
git-svn-id: trunk@23621 -
2013-02-14 21:40:04 +00:00
svenbarth
344571cb4e Added support for type helpers. In non Delphi modes they use "type helper" and in mode Delphi they use "record helper". They can also be used on constants.
symconst.pas:
  + extend "thelpertype" by "ht_type" which tells the code in "pdecobj.parse_extended_type" that a type helper declaration has been parsed
node.pas:
  + add a constant which identifies all constant node types
ptype.pas:
  + read_named_type: add a parameter "hadtypetoken" to tell the code whether a "type" token had been parsed before
  + read_named_type: if an identifier "helper" is parsed we need to check whether "hadtypetoken" is true and the modeswitch "m_class" is set, but the "m_delphi" one is not; in that case we have a "type helper" declaration
pgenutil.pas, generate_specialization:
  * adjust call to read_named_type
pdecl.pas, types_dec:
  * adjust call to read_named_type

pdecobj.pas:
  * parse_extended_type: extend for correct handling of primitive types (includes Delphi compatible handling as well) and reject types that are explicitly not allowed
  * method_dec: require "static" for class methods in type helpers
  * method_doc: allow constructors for type helpers as well
paramgr.pas, tparamanager:
  * set_common_funcretloc_info: handle type helper constructors like record constructors
  * handle_common_ret_in_param: the "self" value of a type helper constructor is also returned in a parameter
pexpr.pas:
  + add a function to postfixoperators which tries to find and apply a type helper for a given type
  * postfixoperators: try to apply type helpers for ordinal constants
  * postfixoperators: use the correct string type for string constants
  * postfixoperators: try to apply type helpers for enum constants
  * postfixoperators: try to apply type helpers for arrays
  * postfixoperators: try to apply type helpers for Variant
  * postfixoperators: try to apply type helpers for pointer types
  * postfixoperators: try to apply type helpers for other types
  * factor: check postfixoperators after _REALNUMBER, _CCHAR, _CWCHAR, _TRUE and _FALSE
  * factor: also check postfixoperators if a _POINT follows a _NIL

symdef.pas, tdefawaresymtablestack.addhelpers:
  * use "generate_objectpascal_helper_key" to generate the key
symtable.pas:
  + add function to generate the key value for the map of extended types using the extended def
  * adjust "search_last_objectpascal_helper" and "search_objectpascal_helper" to handle primitive types as well
  * use the new "generate_objectpascal_helper_key" function to generate the key

pparautl.pas:
  * insert_self_and_vmt_para: don't insert the $vmt symbol for record or type helpers (ToDo: check whether class helpers really need the symbol as well)
  * insert_self_and_vmt_para: pass "self" as var parameter for type helpers as well
psub.pas, generate_bodyentry_block: 
  * also allow type helpers for constructor methods
ncal.pas, tcallnode.gen_self_tree:
  * also use a temp variable for type helper constructors
ncgcal.pas, tcgcallnode.secondcallparan:
  * allow Pointers to be passed as address param if it is the Self value of a type helper extending a pointer type
  * correctly handle the location in case of type helper constructors

+ add tests

git-svn-id: trunk@23580 -
2013-02-06 09:49:35 +00:00
Jonas Maebe
9cbff6f5a6 + support for record constructors for the JVM target
git-svn-id: trunk@23510 -
2013-01-24 09:45:12 +00:00
paul
e9615716c1 compiler: allow constructors in helpers for records
git-svn-id: trunk@23407 -
2013-01-16 13:47:22 +00:00
paul
51825b6f2e compiler: change ret_in_param to accept tabstractprocdef instead of tproccalloption to allow check more options (required for record constructor implementation)
git-svn-id: trunk@23394 -
2013-01-16 01:14:23 +00:00
paul
97d7a4ff50 compiler: fix indentation
git-svn-id: trunk@23346 -
2013-01-09 01:26:46 +00:00
florian
fce9e953b4 + nested exit support
git-svn-id: trunk@23309 -
2013-01-04 19:09:04 +00:00
florian
4d6471fef6 * get rid of calls to empty procedures having parameters without side effect
git-svn-id: trunk@23274 -
2013-01-01 15:58:05 +00:00
pierre
fcaff0489c * psub.pas : translate tregister for registerhi also
(avoids imaginary register number in "# Var I in register .." assembler comments.
  * dbgdwarf.pas : Support register variables as register pairs.
      Does not yet handle case of changing registers.
  * symsym.pas : add currentregloc field to tabstractnormalvarsym class,
     to be able to track changing registers used for a given variable.
  * aasmtai.pas : Update currentregloc field of tai_varloc.create sym parameter.
  * ncgutil.pas : Only generate a tai_varloc if the new registers are different for the variable.

git-svn-id: trunk@22508 -
2012-10-01 14:21:13 +00:00
florian
f25f44605e - get rid of m_all, use a set instead for tokens, this allows to disable/enable tokens depending on the language mode
git-svn-id: trunk@22506 -
2012-09-30 21:03:35 +00:00
pierre
42586baa34 Use SUPPORT_SAFECALL conditional
git-svn-id: trunk@22488 -
2012-09-27 15:57:40 +00:00
florian
ca5fabda6d * cleanup some unused units from uses clauses
git-svn-id: trunk@22433 -
2012-09-21 18:53:46 +00:00
pierre
4f810f0918 free final_asmnode if not used to avoid memory leak
git-svn-id: trunk@22423 -
2012-09-19 07:25:29 +00:00