Commit Graph

256 Commits

Author SHA1 Message Date
yury
627fcb4354 * Do not use the LOC_VOID location to indicate unused parameters.
* Added the tprocdef.parentfpsym property. Set parentfpsym.varstate to vs_read instead of using the pio_needs_parentfp flag.
* Replaced tcgcallparanode.push_zero_sized_value_para by tparamanager.has_strict_proc_signature.

git-svn-id: trunk@45454 -
2020-05-21 09:36:40 +00:00
yury
2808873d1b * Reworked the optimization of unused $parentfp for nested routines.
- Do not remove the $parentfp parameter as was done in the previous optimization approach. Instead when $parentfp is unused to the following:
      - On the caller side: Omit passing the value for $parentfp for targets where tcgcallparanode.push_zero_sized_value_para=false (classic CPU targets). 
          Pass 0/nil as $parentfp for targets where tcgcallparanode.push_zero_sized_value_para=true;
      - On the callee side: Prevent allocation of registers/resources for $parentfp.
  - When possible keep $parentfp in a register.
  - Set the pio_nested_access flag in tprocinfo.set_needs_parentfp() to properly handle deep nesting levels;

git-svn-id: trunk@45436 -
2020-05-19 13:17:47 +00:00
yury
40504a6f9d * If a nested procedure does not access its parent's frame pointer, optimize it by removing the hidden $parentfp parameter.
* Improved the tisogoto1.pp test.

git-svn-id: trunk@45292 -
2020-05-06 14:43:49 +00:00
florian
00859420ab * correctly handle reading of class/object pointers in combination with @, resolves #26326
git-svn-id: trunk@43804 -
2019-12-28 17:59:23 +00:00
Jonas Maebe
ac1e0f96bd * replaced tentryfile.get/putsmall/normalset() with a common tget/putset
that expects an open array of byte, and use it for all sets
   o since all sets need to be typecasted to an array type of the appropriate
     size, we'll get a compilation error in case this needs to be done and
     that also tells us at the same time that the ppu version will need to
     be increased
  * enabled {$packset 1} for the compiler, as this is now safe with the above
    changes

git-svn-id: trunk@43407 -
2019-11-06 21:50:19 +00:00
pierre
243c967967 Commit of new debug feature implemented by J. Gareth Moreton
Allows compilation of compiler using -dDEBUG_NODE_XML
  which will generate a NAME-node-dump.xml file for each 
  unit, program or library compiled,
  containing a XML description of the nodes handled during
  compilation of the unit, program or library.

git-svn-id: trunk@42271 -
2019-06-22 14:08:47 +00:00
florian
749c4d4e47 + keep (certain) arrays in registers if they are used with constants indices only
git-svn-id: trunk@42239 -
2019-06-16 21:29:48 +00:00
Jonas Maebe
281b3ad276 * fix case completeness and unreachable code warnings in compiler that would
be introduced by the next commit

git-svn-id: trunk@42046 -
2019-05-12 14:29:03 +00:00
yury
e5c2d13671 * Do not set pi_needs_got in current_procinfo.flags at the node level, since the GOT usage can only be estimated there. Instead set the pi_needs_got flag at places where the GOT register is accessed during the code generation. This eliminates generation of the unneeded initialization of the GOT register and fixes linker errors when the _GLOBAL_OFFSET_TABLE_ symbol is referenced but no actual GOT references are present.
git-svn-id: trunk@41460 -
2019-02-25 13:35:40 +00:00
Jonas Maebe
170ec00348 - removed withnode (was no longer used since a very long time)
git-svn-id: trunk@40777 -
2019-01-05 22:28:37 +00:00
florian
ae8304f657 * set nf_write flag properly for vec. nodes of types with implicit dereferencing
git-svn-id: trunk@40339 -
2018-11-17 15:08:23 +00:00
florian
93c5eae528 * accept dereferences in generics definitions, resolves #33700 properly
git-svn-id: trunk@39447 -
2018-07-13 21:00:33 +00:00
nickysn
e1d0e7572e * i8086 TP7 compatibility fixes, related to obtaining procedure addresses:
o The @ and Addr() operators in TP or Delphi mode can now be applied to both
    near and far procedures and they always produce a CodePointer, regardless of
    the call model of the procedure.
  o Ofs() and Seg() can now also be applied to both near and far procedures.
  o The @ and Addr() operators in non-TP/Delphi modes, as well as the procedure
    name itself in TP/Delphi modes now can be applied to both near and far
    procedures and produce a near or a far procvar.

