Commit Graph

661 Commits

Author SHA1 Message Date
svenbarth
239d0704ca + add support for type helpers to also extend interface types
git-svn-id: trunk@37023 -
2017-08-21 20:49:20 +00:00
florian
54b5112284 * real constants should be propagated during inline expanding
git-svn-id: trunk@36277 -
2017-05-21 08:34:47 +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
svenbarth
9fc420b546 - remove unused variable
git-svn-id: trunk@36157 -
2017-05-08 19:54:45 +00:00
svenbarth
1aa80f77cb - remove no longer needed global variable allow_array_constructor
git-svn-id: trunk@36103 -
2017-05-04 21:58:14 +00:00
Jonas Maebe
1adde89621 * copy tcallnode.right after copying the callinitblock, as right can be a
temprefnode referring to a temp from the init block (mantis #31421)

git-svn-id: trunk@35478 -
2017-02-24 19:57:40 +00:00
Jonas Maebe
7a57161b6d * in x:=f(..), we only checked for aliasing between x and any parameters of
f(..) before using x directly as function result for f(..) (instead of a
    temp) in case the function result of temp is passed via a hiddel
    call-by-reference parameter. After all, if the result is returned by
    value, then any changes to the function result inside the callee code
    won't affect whatever we will assign the result to until the callee
    has returned. However, this is not true in case of inlining: then
    the replaced function result node will be substituted directly in the
    inlined code -> also check for aliasing in that case.
   o fixes test/toperator5.pp on x86-64

git-svn-id: trunk@34893 -
2016-11-13 16:06:35 +00:00
florian
9bff3ac624 * copy also pushedparasize when copying call nodes, resolves #30923
git-svn-id: trunk@34885 -
2016-11-13 14:46:55 +00:00
florian
cfd38388ca * formatting so lazarus can handle it
git-svn-id: trunk@34737 -
2016-10-16 19:53:12 +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
nickysn
657685a8b6 * use sizesinttype instead of ptrsinttype for the index and high parameter of
open arrays/dynarrays/string-like char arrays, etc.

git-svn-id: trunk@34665 -
2016-10-08 13:56:24 +00:00
Jonas Maebe
66be068365 * set the correct resultdef after converting a dynamic array to an open array
in ncnv
  * handle the fact that we overwrite the open array resultdef of a parameters'
    left node with the original resultdef (i.e., also for dynamic arrays) with
    regards to LLVM type rules
   o use the parameter's formal type (open array) instead of the value's type
     (dynamic array) when loading/using its value, since that's the type the
     value has been converted to
   o this change is not really nice since it adds several independent checks in
     different places, but I can't find a way to nicely unify the code to work
     around this (nor one to get rid of that hack in the first place)

git-svn-id: trunk@34515 -
2016-09-11 17:12:04 +00:00
Jonas Maebe
2f41434284 * fix crash while compiling webtbf/tw14849
git-svn-id: trunk@34454 -
2016-09-08 14:19:02 +00:00
Jonas Maebe
1e506ce1d5 * call beforedestruction if an exception happens in afterconstruction
(mantis #30570)

git-svn-id: trunk@34453 -
2016-09-08 14:18:59 +00:00
Jonas Maebe
388c047c8a - removed the code to check whether a parameter to an inline routine is
also the by-reference function result of a call node, now that this is
    properly checked in the general case (these parameters/function results
    are temp nodes in case of inlined calls)

git-svn-id: trunk@34446 -
2016-09-07 19:37:38 +00:00
Jonas Maebe
5ffd06392d * don't optimize "x:=f(x)" whereby the function result of f() is passed
by reference in case x is a temp (mantis #30572)

git-svn-id: trunk@34445 -
2016-09-07 19:37:35 +00:00
svenbarth
d46c015eb1 * when inlining a function we need to import symbols that were loaded from another unit (or the same unit if the inlined function is from another unit and uses another function in the same unit)
git-svn-id: trunk@34380 -
2016-08-26 13:47:10 +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
8e0ee6599c * store parameters to inline routines that are already in a temp into a new
temp if the original temp was marked as ti_const, and the new parameter
    gets modified (mantis #30015)

git-svn-id: trunk@34289 -
2016-08-12 13:35:56 +00:00
Jonas Maebe
70b1b32722 * let inline parameter temps inherit the "const" property of const
parameters, so we don't apply reference counting to them (mantis #30323)

git-svn-id: trunk@34288 -
2016-08-12 13:35:53 +00:00
Jonas Maebe
a3ca471d32 * factored out all the tests for whether we need to put inline parameters
in temps (no functional changes)

git-svn-id: trunk@34286 -
2016-08-12 13:35:48 +00:00
Jonas Maebe
8d1e8ea203 * fixed indentation in nonlocalvars()
git-svn-id: trunk@34285 -
2016-08-12 13:35:45 +00:00
Jonas Maebe
94f90895a6 * separated call to wrapcomplexinlinepara() from the method that puts
parameters into temps in case it's required for correctness (so we
    can easily "early exit" on failure from the latter) (still no
    functional changes)

git-svn-id: trunk@34284 -
2016-08-12 13:35:42 +00:00
Jonas Maebe
07856870bc * factored out code to determine whether we should put an inline parameter
in a temp or not (no functional changes)

git-svn-id: trunk@34283 -
2016-08-12 13:35:39 +00:00
Jonas Maebe
a0efde8167 * automatically generate necessary indirect symbols when a new assembler
symbol is defined
   o removed all places where AB_INDIRECT symbols were explicitly generated
   o only generate AB_INDIRECT symbols for AT_DATA on systems_indirect_var_imports
   o for some symbols an indirect symbol is always required (because they are
     dereferenced by code in RTL units) -> use new AT_DATA_FORCEINDIRECT type

git-svn-id: trunk@34165 -
2016-07-20 20:53:03 +00:00
Jonas Maebe
1cb8c0d00c * specify the def of assembler level symbols defined via
tasmdata.DefineAsmSymbol() and all routines that call it
   o will be used to automatically generate AB_INDIRECT sybols when
     necessary

git-svn-id: trunk@34164 -
2016-07-20 20:52:59 +00:00
Jonas Maebe
adef9340e6 * converted metadata generation for variant dispatch to high level typed
constant builder

git-svn-id: trunk@34154 -
2016-07-19 14:30:39 +00:00
svenbarth
1bd43d9e37 Fix regressions.
pgenutil.pas:
  + new function maybe_add_pending_specialization() to add a pending specialization if it belongs to the current unit
  * generate_specialization_phase2: don't set up the owner as this leads to problems when using overloaded generic routines and don't add it to the pending list if it's a procdef
ncal.pas, tcallnode:
  * pass_typecheck: if we have a specialization then add it to the pending specializations once we know that we use it

git-svn-id: trunk@33843 -
2016-05-28 22:12:45 +00:00
Jonas Maebe
a29524800f * converted variant dispatch parameter construction from a hacked temp
to a plain record (gets rid of ttemprefnode.create_offset())

git-svn-id: trunk@33725 -
2016-05-20 20:51:41 +00:00
Jonas Maebe
2f81c14ee9 * also print funcretnode for callnodes
git-svn-id: trunk@33610 -
2016-05-02 08:23:08 +00:00
Jonas Maebe
130d9fee91 * don't take the address of element 0 of a dynamic array in
tcallparanode.copy_value_by_ref_para() if the array is empty
    (mantis #30007)

git-svn-id: trunk@33595 -
2016-05-01 12:35:09 +00:00
Jonas Maebe
44682f9f4d * ensure that if we create a temp for the funcretnode in a call node,
the funcretnode field keeps a reference to this temp even after we
    assign it to the call-by-reference return parameter if it is deleted
    by changing it into a normal temp (after which it will be freed when
    the result of the call node is used), because in that case getcopy
    for the callnode must copy this reference after copying the
    tempdeletenode in order to reset tempinfo^.hookoncopy (mantis #29891)

git-svn-id: trunk@33569 -
2016-04-28 20:33:12 +00:00
florian
e1d4d167b4 * hidden high parameter must be of type ptrsinttype, resolves issue #29204
git-svn-id: trunk@32745 -
2015-12-26 20:48:50 +00:00
Jonas Maebe
6fda08705b * moved the generation of th ehidden self parameter from pass_1 to
typecheckpass, because if it's for a nested routine on a platform
    that uses ncgnstmm/ncgnstld, all parentfpstructs (which are
    generated by the typecheckpass of the loadparentfpnode) must be
    generated before pass_1 starts

git-svn-id: trunk@32559 -
2015-12-01 07:54:08 +00:00
nickysn
e6d01eb3b5 * fixed a bug, which caused a function that returns a method pointer (or nested
procdef) to be called twice, when the result of this function is immediately
  called (i.e. not stored in a temp variable).

git-svn-id: trunk@32495 -
2015-11-22 17:21:08 +00:00
nickysn
e325cf1126 * fixed internconsts with two arguments. This allows compile time evaluation of ptr(const,const) on i8086 and i386.
git-svn-id: trunk@32116 -
2015-10-21 16:00:12 +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
svenbarth
2e24d6dffb htypechk.pas:
* extend tcallcandidates by the ability to handle generic procdefs
pgenutil.pas:
  + export check_generic_constraints

git-svn-id: trunk@31760 -
2015-09-18 14:37:47 +00:00
Jonas Maebe
4d0c42ee23 - removed double calling of handlemanagedbyrefpara() for managed targets,
not sure why it didn't cause problems before

git-svn-id: trunk@31668 -
2015-09-13 19:06:29 +00:00
Jonas Maebe
6ffd8f0201 * finalize managed data passed to untyped "out" parameters after r31328
(mantis #2863)

git-svn-id: trunk@31624 -
2015-09-12 23:31:57 +00:00
Jonas Maebe
6be050b729 * fixed finalization of open array out parameters after r31328
git-svn-id: trunk@31623 -
2015-09-12 23:31:53 +00:00
Jonas Maebe
0031e12bf3 * enable the code that determines the complexity of arguments to inline
routines to see through free type conversions (such as type conversions
    inserted for absolute variables, like the 'result' variable)

git-svn-id: trunk@31490 -
2015-09-03 13:36:03 +00:00
Jonas Maebe
ee3f89246c * assume that compilerprocs never capture the addresses of their arguments
git-svn-id: trunk@31489 -
2015-09-03 13:35:59 +00:00
Jonas Maebe
5c5935346a * explain why we may have to search for the uppercase version of a symbol in
tcallnode.createintern()

git-svn-id: trunk@31479 -
2015-09-02 09:54:06 +00:00
Jonas Maebe
e06181749c * guarantee the order of parameter pushes again after r31201 on platforms
that don't use a fixed stack (mantis #28454)
   o moved the code to finalise managed out parameters from ncgcal to ncal,
     and add it to the init code of the call node (so it's evaluated before
     any parameters are processed, ensuring that mantis #28390 stays fixed)

git-svn-id: trunk@31328 -
2015-08-16 12:47:09 +00:00
Jonas Maebe
c95a3f2cf7 * firstpass rather than typecheckpass statements added to the call node
init/done block, as these can be added while pass_1 is ongoing

git-svn-id: trunk@31327 -
2015-08-16 12:47:04 +00:00
Jonas Maebe
9118146bc1 * ensure that managed out-parameters are processed before any other
parameters:
   1) since they are finalised on the caller side, if that same value
      is passed as a value parameter as well and its reference count
      was 1, then the value parameter will contain an invalid pointer
   2) since finalisation involves a call, for optimal code generation
      purposes they should also be evaluated first
    (mantis #28279, #28390)

git-svn-id: trunk@31201 -
2015-07-10 22:04:35 +00:00
Jonas Maebe
945fd4fcf5 * wait till the end of typecheckpass before we load a call context's self
parameter instead of immediately doing it in the constructor of the call
  node, and then only create it if we actually need it.

  It was previously created in the call node constructor because it needs to be
  done before pass_1 (which is where it is actually used) due to pass_1 possibly
  being performed in the context of inlining (and then a wrong self parameter
  may be found, or none at all), and it was done unconditionally because at that
  point we don't know yet whether or not a self parameter will be necessary (as
  we haven't resolved the overloads/procdef yet).

  The problem with this is that if we use the parentfpstruct way of handling
  accesses to outer scope locals/parameters, we need to know all locals/
  parameters that will be accessed from nested routines after typecheckpass,
  otherwise we get crashes. The problem was that if a call to an RTL routine was
  generated by the compiler in a routine nested inside a method during pass_1,
  and this nested routine itself did not access self of the method (so self was
  not added to its parentfpstruct during the typecheckpass), then the
  unconditional reference to self when creating the call caused a compiler
  crash (introduced in r30908)

git-svn-id: trunk@31197 -
2015-07-07 16:34:14 +00:00
Jonas Maebe
7866bae173 * don't crash when trying to access the call_self_node in case it doesn't
exit, but instead give an error (bug introduced in r30950, mantis #28338)

git-svn-id: trunk@31150 -
2015-06-23 21:23:29 +00:00
Jonas Maebe
f40ea04540 * changed getarraydef() into a tarraydef.getreusable() class method
git-svn-id: trunk@31147 -
2015-06-23 21:23:18 +00:00