Commit Graph

638 Commits

Author SHA1 Message Date
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
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
Jonas Maebe
62784ef902 * copy the vmt_entry node in tcallnode.dogetcopy (mantis #28313)
o mention why it doesn't have to be compared in tcallnode.docompare

git-svn-id: trunk@31071 -
2015-06-16 21:24: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
0eab091e1a * factored symansistr-define-conditional handling of fforcedprocname into
a property

git-svn-id: trunk@30944 -
2015-05-31 16:50:30 +00:00
Jonas Maebe
ca5addff8e * fixed memory leaks introduced in r30908
git-svn-id: trunk@30911 -
2015-05-25 15:10:16 +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
Jonas Maebe
6c3f1c3722 * stop tcallnode.pass_1 after we've detected a direct call to a helper/
category method, as this may lead to an internalerror later on after
    the following commits

git-svn-id: trunk@30907 -
2015-05-25 12:55:37 +00:00
Jonas Maebe
f51b11e969 * implemented tcallnode.create_procvar on top of tcallnode.create
git-svn-id: trunk@30906 -
2015-05-25 12:55:34 +00:00
Jonas Maebe
5bb89cc2f0 * keep track of the reason why a loadparentfpnode has been created: to
load a value from a nested context, or to pass a context to a nested
    routine. In case a target uses both the stack and frame pointer, this
    difference can matter.

git-svn-id: trunk@29937 -
2015-02-23 22:53:59 +00:00
Jonas Maebe
f69d2fe61d * AArch64 doesn't use *stret routines for Objective-C dispatching, because it
doesn't need special code for returning a struct by reference

git-svn-id: trunk@29936 -
2015-02-23 22:53:56 +00:00
Jonas Maebe
edb3124ae8 * copy arrays passed by value to cdecl routines on the callee side even on
platforms that normally must copy value parameters on the caller side,
    because
   o if we copy them on the caller side, then the behaviour will be different
     compared to other platforms if the called routine is implemented in C
     (since they are passed by reference, changes to the array contents will
      be visible on other platforms, while they wouldn't be visible if the
      copy is made on the caller side)
   o if we don't copy them on the caller nor on the callee side, then behaviour
     will be different compared to other platforms if the called routine is
     implemented in Pascal and modifies the array (since then changes won't be
     visible on the caller side, except on platforms that normally perform
     the copy on the caller side)

git-svn-id: trunk@29873 -
2015-02-23 22:50:29 +00:00
Jonas Maebe
6e12ad817f * don't make copies of arrays passed as value parameters to cdecl routines
(since C compilers don't copy such arrays either, as they're implciitly
     pointers)

git-svn-id: trunk@29871 -
2015-02-23 22:50:23 +00:00
Jonas Maebe
c6ba0bb6fb + support for targets that require by-reference value parameters to be
be copied on the caller instead of callee side
   o mark Darwin/Aarch64 as such a target (any AArch64 target will be like
     that normally, as its ABI specifies this behaviour)
   o don't mark by-reference value parameters on such targets as
     vo_has_local_copy, since a) they don't have one (the copy is on the
     caller side), and b) this ensures that all code handling such
     parameters automatically knows that they are still by reference
     after the init code has run
   o when making the copies on the caller side, don't increase the
     reference count for managed types except for variants, just like
     is done when making the copies on the callee side. This is because
     the reference count increasing code on the callee side only runs
     for non-assembler functions, and we cannot know 100% certain on the
     caller side whether the called function is assembler or not (e.g. in
     case of externally declared functions)
   o maybe over time we can reuse the Pascal code in
     tcallparanode.copy_value_by_ref_para to replace the equivalent code
     in hlcgobj and ncgutil also on the caller side for other targets

git-svn-id: trunk@29870 -
2015-02-23 22:50:20 +00:00
Jonas Maebe
aae879d28a * also set aktcallnode during tcallnode.pass_1, so that the callparanode
pass_1 code can make use of it

git-svn-id: trunk@29818 -
2015-02-23 22:47:41 +00:00
Jonas Maebe
863e81315e * changed goto usage in tcallnode.pass_typecheck into try/finally (and at
the same time solved some issues where "exit" instead of "goto errorexit"
    was used)

git-svn-id: trunk@29817 -
2015-02-23 22:47:38 +00:00
florian
d6bfb29313 * clean usercode_entry flag from outer block when copying a subroutine node tree for inlining, enables sometimes better inlining
git-svn-id: trunk@29627 -
2015-02-04 21:18:04 +00:00
florian
42020c8bb8 * when passing a parameter by var/out, its address leaves the current scope so the compiler has to take care of this
* when getting rid of temps. of inline parameters, take care if somewhere an alias of the variable might exist, resolves #24796 and #26534

git-svn-id: trunk@29616 -
2015-02-03 21:05:39 +00:00
Jonas Maebe
eb419b58c5 - disable inlining of routines that contain a call to a C-style varargs
function, as we don't save/restore the synthetic paravarsyms that
    are created for this

git-svn-id: trunk@29584 -
2015-01-30 19:31:22 +00:00
Jonas Maebe
146e3bcb9e * synchronised with trunk till r29513
git-svn-id: branches/blocks@29516 -
2015-01-21 23:28:34 +00:00
Jonas Maebe
e97f31541e - reverted partial commit of merge
git-svn-id: branches/blocks@29515 -
2015-01-21 23:24:37 +00:00
Jonas Maebe
a76bbf363d * synchronised with trunk r29513
git-svn-id: branches/blocks@29514 -
2015-01-21 23:18:29 +00:00
florian
681c1afe6c * limit inlined expansion and exponential code grow, resolves #23862
git-svn-id: trunk@29495 -
2015-01-17 13:52:41 +00:00
florian
ccb01d6196 * allow subtraction/addition of internally generated nodes, resolves #27256
git-svn-id: trunk@29456 -
2015-01-12 20:56:17 +00:00