git-svn-id: trunk@38691 -
2018-04-05 15:09:12 +00:00
nickysn
58ead31f49 * optimized ofs(proc) on i8086, so it only loads the offset in all memory models
git-svn-id: trunk@38682 -
2018-04-04 15:26:47 +00:00
nickysn
6929af07b7 + added flag tcnf_proc_2_procvar_get_offset_only
git-svn-id: trunk@38680 -
2018-04-04 14:48:12 +00:00
nickysn
4a3a64d8f4 + print addrnodeflags in printnodeinfo
git-svn-id: trunk@38678 -
2018-04-04 12:48:52 +00:00
nickysn
109fb279f6 * moved the initialization of the resultdef for labelsyms in the typecheckpass
of taddrnode to a virtual method taddrnode.set_labelsym_resultdef. No
  functional changes.

git-svn-id: trunk@38676 -
2018-04-04 12:09:15 +00:00
nickysn
3318703ece * moved nf_typedaddr to addrnodeflags (anf_typedaddr)
git-svn-id: trunk@38671 -
2018-04-03 16:41:01 +00:00
nickysn
213e61eae5 + introduce the anf_ofs address node flag - indicates that the node was
generated by ofs()

git-svn-id: trunk@38670 -
2018-04-03 15:28:27 +00:00
nickysn
539d4cb68a + introduced taddrnodeflags (empty for now)
git-svn-id: trunk@38667 -
2018-04-03 14:33:41 +00:00
nickysn
c665866517 + introduce the tcnf_proc_2_procvar_2_voidpointer flag (for now it is only set,
but not used)

git-svn-id: trunk@38638 -
2018-03-27 16:15:06 +00:00
nickysn
0119e7afb3 * changed the codepointer type in the i8086 small and compact memory models from
nearpointer to nearcspointer

git-svn-id: trunk@37730 -
2017-12-14 17:36:15 +00:00
Károly Balogh
333316f356 less tab more spaces. no functional change.
git-svn-id: trunk@37317 -
2017-09-25 14:52:39 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
svenbarth
0e7a9ad375 * partial fix for Mantis #30831 (partial, because no exception has been encountered yet): when checking whether the left node of a vmtaddrnode is a generic, don't rely on df_generic, but instead use is_generic which checks for a true generic (the other will also be true if it's merely a structured type declared (or specialized) inside another generic)
+ added test

git-svn-id: trunk@34915 -
2016-11-18 14:43:45 +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
18639304e1 * convert the index for open arrays to ptr(u/s)inttype instead of to
(s/u)inttype (as in r32745)

git-svn-id: trunk@34057 -
2016-07-03 21:18:19 +00:00
Jonas Maebe
996e325175 * converted range checking for open arrays/array of const from the code
generator to the typecheck pass, so that it also works for platforms
    that use the parentfpstruct way to handle accesses to nested frames
    in case the array has been migrated to such a parentfpstruct
   o additionally, the number of comparisons for such range checks
     has been reduced from 3 (for signed indices) or 2 (for unsigned
     indices) to 1 in all cases
   o the range checking code is disabled for the JVM target, as the
     JVM automatically range checks all array accesses itself anyway

git-svn-id: trunk@34034 -
2016-06-30 15:33:47 +00:00
Jonas Maebe
5af40f22e8 * handle enums with a packenum setting that is larger than necessary to store
all of their values, when kept in a bitpacked array, properly via
    pass_typecheck rather than hacking location.size in pass_generate_code:
   o the old fix was incomplete (it didn't handle non-constant indices)
   o the old fix didn't work for llvm (since it uses defs rather than
     location.size)

git-svn-id: trunk@33943 -
2016-06-09 22:00:14 +00:00
Jonas Maebe
7005dec9b4 * equivalent of r32602 for subscriptnodes; couldn't find a test that fails
without this patch, but just like with arrays, writing part of a record
    should mark the record itself as modified

