Commit Graph

283 Commits

Author SHA1 Message Date
yury
6975437da8 * rgobj: ungetiftemp can't be used here since it frees only temps of the tt_normal type.
git-svn-id: trunk@48407 -
2021-01-24 17:53:42 +00:00
yury
4fa99cff62 * Removed more assigned but unused vars.
git-svn-id: trunk@48392 -
2021-01-24 14:05:21 +00:00
yury
31cd3df783 * Fixed r44145. To test if a constant is declared it is needed to use {$if declared()} instead of {$if defined()}.
git-svn-id: trunk@48389 -
2021-01-24 13:32:11 +00:00
florian
637976e83f * patch by Marģers to unify internal error numbers, resolves #37888
git-svn-id: trunk@47103 -
2020-10-13 19:59:01 +00:00
yury
2f21f5ae93 * Reverted r46836, since it does not work as expected for yet unknown reason.
git-svn-id: trunk@46856 -
2020-09-12 10:13:00 +00:00
yury
b5abefe03e * Moved spilling of registers which have the initial memory location and are used only once to a stage after coalescing is done. This produces a better code.
git-svn-id: trunk@46836 -
2020-09-11 13:32:18 +00:00
yury
c06744b62b * Include stack location of spilled variables in the assembler output.
git-svn-id: trunk@46835 -
2020-09-11 12:36:31 +00:00
yury
60c23daa91 * Fixed the stack parameters optimization (r46776) for big endian CPUs.
git-svn-id: trunk@46794 -
2020-09-07 12:54:20 +00:00
yury
71fcb74e95 * Fixed r46776: With -O3 do not "coalesce" spilled nodes if the initial location is set.
git-svn-id: trunk@46777 -
2020-09-05 18:39:09 +00:00
yury
c2dc342c55 * Use the initial location of stack parameters as a spilling location if spilling is needed. This leads to the following optimizations:
- no spill temp is allocated;
  - no load of a stack parameter to a spill temp;
  - if a stack parameter is used only once do not preload it to a register. The parameter can be accessed directly in the stack if the target CPU supports this.

git-svn-id: trunk@46776 -
2020-09-05 18:20:18 +00:00
yury
acef1e22d3 * Improved output of spilling statistics:
- Do not use count_uses, since weight already represents a usage count of a register.
  - Do not count spills of registers with weight less than 100.

git-svn-id: trunk@46775 -
2020-09-05 16:06:41 +00:00
yury
d9db680937 * In assembly comments include all used registers by a variable for 8/16 bit CPUs.
* Do not add comments about unused varlocs.

git-svn-id: trunk@46296 -
2020-08-06 17:57:30 +00:00
Jonas Maebe
3047ce71bc * fixed LLVM register allocator after r46199
git-svn-id: trunk@46212 -
2020-08-03 20:36:02 +00:00
yury
ff820247c3 * Early during register allocation, spill registers which interfere with all usable real registers.
It is pointless to keep them for further processing. Also it may
  cause endless spilling.
  This can happen when compiling for very constrained CPUs such as
  i8086 where indexed memory access instructions allow only
  few registers as arguments and additionally the calling convention
  provides no general purpose volatile registers.

git-svn-id: trunk@46199 -
2020-08-03 16:46:25 +00:00
yury
601e05f17f * Count only usable real registers.
git-svn-id: trunk@46197 -
2020-08-03 16:24:14 +00:00
yury
0daba07246 * Enhanced the debug output of spilling statistics. Now it includes efficiency of the spilling which is based on
weight and usage count of registers. Range 0-100%. Such statistics are very handy when you modify the register allocator.
  

git-svn-id: trunk@46196 -
2020-08-03 16:18:32 +00:00
yury
4964f5cf76 * Count the number of interferences with real registers.
* Do not coalesce registers 'u' and 'v' if 'u' is the last usable real register available for imaginary register 'n' which also interferences with 'v'.
    This prevents endless spilling in some cases for constrained CPUs such as AVR. Resolves issue #37421.
    Also this reduces the number of spilled registers in some cases and even eliminates spilling completely for some simple routines for i386 and AVR.
* Added a debug output of the number of spilled registers for each routine. This allows to easily compare results after changes in spilling algorithms.

git-svn-id: trunk@45987 -
2020-08-02 11:50:43 +00:00
yury
e6b89c98f5 * Changed tsuperregisterworklist.get() to always return the last item from the list.
* Reversed sort order of simplifyworklist so nodes with most interferences will get their colors first.
    Since degree of nodes in simplifyworklist before sorting is always
    less than the number of usable registers this should not trigger spilling
    and should lead to a better register allocation in some cases.

  After these changes sysutils.o for i386-win32 is 80 bytes less. :)

git-svn-id: trunk@45857 -
2020-07-25 18:29:59 +00:00
yury
c455e942e5 * Try to avoid spilling of an imm register if it contains a value loaded from an already spilled imm register. It likely leads to an endless loop and the register allocation fails.
This fixes the register allocation for i8086 when handling registers for very constrained instructions such as "mov ireg1,[ireg2+ireg3]". 
    Here ireg2 can be only BX or BP. So in most cases only BX is available. When ireg2 is spilled, its value must be loaded to BX only.
    Coloring of the ireg which holds the spilled value must be as early as possible to be able to assign BX to this ireg.
    This fix should also help register allocation for other constrained/old CPUs.

