Commit Graph

573 Commits

Author SHA1 Message Date
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
Jonas Maebe
44fa475fe4 * fixed -dTEST_WIN64_SEH after r22337 (mantis #22885)
git-svn-id: trunk@22412 -
2012-09-17 11:22:18 +00:00
florian
be2003a404 * output register pairs correctly
git-svn-id: trunk@22338 -
2012-09-06 15:11:46 +00:00
Jonas Maebe
288d1ec74a * support referencing "result" in nostackframe pure assembler routines if
the result location is a simple location (a single register/reference)
    (mantis #22490)
  * print an error when accessing "result" in a nostack pure assembler routine
    if the result location is not simple

git-svn-id: trunk@22166 -
2012-08-21 19:51:40 +00:00
Jonas Maebe
5e93f6b70f - reverted r1733, which caused all local procedures to become global in case
PIC was used. This was probably a workaround for a code generator bug,
    which is no longer required

git-svn-id: trunk@21921 -
2012-07-16 15:22:14 +00:00
Jonas Maebe
07ebc51b6c * always store generics token streams in little endian, so we don't have to
keep a separate field for each tstoreddef that records whether the
    endianness needs to be swapped

git-svn-id: trunk@21914 -
2012-07-15 16:09:14 +00:00
pierre
bc0c94c204 fpcdefs.inc: Set fpc_compiler_has_fixup_jmps for powerpcXX and mips CPUs.
psub.pas: Use new fpc_compiler_has_fixup_jmps conditional.
 mips/aasmcpu.pas: MIPS specific fixup_jmps function,
   The insttruction distance calculation is not exact as
   some pseudo-instruction can be expanded to a variable number of real instructions
   real calculation would only be possible if we first 
   convert pseudo-instuctions to real instructions before calling fixup_jmps.

 ncgutil.pas: Revert commit r21791
 ncgcon.pas: Revert commit r21786
 mips/cgcpu.pas: Partial revert of commit r21798, no need to always use A_J,
 as fixup_jmps now handles out of range branches.

git-svn-id: trunk@21822 -
2012-07-09 08:59:13 +00:00
svenbarth
7dfaec7a05 Fix for Mantis #21457
* pdecsub.pas, parse_proc_dec & pdecobj.pas, constructor_head: 
    correctly set the return type of the constructor of a class helper to the extended def
* psub.pas, generate_bodyentry_block:
    call the NEWINSTANCE of the extended class for constructors of class helpers

git-svn-id: trunk@21582 -
2012-06-12 09:42:22 +00:00
sergei
e0deb4cc99 * Fixed building with OPT="-dTEST_WIN64_SEH -O2" after r21454. It is not yet possible to omit rbp-based stack frames if using SEH on Win64.
git-svn-id: trunk@21556 -
2012-06-08 18:29:10 +00:00
florian
52372a88ca * arm and x86-64 can do exception handling without a framepointer based stack
git-svn-id: trunk@21454 -
2012-06-01 21:32:23 +00:00
Jonas Maebe
baa8fa39a8 * converted code to trash variables (-gt) to operate at the node tree level,
and also use this code to trash local variables in inlined routines
   o fixes mantis #22088
   o makes it possible to also implement it for the jvm target in the future

git-svn-id: trunk@21393 -
2012-05-26 11:32:39 +00:00
florian
6c8eed21c4 + implement auto inlining (-Ooautoinline)
+ implement trashing of local variables if subroutine is inlined
* fix some errors releated to interproc. gotos and inlining
+ node_count function
* inline cannot be used with iochecking and safecall calling conventions
* track inherited usage
* don't inline if inherited is used

git-svn-id: trunk@21335 -
2012-05-19 13:30:02 +00:00
florian
25e82bb1af * fix stack frame generation on mips(el)
git-svn-id: trunk@21121 -
2012-04-29 21:29:06 +00:00
sergei
7f96fee752 + Added a comment on tcgprocinfo.generate_exceptfilter operation.
git-svn-id: trunk@21111 -
2012-04-29 10:34:29 +00:00
sergei
a85bb08a74 * Save/restore high-level code generator when processing exception filters, fixes building in Win64 with -dTEST_WIN64_SEH, Mantis #21879.
git-svn-id: trunk@21110 -
2012-04-29 07:35:19 +00:00
Jonas Maebe
aee5380ae0 * merged trunk up to r20882
o support for the new codepage-aware ansistrings in the jvm branch
   o empty ansistrings are now always represented by a nil pointer rather than
     by an empty string, because an empty string also has a code page which
     can confuse code (although this will make ansistrings harder to use
     in Java code)
   o more string helpers code shared between the general and jvm rtl
   o support for indexbyte/word in the jvm rtl (warning: first parameter
     is an open array rather than an untyped parameter there, so
     indexchar(pcharvar^,10,0) will be equivalent to
     indexchar[pcharvar^],10,0) there, which is different from what is
     intended; changing it to an untyped parameter wouldn't help though)
   o default() support is not yet complete
   o calling fpcres is currently broken due to limitations in
     sysutils.executeprocess() regarding handling unix quoting and
     the compiler using the same command lines for scripts and directly
     calling external programs
   o compiling the Java compiler currently requires adding ALLOW_WARNINGS=1
     to the make command line

git-svn-id: branches/jvmbackend@20887 -
2012-04-15 15:54:10 +00:00