Commit Graph

274 Commits

Author SHA1 Message Date
J. Gareth "Curious Kit" Moreton
4378319f87 * Added missing "override" directive for XML node dump routine on TDerefNode 2024-03-26 13:25:46 +00:00
florian
4103b3d180 * formatting 2024-03-02 21:31:21 +01:00
J. Gareth "Curious Kit" Moreton
4736cc2360 * Flags specific to TDerefNode have been moved to their own field 2024-03-02 21:31:21 +01:00
J. Gareth "Curious Kit" Moreton
1bba83cebb * Flags specific to TVecNode have been moved to their own field 2024-03-02 21:31:21 +01:00
Charles Averill
bb2e2f83e9 Add struct field names to subscriptn nodes in parse tree output 2024-01-21 16:39:09 +00:00
florian
7bbd33bcd6 * last commit was not complete, fixed 2024-01-21 15:26:21 +01:00
florian
79f6ee538d * fix compilation on 32 bit hosts 2024-01-21 15:25:36 +01:00
J. Gareth "Curious Kit" Moreton
74625648cf * Vectors of string constants are now simplified into ordinal constants 2024-01-21 11:56:09 +00:00
Jonas Maebe
12bde4e903 WPO: fix dead code detection, and handle procvars
Extend dead code detection to not only look for the main mangled name, but also
for any aliases before deciding that a routine has been dead-stripped.

Assume objects/classes can also be constructed if the address of one of their
constructors or of the TObject.NewInstance class method has been taken.

Resolves #40204
2023-03-24 21:22:18 +01:00
Rika Ichinose
c26f9329b6 Support arrays and classes in compile-time OffsetOf. 2022-07-16 22:12:07 +02:00
florian
43b4b34395 * disallow offsetof trick for types involving implicit dereferences, resolves #39667 partially 2022-04-14 17:06:15 +02:00
florian
62f21ae60d + recurse into multiple subscription nodes when calculating contant @... expressions, resolves #39665 2022-04-13 21:32:06 +02:00
florian
8b24d60df7 * removed accidently committed printnode
git-svn-id: trunk@48464 -
2021-01-31 13:19:55 +00:00
florian
8496690ed0 * additional fix for r48449
git-svn-id: trunk@48461 -
2021-01-30 22:47:38 +00:00
florian
e99827246e * fix type conversion for array indicies if the ordinal ranges of the involved types do not overlap, resolves #38413
git-svn-id: trunk@48449 -
2021-01-28 20:56:15 +00:00
florian
7f07c9f94d + range check enumeration array indicies, range checking is after all a safety mean
git-svn-id: trunk@47652 -
2020-11-30 22:08:04 +00:00
florian
044133fc87 * explicitly convert array indicies to pointer sized integers, so cse
can handle the conversion

git-svn-id: trunk@47150 -
2020-10-21 20:46:28 +00:00
yury
7bffafdf8b * Improved the parentfp optimization to properly handle cases when a nested routine calls other nested routines.
git-svn-id: trunk@45665 -
2020-06-20 18:34:26 +00:00
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