git-svn-id: trunk@45843 -
2020-07-24 14:08:18 +00:00
yury
15f411a332 * Improved r45832.
git-svn-id: trunk@45833 -
2020-07-23 12:52:17 +00:00
yury
80facfa0bf * Fixed indentations of the interference graph.
* Added register names to the interference graph.

git-svn-id: trunk@45832 -
2020-07-23 12:45:40 +00:00
pierre
40a6059143 Modify code to avoid error when compiling with -CriotR option
git-svn-id: trunk@44145 -
2020-02-10 09:37:53 +00:00
florian
96a4cda03b * AVR: fixes pushing and handling of stack passed parameters
git-svn-id: trunk@43983 -
2020-01-19 15:55:21 +00:00
florian
c6659d62f8 * do not join register deallocations/allocations as it makes no use and causes later on trouble in
the assembler optimizer as register allocations are not correct, resolves #33565

git-svn-id: trunk@43384 -
2019-11-03 17:13:59 +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
a277a5f8db * Removed unused local vars.
git-svn-id: trunk@41457 -
2019-02-25 11:22:49 +00:00
florian
ccb8e86560 * fixes arm
git-svn-id: trunk@40350 -
2018-11-18 14:16:20 +00:00
florian
9d56387e7f + new spilling heuristics which takes care of the usage weigth of a register,
not yet activated, can be selected by passing SPILLING_NEW when compiling the compiler

git-svn-id: trunk@40346 -
2018-11-18 10:11:13 +00:00
yury
4357caaad8 * Removed unused local vars.
git-svn-id: trunk@40183 -
2018-11-02 18:44:29 +00:00
florian
ea32ddd5b2 * avoid overflows of execution weight
git-svn-id: trunk@39623 -
2018-08-16 20:45:36 +00:00
florian
37a5716819 * reuse more sparc code for sparc64
git-svn-id: trunk@36961 -
2017-08-20 17:20:43 +00:00
florian
7c0f72d9af * avoid spill coalesce of registers with itself, resolves issue #31926
git-svn-id: trunk@36363 -
2017-05-28 08:59:57 +00:00
florian
344970879e * spill coalesce uses get_alias
git-svn-id: trunk@36359 -
2017-05-28 08:59:49 +00:00
florian
db49b2f62b * coalesce spilled registers if possible to avoid mem->mem moves
git-svn-id: trunk@36325 -
2017-05-25 12:44:35 +00:00
florian
4b17ad80d0 * reduce initial size of movelist, 16 is enough for most cases
git-svn-id: trunk@36324 -
2017-05-25 12:44:33 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
yury
60e21e4222 * Reverted r34524 - workaround for compiling with -gc. It is not needed anymore since cycle completes with -gc.
git-svn-id: trunk@35537 -
2017-03-07 09:30:16 +00:00
florian
4242949453 * write more information into the interference graph
git-svn-id: trunk@34801 -
2016-11-05 23:06:04 +00:00
Károly Balogh
e0e90fffc4 make rgobj.uses_registers also return true, when the rg never allocated an imreg, but there were direct cpu register allocations. this at least fixes some address regvar trashing on 68k in relation to syscalls' explicit paralocs
git-svn-id: trunk@34777 -
2016-11-03 01:45:34 +00:00
pierre
c7d79acd61 Allow compilation of compiler with -gc option
git-svn-id: trunk@34524 -
2016-09-13 08:47:53 +00:00
florian
2a28f5a85d * update used_in_proc only in trgobj.translate_registers, before it might cause unnecessary pushes of actually unused registers
git-svn-id: trunk@33526 -
2016-04-15 21:30:14 +00:00
sergei
c0eafe38aa * Make trgobj.uses_registers method return True when registers of appropriate type are specified in list of used registers (after assembler blocks), but not used otherwise. This is a missing piece of r30011, enabling code generator to actually save/restore such registers. Resolves #28421.
git-svn-id: trunk@32610 -
2015-12-07 19:12:20 +00:00
florian
199b1861d6 * fix wrong comparisons in trgobj.conservative to enable better coalescing,
before this patch, k was calculated wrong most of the time

git-svn-id: trunk@31439 -
2015-08-28 18:49:04 +00:00
florian
31709b1b43 * check registers of ait_regalloc for a valid color when translating and compiling with -dextdebug
git-svn-id: trunk@30438 -
2015-04-05 19:06:06 +00:00
Jonas Maebe
e12dff9a5e * support top_para in trgllvm.get_spill_temp()
git-svn-id: trunk@30426 -
2015-04-04 14:29:06 +00:00
Jonas Maebe
e750678f37 * factored out spilling code that deals with operand types into virtual
methods so they can be overridden by platform-specific variants
    for platform-specific operand types

git-svn-id: trunk@30425 -
2015-04-04 14:29:03 +00:00
Jonas Maebe
197e5194b9 * don't crash if we have to spill a register of the last instruction in an
asmlist

git-svn-id: trunk@30402 -
2015-04-01 15:43:10 +00:00
Jonas Maebe
67b8aceaee * synchronized with privatetrunk till r30095
git-svn-id: branches/hlcgllvm@30101 -
2015-03-05 20:32:15 +00:00
sergei
31fddaafe8 + New subtype of tai_regalloc, "ra_markused". It marks a physical register as used in procedure, triggering saving/restoring that register if it is non-volatile.
git-svn-id: trunk@30010 -
2015-02-25 21:38:23 +00:00
Jonas Maebe
5c75b6dd6b * synchronised with trunk up till r28402
git-svn-id: branches/hlcgllvm@28403 -
2014-08-13 16:04:30 +00:00