git-svn-id: trunk@33195 -
2016-03-06 15:10:31 +00:00
Jonas Maebe
356a5aff05 * apparently, Darwin/x86-64 also uses an opaque ISA pointer on OS X 10.11
-> assume it is always the case for non-fragile ABI platforms
    (mantis #29667)

git-svn-id: trunk@33112 -
2016-02-22 08:44:00 +00:00
florian
cad29a4e19 * set nf_write flag correctly for subscript nodes, resolves issue #28713
git-svn-id: trunk@32602 -
2015-12-06 19:17:50 +00:00
Jonas Maebe
2778bf55c7 * add "doregister" parameter to torddef.create, and don't register temporary
defs created in the scanner for evaluating compile time expressions, or in
    the code generator for range checking

git-svn-id: trunk@32046 -
2015-10-13 15:59:06 +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
florian
049491a573 + fold the constructs @<record type>(nil^).<field >) and @<record point>(nil)^.<field> used to get the offset of a field into a constant
git-svn-id: trunk@31470 -
2015-08-31 20:03:49 +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
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
703e31512d * moved JVM-specific code of tloadvmtaddrnode.pass_1 to njvmmem
* create separate nodes for Objective-C in tloadvmtaddrnode.pass_1
    instead of implicitly relying on the fact that the Objective-C
    ISA field is at the same offset as the VMT of Object-Pascal
    classes
   o translate the resulting loads of ISA field into direct pointer
     accesses, so that even on non-fragile ABI platforms we don't
     go via an indirection (like clang/gcc)

git-svn-id: trunk@30947 -
2015-05-31 16:50:39 +00:00
Jonas Maebe
37c2d0e60d * use Object_getClass(obj) instead of obj._class to get the class of an
Objective-C instance on AArch64, as the latter helper from the runtime
    is a plain function call rather than an expensive message dispatch,
    and moreover it also works for protocols (the "class" method is part
    of NSObject, and protocols do not support it since there is no single
    root class and hence they may represent an instance of a class that
    does not derive from NSObject)
   o also call it to get the "self" pointer when calling class methods for
     protocols on AArch64 (fixes tobjc22a and tobjc22b on Darwin/AArch64)
   o also call it to get the metaclass of a class on Darwin/AArch64 (fixes
     tobjc25)
  - removed special handling of getting the Objective-C (meta)class for
    non-type nodes on other Darwin platforms, as this is also correctly
    handled by the generic pass_generate_code

git-svn-id: trunk@30018 -
2015-02-26 21:49:08 +00:00
Jonas Maebe
2c6e16e49e * accesses to the ISA pointer are guaranteed to be aligned -> ensure the
code generator knows this

git-svn-id: trunk@29944 -
2015-02-23 22:54:21 +00:00
Jonas Maebe
2340da410c * we cannot directly load the ISA pointer on AArch64, we have to call the
class instance method
   (http://www.sealiesoftware.com/blog/archive/2013/09/24/objc_explain_Non-pointer_isa.html )

git-svn-id: trunk@29943 -
2015-02-23 22:54:18 +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
Jeppe Johansen
7c34dc51a1 Removed vecn nodes from constant pointer address calculations to absolute variables, since only subscripts were being handled leading to problems like those described in issue #17118.
After the removal of vecn these values seem to be handled easily by subsequent optimizations anyway.

git-svn-id: trunk@28978 -
2014-11-03 20:12:19 +00:00
nickysn
235a37fad4 * moved the pass_1 handling of vecnodes for arraydefs to a new virtual method
tvecnode.first_arraydef. This will allow overriding it in the i8086 code
  generator in order to handle huge arrays.

git-svn-id: trunk@28271 -
2014-07-26 16:18:57 +00:00
nickysn
4b1e5f1c9a * in the vecnode, when indexing a pointer[], convert right to
tpointerdef.pointer_arithmetic_int_type instead of sinttype

git-svn-id: trunk@28269 -
2014-07-26 12:24:50 +00:00
nickysn
e6c5c35d65 * tarraydef.create_from_pointer changed to require the actual pointerdef as a
parameter, instead of the element def. This will allow e.g. creating huge
  arrays from huge pointers on i8086.

git-svn-id: trunk@28268 -
2014-07-26 10:39:18 +00:00
nickysn
02dff17ae0 * taddrnode: fixed getting the address of nested procs in tp mode in i8086 far
data memory models

git-svn-id: trunk@27816 -
2014-05-23 22:38:07 +00:00
nickysn
9f4dd78701 * the ifdef i8086 in taddrnode.pass_typecheck removed via using tabstractprocdef.address_type
git-svn-id: trunk@27547 -
2014-04-12 14:49:54 +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
Jonas Maebe
4a79481c51 * isolated segment-related functionality of tabsolutevarsym into i386/i8086-
specific descendent classes and moved the code that deals with this in the
    code generator also to target-specific classes -> only ifdefs left in
    pdecvar

git-svn-id: trunk@27379 -
2014-03-30 15:42:53 +00:00