Commit Graph

272 Commits

Author SHA1 Message Date
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
sergei
9b9ea15d68 + m68k: initial implementation of do_spill_replace (supports only MOVE instructions for now). Tested with qemu for Coldfire target.
git-svn-id: trunk@28274 -
2014-07-30 01:20:59 +00:00
Jonas Maebe
bacd303208 * synchronized with trunk up to r27758
git-svn-id: branches/hlcgllvm@27779 -
2014-05-12 16:12:34 +00:00
Jonas Maebe
246caf3526 * never alias/coalesce cpu registers that are not usable by the register
allocator (such as stack/framepointers) with virtual registers, otherwise
    they can get changed in case the virtual register gets changed (read-only
    use would be ok, but we don't keep track of which virtual registers are
    only read

git-svn-id: trunk@27104 -
2014-03-11 23:18:45 +00:00
Jonas Maebe
e9268a0a14 * synchronised with trunk up till r26975
git-svn-id: branches/hlcgllvm@26976 -
2014-03-06 21:36:58 +00:00
florian
23c724f885 * prevent a temp. register allocated during spilling being immediately spilled again, resolves #25164
git-svn-id: trunk@26930 -
2014-03-02 19:47:05 +00:00
florian
829764e96b + replace registers to spill in mov instructions and convert them into ldr/str
git-svn-id: trunk@26677 -
2014-02-05 18:19:41 +00:00
Károly Balogh
587acf6452 fix infinite spilling on m68k, patch by Florian, additional IE workaround by me, based on a similar hack in the ARM cg...
git-svn-id: trunk@26465 -
2014-01-15 02:09:02 +00:00
Károly Balogh
70f9b098e0 no longer define a segment field for m68k
git-svn-id: trunk@26464 -
2014-01-15 02:06:10 +00:00
sergei
d2a9308181 + SPARC: implemented register spill replacement.
git-svn-id: trunk@26364 -
2014-01-03 08:14:43 +00:00
Jonas Maebe
b7803ab974 + llvm support for the register allocator. While llvm works with virtual
registers itself, it requires them to be in SSA form. Therefore we
    spill all registers that are written more than once to memory.
  + support in the generic register allocator for generating code that is
    SSA-safe
  + spilling helpers for llvm

git-svn-id: branches/hlcgllvm@26044 -
2013-11-11 11:15:47 +00:00
Jonas Maebe
5ef93e85b8 + added extra "orgsupreg" parameter to do_spill_read/do_spill_written/
do_spill_replace routines, will be necessary by llvm register
    allocator to determine the tdef corresponding to that register
  * replaced uses of taicpu with tai_cpu_abstract_sym in the register
    allocator so that it can work both with taicpu and taillvm instructions

git-svn-id: branches/hlcgllvm@26043 -
2013-11-11 11:15:43 +00:00