Commit Graph

157 Commits

Author SHA1 Message Date
florian
3d514856a4 * improve node complexity calculations for type nodes
git-svn-id: trunk@37151 -
2017-09-06 20:34:56 +00:00
nickysn
efc5e339d0 * use an enum instead of integer constants to represent inline numbers
* compinnr.inc include file converted to a unit
* inline number field size stored in ppu increased from byte to longint
* inlines in the parse tree (when written with the -vp option) now printed with
  their enum name, instead of number

git-svn-id: trunk@36174 -
2017-05-10 14:41:43 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
nickysn
b6d05dba9e * mark the sar/shl/shr/rol/ror_assign nodes as having side effects
git-svn-id: trunk@35781 -
2017-04-12 12:17:08 +00:00
nickysn
7b40bdaa6e + treat the new modify-in-place inline nodes as having side effects in
check_for_sideeffect()

git-svn-id: trunk@35774 -
2017-04-11 14:59:38 +00:00
Károly Balogh
5426c11611 marked a few uses of TConstExprInt as const during parameter passing, to avoid a few unnecessary record copying
git-svn-id: trunk@35509 -
2017-03-03 17:29:59 +00:00
florian
9c81e90e08 + extension to iso mode: reset/rewrite can take a file name as a second parameter
git-svn-id: trunk@34726 -
2016-10-16 07:55:08 +00:00
pierre
1e9491550d nutils.pas: Add new procedure:
procedure node_change_local_switch(p : tnode;cs : tlocalswitch;enable : boolean);
    to add/remove cs local switch from all p tnode tree localsettings.

    modify second_prefetch implementation in arm, ppcgen and x86 subdirectories
    to use node_change_local_settings to temporarily disabled
    checkpointer local switch, as prefetch is allowed even on unaccessible addresses.
    (previous code was buggy because I frogot that each node has it own localswitches).

git-svn-id: trunk@34576 -
2016-09-29 21:34:34 +00:00
Jonas Maebe
179c1ab328 * changed ttemp*node.tempinfo^.flags to a private field, and added setters
and getters for the ttemp*node classes instead
   o this will allow descendants to prevent certain flags from being added
     or removed. E.g. for LLVM, certain temps must never be put in registers
     because it cannot typecast a value in a register from a non-record/array
     type to an array type without forcing it to memory (so if that is done
     on an lvalue, the result will be written to the memory temp instead of
     to the register)

git-svn-id: trunk@34358 -
2016-08-21 14:23:09 +00:00
Jonas Maebe
8df1d1f9b8 * fixed compilation of tw15391 with range checking enabled after r34034:
support maybe_call_procvar() on internal block nodes, which return
    their result via the last statement

git-svn-id: trunk@34051 -
2016-07-02 21:09:59 +00:00
Károly Balogh
e0c21b6f8b ARM: avoid some range check errors, while running a compiler compiled with -CR
git-svn-id: trunk@33257 -
2016-03-16 10:08:44 +00:00
nickysn
96f331038d * fixed crash in node_complexity() on the callparan nodes of SetLength() (and
perhaps calaparans of other inline nodes as well?)

