Commit Graph

637 Commits

Author SHA1 Message Date
florian
e24449bcfd * if sub nodes of a commutative node contain conditionally executed nodes, these sub nodes might not be swapped
as this might result in some nodes not being executed, like temp. create nodes with init. code, see e.g. issue #34653, resolves #34653

git-svn-id: trunk@40934 -
2019-01-20 12:55:20 +00:00
Jonas Maebe
c9a7afe053 * in constructors, free the temp holding self only after loading the function
result, as self is the function result there (follow up to 40501)

git-svn-id: trunk@40635 -
2018-12-24 22:10:09 +00:00
Jonas Maebe
3b7efb5123 * only free the temp holding the function result after we've loaded it into
the function return register (so we won't load from an already freed
    temp once we emit lifetime info for temps on LLVM)

git-svn-id: trunk@40501 -
2018-12-08 15:31:48 +00:00
yury
93d672bf16 * aarch64: Fixed loading of a function result which is returned in 4 32-bit MM registers to 2 64-bit int registers. Bug #30329.
git-svn-id: trunk@39953 -
2018-10-17 11:41:34 +00:00
nickysn
55ecc7feff - removed the check for pocall_oldfpccall from ncgutil.gen_save_used_regs and
gen_restore_used_regs. This is now handled by get_saved_registers_int in
  cpupara.

git-svn-id: trunk@38934 -
2018-05-06 12:41:40 +00:00
Jonas Maebe
d69ad8fa41 * removed temppos field again from parameter locations: they're not allocated
by the temp manager of the current procedure

