Commit Graph

133 Commits

Author SHA1 Message Date
florian
be2ab84474 * make actualtargetnode a normal procedure using pointers to node so it can be used also when replacing nodes
+ replacenode to replace nodes inline

git-svn-id: trunk@25013 -
2013-06-29 22:20:30 +00:00
florian
541d67771b * keep managed types in registers if possible. Under certain circumstances (if they don't require init/final code,
e.g. being a const parameter or immutable temp. values), managed types like dyn. arrays, new string types and interfaces can be kept in registers.

git-svn-id: trunk@24953 -
2013-06-23 15:16:30 +00:00
florian
18aaeff1d7 + calculate node complexity for addrnodes and labelnodes
git-svn-id: trunk@24358 -
2013-04-28 16:36:10 +00:00
Jonas Maebe
3cde2b2d84 * fixed check for bitpacked accesses (mantis #24007)
git-svn-id: trunk@23705 -
2013-03-07 15:44:41 +00:00
florian
b43b4bb455 + pseudo procedure aligned: tells the compiler to assume that the given parameter is naturally aligned, counterpart of unaligned
git-svn-id: trunk@23310 -
2013-01-04 19:13:24 +00:00
Jonas Maebe
5929ec5592 * turned getpropaccesslist, add_parameters and add_index_parameter into
methods of tpropertysym (refactoring)
  * turned code to copy the contents of a property into another one
    into a method of tpropertysym (refactoring)

git-svn-id: trunk@22955 -
2012-11-08 20:17:48 +00:00
Jonas Maebe
33f5de990d * fixed indentation
git-svn-id: trunk@22255 -
2012-08-26 21:04:51 +00:00
florian
8c39b1eba8 * document tforeachprocmethod
git-svn-id: trunk@22134 -
2012-08-19 21:18:28 +00:00
florian
3987c82bab * assign a complexity of 2 to float nodes because they usually involve a loading from memory
git-svn-id: trunk@22097 -
2012-08-15 18:28:47 +00:00
florian
41e8da998c * cast raise node only to a tertiary node in foreach, makes adding more tertiary nodes easier
git-svn-id: trunk@22096 -
2012-08-15 18:22:47 +00:00
florian
4d86d25c6c * -O4 switch for optimizations which are correct but which might have unexpected effects
like field reordering (possible problems cracker classes) or using ebp as normal register (broken
      stack traces from dump_stack)
    + niln is also valid in a cse domain
    * parameters passed by reference shall have a complexity >1
    * load nodes from outer scopes shall have a complexity >1
    * better cse debugging
    + more node types added to cse
    * consider parameters passed by reference in cse
    * take care of cse in parameters in simple cases

git-svn-id: trunk@22050 -
2012-08-09 18:58:54 +00:00
florian
89ec13deeb * improved complexity estimation for subscript nodes
git-svn-id: trunk@21984 -
2012-07-29 17:12:54 +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
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
sergei
06192a8137 Values of managed variables are never ever used after decrementing reference on the variable, so there is no point of having a 'decrement reference' as a separate operation. We can always do 'finalize', i.e. clear the contents after decref.
* Modified fpc_ansistr_decr_ref and fpc_widestr_decr_ref so they always zero the pointer passed by reference. Other _decr_ref helpers already do it.
- Removed tcg.g_decrrefcount, calling cg.g_finalize instead.
- finalize_data_node and tcg.g_finalize: removed code generation for zeroing locations, because it is now done by RTL helpers. This further reduces code size.

As a total result of this change and r20118, the size of Lazarus executable is reduced by about 12%.

git-svn-id: trunk@20119 -
2012-01-19 23:11:09 +00:00
florian
6ec0f2549a * factored load node flags out of node flags to gain space
+ implemented iso mode mod, resolves #17685

git-svn-id: trunk@19558 -
2011-10-30 15:14:21 +00:00
sergei
6e23565edf + Initialize/finalize variants using dedicated helpers, produces both smaller (no RTTI loading necessary) and faster (direct path taken) code.
git-svn-id: trunk@19442 -
2011-10-09 20:34:58 +00:00
Jonas Maebe
eb8ba875db * set the node complexity of stringconstn and setconstn to 1 rather than
respectively to 0 and 255 (both generally require one memory load);
    the setconstn complexity of 255 also caused the node cse to replace
    them with temprefn in some cases, which wreaked havoc with the JVM
    practice of determining whether in-expressions can be handled by
    the generic code generator or not

git-svn-id: branches/jvmbackend@18756 -
2011-08-20 08:33:10 +00:00
Jonas Maebe
1c74072748 * moved handle_staticfield_access() from pexpr to nutils so it can
be reused elsewhere
  * moved check_hints() from htypechk to symsym (so it can be called
    from nutils, and it's also more about symbols than about types)

git-svn-id: branches/jvmbackend@18722 -
2011-08-20 08:27:42 +00:00
Jonas Maebe
1302017b21 + support class variables in propaccesslist_to_node() (use regular loadn,
no subscriptn)

git-svn-id: branches/jvmbackend@18613 -
2011-08-20 08:15:10 +00:00
Jonas Maebe
ab5b1fb686 * turned call_fail_node, initialize_data_node, and finalize_data_node from
nutils.pas into virtual class methods of a new tnodeutils class defined
    in ngenutil (global factory: cnodeutils), so they can be overridden by
    architecture-specific implementations (required by the JVM backend)

git-svn-id: branches/jvmbackend@18364 -
2011-08-20 07:52:11 +00:00
florian
4f6a803c29 + might_have_sideeffects, make use of it when optimizing x*x into sqr(x)
git-svn-id: trunk@18271 -
2011-08-19 09:26:40 +00:00
paul
dad8313512 compiler: handle dispinterfaces the same way as com interfaces because they are IDispatch descendants: increment/decrement they references in assignments and parameters passing by _AddRef, _Release
git-svn-id: trunk@16755 -
2011-01-13 03:38:45 +00:00
Jonas Maebe
2222f2c44b * renamed is_class_or_interface_or_dispinterface_or_objc() into
is_implicit_pointer_object_type() to better indicate the purpose of
    that routine, and to avoid having to change its name every time
    a new object type with this property is added

git-svn-id: trunk@16664 -
2010-12-30 15:19:54 +00:00
paul
2af416e145 compiler: move current_objectdef variable to implementation of pdecobj and use explicit type conversion to tobjectdef in other places where current_objectdef is needed
git-svn-id: trunk@16660 -
2010-12-30 07:40:31 +00:00
paul
dc5f5c3f63 compiler: use current_structdef instead of current_objectdef in more places
git-svn-id: trunk@16658 -
2010-12-30 06:46:06 +00:00
paul
56bf42de57 compiler: implement record methods and class methods:
- rename tprocdef._class to tprocdef.struct and change the type from tobjectdef to tabstractrecorddef because methods can belong not to classes only now but to records too
  - replace in many places use of current_objectdef to current_structdef with typcast where is needed
  - add an argument to comp_expr, expr, factor, sub_expr to notify that we are searching type only symbol to solve the problem with records,objects,classes which contains fields with the same name as previosly declared type (like:
  HWND = type Handle;
  rec = record 
    hWnd: HWND;
  end;)
  - disable check in factor_read_id which was made for object that only static fields can be accessed as TObjectType.FieldName outside the object because it makes SizeOf(TObjectType.FieldName) imposible and since the same method was extended to handle records it also breaks a52 package compilation
  - rename tcallcandidates.collect_overloads_in_class to tcallcandidates.collect_overloads_in_struct and addapt the code to handle overloads in records too
  - fix searchsym_type to search also in object ancestors if we found an object symtable
  - add pd_record, pd_notrecord flags to mark procedure modifies which can or can't be used with records. Disallow the next modifiers for records: abstract, dynamic, export, external, far, far16, final, forward, internconst, internproc, interrupt, message, near, override, public, reintroduce, virtual, weakexternal,
Allow the next modifiers for records: static

git-svn-id: branches/paul/extended_records@16526 -
2010-12-09 02:24:46 +00:00
Jonas Maebe
d45ba6c966 * only ordinals and enums can be bitpacked -> don't give an error when
e.g. passing a 3-byte record in a bitpacked array as var-parameter
    (mantis #17862)

git-svn-id: trunk@16317 -
2010-11-08 21:23:55 +00:00
Jonas Maebe
9ab050316e * all accesses that cannot be handled natively by the code generator have
to be handled as a bitpacked access, not just those whose size mod 8 <> 0
    (bug reported by Willibald Krenn on fpc-devel, and mantis #17715)

git-svn-id: trunk@16227 -
2010-10-26 17:17:28 +00:00
Jonas Maebe
94d976bc87 * when simplifying ordinal expressions during inlining, keep the resultdef
that was set during the typecheck pass because typeconversion nodes
    may have been optimised away previously and sometimes the resultdef is
    important (e.g. for the value of callparanodes) (mantis #17458)

git-svn-id: trunk@16101 -
2010-10-07 15:08:52 +00:00
mazen
b127fc154a * Fixed spell error revealed by lintian.
git-svn-id: trunk@16094 -
2010-10-06 20:33:57 +00:00
florian
7199ac4ad7 + apply cse on load parent frame pointer nodes
git-svn-id: trunk@16055 -
2010-09-27 20:54:34 +00:00
Jonas Maebe
7f489635da * disabled maybe_call_procvar() again for macpas mode, because it breaks
CodeWarrior compatibility in a more prominent way than failure to
    compile webtbs/tw17379a.pp (-> added %knowncompileerror)

git-svn-id: trunk@15976 -
2010-09-13 20:14:27 +00:00
Jonas Maebe
c43fda1fe1 * enabled maybe_call_procvar() also for macpas mode (calls procvars that
don't have any parameters in most expressions, rather than using them
    as the procvar itself) -> replaced procvar<>nil with assigned(procvar)
    in test/tmacprocvar.pp to keep it compiling (otherwise it now called
    the procvar); necessary in combination with the next fix to compile
    webtbs/tw17379a.pp
  * automatically disambiguate the use of the function name when used as a
    parameter in macpas mode (if the formal parameter type is a procvar
    type then interpret it as the current function definition, otherwise
    as the current function result) (mantis #17379)

git-svn-id: trunk@15971 -
2010-09-12 16:03:00 +00:00
pierre
11654d5f8c * nflw.pas: Add lnf_simplify_processing loopflag value.
* nutils.pas: Adapt dosimplify to handle loop nodes so that the condition
  is simplified before any of the possible alternatives to avoid compilation
  failures as was appearing for a while on 64-bit compiler if DEBUG=1 was used.

git-svn-id: trunk@15848 -
2010-08-18 16:08:30 +00:00
pierre
874e69bcf8 * revert wrong commits
git-svn-id: trunk@15762 -
2010-08-10 11:33:38 +00:00
pierre
d27278faac * Add external linker possibility for windows x86_64 compiler
git-svn-id: trunk@15761 -
2010-08-10 11:28:31 +00:00
Jonas Maebe
57bd6d2685 + merged nestedprocvars branch
+ support for nested procedural variables:
    o activate using {$modeswitch nestedprocvars} (compatible with all
      regular syntax modes, enabled by default for MacPas mode)
    o activating this mode switch changes the way the frame pointer is
      passed to nested routines into the same way that Delphi uses (always
      passed via the stack, and if necessary removed from the stack by
      the caller) -- Todo: possibly also allow using this parameter
      passing convention without enabling nested procvars, maybe even
      by default in Delphi mode, see mantis #9432
    o both global and nested routines can be passed to/assigned to a
      nested procvar (and called via them). Note that converting global
      *procvars* to nested procvars is intentionally not supported, so
      that this functionality can also be implemented via compile-time
      generated trampolines if necessary (e.g. for LLVM or CIL backends
      as long as they don't support the aforementioned parameter passing
      convention)
    o a nested procvar can both be declared using a Mac/ISO Pascal style
      "inline" type declaration as a parameter type, or as a stand-alone
      type (in the latter case, add "is nested" at the end in analogy to
      "of object" for method pointers -- note that using variables of
      such a type is dangerous, because if you call them once the enclosing
      stack frame no longer exists on the stack, the results are
      undefined; this is however allowed for Metaware Pascal compatibility)

git-svn-id: trunk@15694 -
2010-08-02 22:20:36 +00:00
Jonas Maebe
835899524b + support for Objective-Pascal for-in loops ("fast enumerations")
+ {$modeswitch objectivec2}, which is required before you can use
    Objective-C 2.0 features (such as the above). It automatically
    also implies {$modeswitch objectivec1}
  + genloadfield() helper to load a field of a node representing
    a record/object/class

git-svn-id: trunk@15460 -
2010-06-20 12:38:45 +00:00
Jonas Maebe
efcc6f6440 * also handle statement nodes in has_no_code()
git-svn-id: trunk@14907 -
2010-02-13 20:48:38 +00:00
Jonas Maebe
85984c2d8f * insert proper type conversions when optimising logical operations and
compares by avoiding unnecessary sign extensions (fixes bug reported in
    http://lists.freepascal.org/lists/fpc-pascal/2010-January/023907.html )
  * never throw away int2int type conversions on bitpacked loads, because
    in these cases the proper bits still need to be selected

git-svn-id: trunk@14892 -
2010-02-12 18:13:08 +00:00
florian
69a23fe32a + foreachnode* must also iterate through the new introduced temp. initialization field
git-svn-id: trunk@14764 -
2010-01-21 19:00:42 +00:00
paul
009ef9184d compiler: add dispinterfaces to most of places where something is comparing to usual interfaces since they are not very different things
git-svn-id: trunk@14751 -
2010-01-19 15:24:39 +00:00
florian
fdb67a28ab * node complexity of subscribing increased because it's not only a simple operation to a register but requires a memory access
git-svn-id: trunk@14495 -
2009-12-29 19:43:32 +00:00
paul
b084d70ae4 compiler: cleanup - remove unused variables
git-svn-id: trunk@14493 -
2009-12-29 06:14:52 +00:00
florian
1583907ac4 * improved node complexity calculation: 64 bit operations are more expensive, ord. const nodes on arm can be expensive
git-svn-id: trunk@14486 -
2009-12-27 20:15:30 +00:00
Jonas Maebe
559e284bd0 * merged r13762-14047 from trunk
git-svn-id: branches/objc@14048 -
2009-11-04 15:50:26 +00:00
paul
aa5a5e79ce merge revisions: 13909,13923,13924,13934,13935,13942,13943,13944,13946,13948,13950,13951,13952,13983,13994:
rtl: add enumerators to the basic classes
tests: add enumerators test which compiles and work both by fpc and dcc
compiler: 
  + start for-in loop implementation: implement for-in loop for types (enumerations and ranges), strings, arrays and sets. todo: perform type checking, optimize array and string loops - use temp for expression, implement for-in loop for classes
test:
  + add a simple test for the 'for-in' loop
compiler: fix string for-in loop. now it uses a temp variable to store string expression result
complier: fix for-in array loop. use a temp variable for the loop expression only if loop is not an open array loop
complier: continue enumerator implementation:
  + add operator enumerator which give an ability to add enumerator for an existent type (for example to override builtin string enumerator)
  + add class enumerator support via delphi compatible GetEnumerator method + enumerator class/object template (function MoveNext: Boolean; property Current)
  + tests
compiler: fix for-in loop for arrays. delphi does not copy arrays to a temp variable and it is possible to change array during loop. + test
compiler: add reference for the enumerator operator when it is used + another test for operator enumerator for a class
compiler: add reference for the enumerator operator when it is used + another test for operator enumerator for a class
compiler: enumerator directive support:
  + allow to mark methods and properties by 'enumerator MoveNext' and 'enumerator Current' modifiers. Parser checks return types and duplicates.
  + prefer *marked* by enumerator directive methods and properties than GetEnumerator and Current builtin symbols
  + increase ppu version
  + test
rtl: add IEnumerator and IEnumerable interfaces declarations
tests: for-in loop tests:
  + add small comment at the top of test program
compiler: allow 'enumerator MoveNext' for the interface function declaration + test
compiler: move all for-in loop helpers to the nflw unit
compiler: don't allow the compiler to choose the non-valid enumerator operator for the for-in loop

git-svn-id: trunk@14008 -
2009-11-02 03:24:48 +00:00
Jonas Maebe
dd937bd32d * don't crash when looking for a local/parasym while current_procinfo is
nil, such as while parsing a property definition (mantis #14849)

git-svn-id: trunk@13958 -
2009-10-26 13:48:58 +00:00