git-svn-id: trunk@33256 -
2016-03-15 23:46:46 +00:00
Jonas Maebe
9ea38f4577 * support static fields in nested types in records, by always including
support for nested types when generating an access to a static fied;
    we also always do that when generating the mangled name of a static
    field declaration in symcreat.make_field_static() (mantis #29030)

git-svn-id: trunk@32517 -
2015-11-24 16:04:19 +00:00
florian
27828d41e7 * extended nodes which return true from is_const
git-svn-id: trunk@31472 -
2015-08-31 20:03:52 +00:00
Jonas Maebe
f402b0d7df * changed getpointerdef() into a tpointerdef.getreusable() class method
o allows removing the ugly x86 hacks

git-svn-id: trunk@31144 -
2015-06-22 08:17:49 +00:00
florian
919c539ff5 * better estimation of callparanode complexity
git-svn-id: trunk@31038 -
2015-06-13 16:50:55 +00:00
Jonas Maebe
3f736f6114 * handle the loading of VMT entries at the node level, so it's done in a
type-safe way (for LLVM, and also internal consistency checking between
    the VMT as generated in nobj.pas and ncgvmt.pas)
   o also converted the VMT validity checking to the node level

git-svn-id: trunk@30950 -
2015-05-31 16:50:47 +00:00
Jonas Maebe
caea5ac8be * record a load node for the self/vmt tree of the current routine in the
tcallnode constructor, so that when it's needed later during pass 1,
    its value doesn't depend on the context in which pass 1 is executed
    (e.g. when inlining) (mantis #18121)

git-svn-id: trunk@30908 -
2015-05-25 12:55:40 +00:00
florian
0dfbba86f3 * properly firstpass nodes when inc(...) is converted into ...:=...+x, resolves #27471
git-svn-id: trunk@29742 -
2015-02-17 21:14:45 +00:00
svenbarth
5115c3e680 Fix for Mantis #26481. This is a regression.
nutils.pas, handle_staticfield_access:
  * generics don't have staticvarsyms for their static fieldvarsyms so we need to simulate a non-static access to avoid 1) an exception and 2) incorrect errors that instance methods can't be accessed

+ added tests

git-svn-id: trunk@29484 -
2015-01-16 16:05:53 +00:00
florian
6dd2edb10d * better complexity estimation for some inline nodes
git-svn-id: trunk@27674 -
2014-04-27 14:28:01 +00:00
florian
701cdf8ea2 * fix for #25956: left is not necessarily the array load node when accessing an open array/array of const element
git-svn-id: trunk@27487 -
2014-04-06 15:15:16 +00:00
svenbarth
9d48bc0baf Implement cross unit type overloading of generics. This fixes the regression introduced with revision 25498.
symtable.pas:
  + add new tsymbol_search_flag type which can be passed to various searchsym* routines
  + add support to not call "addsymref"
  + add new searchsym_with_flags function that calls searchsym_maybe_with_symoption
  * adjust searchsym_maybe_with_symoption, searchsym_in_class & searchsym_in_helper to use new flag type instead of Boolean arguments
  * adjust searchsym & searchsym_with_symoption which call the modified functions
nutils.pas, handle_staticfield_access:
  * adjust searchsym_in_class call
pexpr.pas, handle_factor_typenode, postfixoperators, factor:
  * adjust searchsym_in_helper and searchsym_in_class calls
pinline.pas, new_function:
  * adjust searchsym_in_class call
scanner.pas, try_consume_nestedsym:
  * adjust searchsym_in_class call
fmodule.pas, tmodule:
  + add genericdummysyms field which is a TFPHashObjectList that contains TFPObjectList instances per generic dummy that in turn contains tgenericdummysyms instances
pgenutil.pas:
  + add function split_generic_name to split a generic name into non-generic name and count value of type parameters
  + add function resolve_generic_dummysym which tries to use the new genericdummysyms field to find the real symbol of a dummy sym
  * generate_specialization: adjust searchsym_in_class call
  * specialization_init/specialization_done: save/restore genericdummysyms of module
symdef.pas, tdefawaresymtablestack:
  + add new intermediate method pushcommon which is used by both push and pushafter
  + add new intermediate method remove_helpers_and_generics (which calls remove_generics and remove_helpers if necessary)
  * rename removehelpers to remove_helpers
  * rename addhelpers to add_helpers_and_generics and extend it to correctly fill current_module.genericdummysyms
  * call remove_helpers_and_generics from pop instead of remove_helpers
ptype.pas, single_type, read_named_type.expr_type, read_named_type:
  * try to resolve symbols with sp_generic_dummy with resolve_generic_dummysym

+ added test

git-svn-id: trunk@25519 -
2013-09-18 14:28:46 +00:00
florian
5d4a094799 * calculate complexity of exit nodes correctly
git-svn-id: trunk@25245 -
2013-08-11 21:13:20 +00:00
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