git-svn-id: trunk@38858 -
2018-04-27 19:18:55 +00:00
Jonas Maebe
4686f61002 * keep track of the temp position separately from the offset in references,
so that they can still be freed after the reference has been changed
    (e.g. in case of array indexing or record field accesses) (mantis #33628)

git-svn-id: trunk@38814 -
2018-04-22 17:03:16 +00:00
florian
a66016026b * handle bitpacked booleans more efficiently
git-svn-id: trunk@38509 -
2018-03-12 22:05:34 +00:00
nickysn
ddba821561 * GetNextReg(), used by 16-bit and 8-bit code generators (i8086 and avr) moved
from cpubase unit to a method in the tcg class. The reason for doing that is
  that this is now a standard part of the 16-bit and 8-bit code generators and
  moving to the tcg class allows doing extra checks (not done yet, but for
  example, in the future, we can keep track of whether there was an extra
  register allocated with getintregister and halt with an internalerror in case
  GetNextReg() is called for registers, which weren't allocated as a part of a
  sequence, therefore catching a certain class of 8-bit and 16-bit code
  generator bugs at compile time, instead of generating wrong code).
- removed GetLastReg() from avr's cpubase unit, because it isn't used for
  anything. It might be added to the tcg class, in case it's ever needed, but
  for now I've left it out.
* GetOffsetReg() and GetOffsetReg64() were also moved to the tcg unit.

git-svn-id: trunk@37180 -
2017-09-11 14:53:06 +00:00
florian
a53d6bd6bd * pass the correct size to a_load_cgparaloc_ref in gen_load_cgpara_loc to avoid to overwrite adjacent data
git-svn-id: trunk@36952 -
2017-08-20 15:22:01 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
svenbarth
d149f260fc - remove no longer needed gen_fpc_dummy()
git-svn-id: trunk@35374 -
2017-01-29 22:40:36 +00:00
Jonas Maebe
a1c0d1a1ff * moved exception handling helpers from ncgutil to ncgflw as they are only
used there (could be turned into protected methods if they are ever needed
    by child classes)

git-svn-id: trunk@35143 -
2016-12-16 22:41:28 +00:00
Jonas Maebe
472b5228fe * changed ncgutil.has_alias_name(pd,s) to a method of tprocdef
git-svn-id: trunk@35085 -
2016-12-09 13:39:28 +00:00
Jonas Maebe
a25ebbba3e + added volatility information to all memory references
o separate information for reading and writing, because e.g. in a
     try-block, only the writes to local variables and parameters are
     volatile (they have to be committed immediately in case the next
     instruction causes an exception)
   o for now, only references to absolute memory addresses are marked
     as volatile
   o the volatily information is (should be) properly maintained throughout
     all code generators for all archictures with this patch
   o no optimizers or other compiler infrastructure uses the volatility
     information yet
   o this functionality is not (yet) exposed at the language level, it
     is only for internal code generator use right now

git-svn-id: trunk@34996 -
2016-11-27 18:17:37 +00:00
pierre
89c1b68b14 * Delete regvars unit.
This unit was empty unless OLDREGVARS macro was set,
    but this does not compile and no change has been made since 2011.

  * Remove regvars from all _USES clauses.

git-svn-id: trunk@34808 -
2016-11-06 14:01:39 +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
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
fb0f4394c0 * don't set varsym.localloc anymore in gen_alloc_regvar(): in most cases
initialloc was already set afterwards, now it's also done in the final
    case (and allocating the initial location should be different from
    setting the current location)

git-svn-id: trunk@34085 -
2016-07-08 07:46:48 +00:00
Jonas Maebe
cd5817a689 * also emit a tai_varloc() when regvars are initially assigned
o removed separate writing of the local variable/parameter location from
     psub, as that is now triggered by thise tai_varloc

git-svn-id: trunk@34084 -
2016-07-08 07:46:45 +00:00
Jonas Maebe
db77aad2cc * support LOC_MMREGISTER for paralocs when loading 128 bit function results
into integer registers (a record that consists of 4 32 bit floats is
    returned in 2 xmm registers on x86_64) (mantis #30329)

git-svn-id: trunk@34058 -
2016-07-03 21:18:23 +00:00
Jonas Maebe
98ac6c4797 * converted gen_stack_check_call() to the high level code generator
git-svn-id: trunk@33990 -
2016-06-15 18:31:52 +00:00
Károly Balogh
b6242d14ed * use currpara.paraloc[calleeside].def instead of currpara.vardef when copying parameters to local registers in ncgutil. this mimics hlcgobj behavior and fixes parameters passed by reference to be allocated into intregs on m68k. among others, this has a big impact on OOP code, because of self, for example
git-svn-id: trunk@33707 -
2016-05-19 02:39:45 +00:00
pierre
b93928a9aa Fix compilation of mips compiler after rev 33591
git-svn-id: trunk@33609 -
2016-05-02 08:22:43 +00:00
Károly Balogh
56fea8d047 * have regvars in address registers for defs which are address types. improves code with reference bases in regvars on m68k. and also reduces data register pressure.
git-svn-id: trunk@33591 -
2016-05-01 11:33:37 +00:00
svenbarth
557f74cdbd (Note to self: always include the root of the working copy in the commit when dealing with merges -.-)
Merged revision(s) 28793, 28903, 31951 from branches/svenbarth/packages:
psub.pas, read_proc:
  * don't generate assembler symbols for compiler internal code
........
Ensure that unneeded initialization/finalization procedures don't leave assembler symbols.

ncgutil.pas:
  + new function release_proc_symbol which removes all assembler symbols of a procdef
pmodules.pas, proc_unit:
  * if the initialization or finalization procedure is empty also remove their assembler symbols so they are exported
........
Ensure that readonly sections that need relocations are indeed declared as such.
Thanks to Jonas for this.

ncgvmt.pas, TVMTWriter:
  * writeinterfaceids: use sec_rodata instead of sec_rodata_norel

........

git-svn-id: trunk@32982 -
2016-01-22 16:58:33 +00:00
Jonas Maebe
da696057ab * converted register_maybe_adjust_setbase() to the high level code generator
git-svn-id: trunk@32591 -
2015-12-05 18:03:37 +00:00
Jeppe Johansen
14020b044c Fix bug in gen_load_cgpara_loc for 64bit registers on 8bit architectures.
Added a workaround in a_load_const_reg to allow compilation for AVR.

git-svn-id: trunk@32090 -
2015-10-18 11:36:58 +00:00
yury
d8542bf778 * Do not remove a ret-in-param value from the stack by callee for safecall function when safecall exception check is enabled for a target.
The bug has been triggered only with the following conditions: 
    - tf_safecall_exceptions, tf_safecall_clearstack in target flags;
    - fixed stack is used.
  Since only the i386-android target meets these conditions atm, the bug has been unnoticed.

git-svn-id: trunk@32005 -
2015-10-10 20:40:33 +00:00
yury
11a9ff4a43 * Removed unused vars for mipsel compiler.
git-svn-id: trunk@31745 -
2015-09-17 15:46:30 +00:00
yury
432248cbf1 * Removed lot of unused vars.
git-svn-id: trunk@31732 -
2015-09-17 12:48:58 +00:00
Jonas Maebe
0fc1fd6ac1 * replaced current_procinfo.currtrue/falselabel with storing the true/false
labels of LOC_JUMP in the node's location. This generates some extra jumps
    for short circuit boolean and/or-expressions if optimizations are off, but
    with optimisations enabled the generated code is the same (except for JVM
    because the jump threading optimisation isn't enabled there yet).

git-svn-id: trunk@31431 -
2015-08-27 18:28:57 +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
b39bc5888a * moved the import name handling entirely to hlcgobj so it can be
overridden

git-svn-id: trunk@31053 -
2015-06-13 22:48:17 +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
32501834c9 * fixed memory leaks due to missing frees of temporary tcgpara locations
git-svn-id: trunk@30854 -
2015-05-14 14:42:35 +00:00
florian
f95d5e0de6 + support 8 locations in gen_load_cgpara_loc
git-svn-id: trunk@30534 -
2015-04-10 20:33:11 +00:00
Jonas Maebe
8fc562a2f8 * fixed def used for saving the result of fpc_setjmp() after r30497, fixes
cycle for x86-86 (mantis #27812)

git-svn-id: trunk@30506 -
2015-04-09 07:36:45 +00:00
Jonas Maebe
a674804869 * made fpc_setjmp() code generic and fixed it for llvm
git-svn-id: trunk@30497 -
2015-04-08 19:08:30 +00:00
Jonas Maebe
61e4a1b811 + added tasmlist parameter to getintparaloc() (needed for llvm)
git-svn-id: trunk@30429 -
2015-04-04 14:29:16 +00:00
Jonas Maebe
bd203a5b57 * synchronised with trunk till r30240
git-svn-id: branches/hlcgllvm@30241 -
2015-03-15 19:44:58 +00:00
florian
f07969245b * fix warning about uninitialized variable
git-svn-id: trunk@30240 -
2015-03-15 17:10:01 +00:00
Jonas Maebe
0c394eb6f4 * ensure we don't call a_load_cgparaloc_anyreg() to move an fpu register
into an integer register

git-svn-id: trunk@30227 -
2015-03-14 18:36:57 +00:00
Jonas Maebe
fc21845686 * fixed the allocation of R12 on ppc32/ppc64 when used to hold the value of
the stack pointer during the prolog. This was done previously in
    tcg.g_proc_entry(), but that routine is called after register allocation
    and hence has no influence. Also cleaned up the deallocation of that
    register by moving the previously ifdef'd code to thlcgppcgen
    (mantis #27634)

git-svn-id: trunk@30164 -
2015-03-11 17:49:44 +00:00
Károly Balogh
0021ad714f * fixed some ancient code behind cpu_uses_separate_address_registers define to at least compile again, for some m68k experiment
git-svn-id: trunk@30130 -
2015-03-07 22:11:43 +00:00
Jonas Maebe
67b8aceaee * synchronized with privatetrunk till r30095
git-svn-id: branches/hlcgllvm@30101 -
2015-03-05 20:32:15 +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
2dbfbd40ab * unified hlcg.g_copyvalueparas and ncgutil.copyvalueparas, they have the
same functionality in the mean time

git-svn-id: trunk@29872 -
2015-02-23 22:50:26 +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