Commit Graph

123 Commits

Author SHA1 Message Date
florian
991ce83a2b * patch by J. Gareth Moreton: conditional Jump Inversion stoploop variable, resolves #36680
git-svn-id: trunk@44144 -
2020-02-09 20:57:59 +00:00
yury
1b3a3a7983 * Removed lot of unused local vars. It is useful to turn on the notes in options. :)
git-svn-id: trunk@44053 -
2020-01-28 18:45:33 +00:00
Jeppe Johansen
7cfb87b325 - Handle jump optimizations on RISC-V
git-svn-id: trunk@43933 -
2020-01-13 22:42:39 +00:00
florian
872c22842e * do prefetching correctly
* more prefetching inserted
  * unnecessary/wrong UpdateUsedRegs removed

git-svn-id: trunk@43878 -
2020-01-06 20:59:24 +00:00
florian
599e2df71f o patch by J. Gareth Moreton, resolves r36371:
* This patch makes some minor improvements to the cross-platform code that deals with jump optimisations.
      More specifically, it attempts to do more in a single pass which has the nice side-effect of
      fixing a couple of minor mistakes (in some situations, it would erroneously remove an alignment entry).
      - Most improvements are with dealing with Jcc/JMP pairs and their equivalents on other platforms, by
      collapsing label clusters and stripping dead code as soon as it has enough information to do so, and being
      more intelligent before calling Continue to see if another optimisation can be performed in the same sitting.

      - RemoveDeadCodeAfterJump is now a function that returns True if a jump was found among the dead code,
      thus allowing the ability to flag the peephole optimizer for another iteration of Pass 1 - the
      destination label may have appeared earlier in the code and become dead as a result of the removal
      of the jump, thus opening up new optimisations with instructions that sat either side of the label.

      - Preliminary tests show that it does sometimes reduce the number of passes required to optimise a subroutine
      under -O3.

git-svn-id: trunk@43668 -
2019-12-09 20:58:31 +00:00
florian
7e6eeebdf0 o patch by J. Gareth Moreton, seeks to improve maintainability, safety and efficiency
in the peephole optimizer by slightly modifying some function headers based
    on their intended purpose, resolves #36353
    * Non-virtual methods and class methods that don't need to access any fields from
      the current object are now static methods, thus removing the hidden "Self"
      parameter and reducing overhead. This includes a large number of
      frequently-used functions such as SkipEntryExitMarker and SuperRegistersEqual.
    * GetNextInstruction, GetLastInstruction, SkipEntryExitMarker and
      SkipLabels have had their 'var' parameter changed to an 'out' parameter because
      they shouldn't depend on its input value. This will cause the compiler to throw warnings
      if you start using the value without initialising it first, and may open up optimisation
      opportunities in the future (e.g. storing written values in a temporary register
      and only writing it to the actual variable when the routine exits).

git-svn-id: trunk@43595 -
2019-11-26 22:09:33 +00:00
florian
af107ca8fe o patch by J. Gareth Moreton, resolves #36355
+ This patch serves to extend the JMP -> RET optimisation in OptPass2JMP by also doing the same
      for JMP -> MOV/RET, since there are often cases where the result (e.g. EAX) is set just
      prior to the function exiting.
    * RemoveDeadCodeAfterJump will now drop out if it detects SEH information -
      this stops exception information from being stripped if it is called on the final RET instruction.

git-svn-id: trunk@43592 -
2019-11-25 21:15:41 +00:00
pierre
17c422c3f2 Patch by Gareth Moreton.
* TAOptObj.CollapseZeroDistJump: Change hp1 to local variable,
     initialized as p.next, to avoid problems of dangling pointers
     revealed by use of "-CriotR -O2" compilation arguments.

git-svn-id: trunk@43554 -
2019-11-22 09:10:32 +00:00
florian
61bf55e0fe * define renamed
git-svn-id: trunk@43531 -
2019-11-21 19:58:48 +00:00
pierre
ff415ba39c Fixes by Gareth Moreton for problems exposed by use of -CriotR option
git-svn-id: trunk@43529 -
2019-11-21 10:00:20 +00:00
florian
6248a127ca * write assembler optimizer messages into output file if DEBUG_AOPTOBJ is set
git-svn-id: trunk@43521 -
2019-11-20 22:12:28 +00:00
florian
da54d0e8f7 + patch by J. Gareth Moreton: new method TAOptObj.CanDoJumpOpts and arm specific implementation
git-svn-id: trunk@43519 -
2019-11-20 22:12:27 +00:00
florian
f505822ab5 o patch by J. Gareth Moreton:
* fix jump optimizer for MIPS(EL).
    + New method called "MakeUnconditional" introduced that can do platform-specific changes

git-svn-id: trunk@43518 -
2019-11-20 22:12:26 +00:00
florian
d4f0658c02 * disable condition jump optimization on MIPS for now for the time being
git-svn-id: trunk@43486 -
2019-11-15 20:50:17 +00:00
florian
bf24882c33 * patch by J. Gareth Moreton: fix building for armv6m after r43441
git-svn-id: trunk@43466 -
2019-11-14 21:38:21 +00:00
florian
0ab0eefae0 + separate JUMP_DEBUG define
git-svn-id: trunk@43463 -
2019-11-14 21:14:00 +00:00
florian
d82335bf9a * do not remove cfi_endproc after jmps
git-svn-id: trunk@43462 -
2019-11-13 21:13:05 +00:00
florian
5c0a5b73c7 * patch by J. Gareth Moreton: fix compilation with debug info after r43441 and friends, resolves #36299
git-svn-id: trunk@43455 -
2019-11-12 20:03:19 +00:00
florian
47dcc5b05b * patch by J. Gareth Moreton, issue #36271, part 1: general rework of the jump optimizer
git-svn-id: trunk@43439 -
2019-11-10 16:11:38 +00:00
Jonas Maebe
67fc9a7853 * fixed peephole opitimizer removing some infinite loops (mantis #36139)
git-svn-id: trunk@43175 -
2019-10-12 21:39:48 +00:00
florian
9230ae5aab o overhaul-base.patch by J. Gareth Moreton, base for further patches
+ some inline directives added
  + some functions exported from units

git-svn-id: trunk@42722 -
2019-08-17 16:14:22 +00:00
Jonas Maebe
1b6425176b * synchronised with trunk till r42049
git-svn-id: branches/debug_eh@42050 -
2019-05-12 18:44:05 +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
Jonas Maebe
5d28e2156b + support for generating Dwarf CFI using .cfi_* directives
o adjust peephole optimisers so they don't remove cfi_endproc directives
     in case of tail call optimisation

git-svn-id: branches/debug_eh@41578 -
2019-03-03 17:15:03 +00:00
florian
94d7a02fae * modified patch by Gareth Moreton to pool TmpUsedRegs in the assembler optimizers, resolves #34679
git-svn-id: trunk@40938 -
2019-01-20 14:16:38 +00:00
Jonas Maebe
122d0d36d6 + volatile() expression that marks an expression as volatile
* disable matching volatile references in the assembler optimisers, so they
    can't be removed (more conservative than needed, but better than removing
    too many)
   o the CSE optimiser will ignore them by default, because they're an unknown
     inline node for it
  * also removed no longer used fpc_in_move_x and fpc_in_fillchar_x inline node
    identifiers from rtl/inc/innr.inc, and placed fpc_in_unaligned_x at the
    right place

git-svn-id: trunk@40465 -
2018-12-04 19:53:20 +00:00
florian
9b0ff05ee8 - get rid of MaxOps, it is redundant with max_operands
* MatchOpType with three operands is only available of max_operands>2

git-svn-id: trunk@40190 -
2018-11-02 21:32:29 +00:00
florian
2a016889de * skip align directives after unconditional jumps
git-svn-id: trunk@40160 -
2018-11-01 20:49:18 +00:00
pierre
0abc978cc4 Change RemoveCurrentP parameter type to tai, because GetNextInstruction does not always return a taicpu, adapt code in avr/aoptcpu unit
git-svn-id: trunk@40120 -
2018-10-31 23:15:22 +00:00
Jeppe Johansen
054bf32f1f Add RV64GC cpu type.
Fix float loading.
Fix a number of small issues with wrong operand sizes.
Fixed concatcopy code generation.
Align jump table for case statements.

git-svn-id: branches/laksen/riscv_new@39481 -
2018-07-21 22:34:42 +00:00
Jeppe Johansen
ceb38833f2 Added RiscV32/64 target, from a cleaned up version of branches/laksen/riscv/trunk.
git-svn-id: branches/laksen/riscv_new@39474 -
2018-07-20 08:21:15 +00:00
florian
5782acc32d * patch by J. Gareth Moreton to fix 33909
git-svn-id: trunk@39353 -
2018-07-01 12:54:30 +00:00
florian
ae950956af + TAOptObj.*PeepHoleOpts* check if p is really assigned
+ TAOptObj.RemoveCurrentP

git-svn-id: trunk@38488 -
2018-03-10 21:53:48 +00:00
florian
78878f59b1 + generic TAOptObj.AllocRegBetween
- removed x86 specific AllocRegBetween

git-svn-id: trunk@38445 -
2018-03-07 22:17:35 +00:00
florian
52510ea933 + TUsedRegs.Dump
git-svn-id: trunk@38067 -
2018-01-28 13:26:45 +00:00
florian
8315c660f4 * fix JumpTargetOp for sparc64
git-svn-id: trunk@37158 -
2017-09-09 19:36:50 +00:00
florian
7f286eb54e + define cpudelayslot: set during compiler compilation for CPUs having branch instructions with delay slot (MIPS, SPARC)
git-svn-id: trunk@36958 -
2017-08-20 17:20:38 +00:00
florian
f4718c0969 * made nop handling generic for sparc, so it is used by sparc64 as well
git-svn-id: trunk@36814 -
2017-07-29 20:06:14 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
florian
e3f0b338d4 * SkipLabels moved to aoptutils
* factored out OptPass2Jmp assembler optimization
* OptPass2Jmp now used by x86-64 as well

git-svn-id: trunk@36141 -
2017-05-06 21:07:02 +00:00
nickysn
c096b1fe6b * fixed the debug output, generated by -dDEBUG_INSTRUCTIONREGISTERDEPENDENCIES
for x86 instructions, entered via inline assembler, using intel syntax
  (the low level optimizer isn't normally run on them, so it doesn't matter that
  InstructionLoadsFromReg and similar functions don't work on them, but with
  -dDEBUG_INSTRUCTIONREGISTERDEPENDENCIES it is much more convenient for
  debugging purposes to have correct data for them, because you can enter
  instructions manually and see how these functions behave)

git-svn-id: trunk@36065 -
2017-05-03 10:14:35 +00:00
nickysn
a9617b623f + print info about the registers, in which new values are written (as reported
by RegLoadedWithNewValue), when DEBUG_INSTRUCTIONREGISTERDEPENDENCIES is
  defined

git-svn-id: trunk@35996 -
2017-04-28 13:14:12 +00:00
nickysn
7ea0429d40 + added new compiler debug ifdef DEBUG_INSTRUCTIONREGISTERDEPENDENCIES, which
adds instruction register usage info to the assembly output (only register
  reads for now, but register writes will also be added later). Useful for
  debugging InstructionLoadsFromReg and other similar functions.

git-svn-id: trunk@35967 -
2017-04-27 13:40:58 +00:00
florian
b274599a47 * made some assembler optimizer methods class methods
git-svn-id: trunk@33929 -
2016-06-06 21:18:20 +00:00
florian
d05222990e * while updating used register sets, all labels can/must be skipped
git-svn-id: trunk@33909 -
2016-06-04 19:45:12 +00:00
florian
cfd49ec708 + TAOptBase.SuperRegistersEqual
+ properly implemented TAOptObj.PrePeepHoleOpts
+ properly implemented TAOptObj.PeepHoleOptPass2

git-svn-id: trunk@33654 -
2016-05-05 12:38:19 +00:00
florian
3c2dab9878 * i386 peephole assembler uses largely the common peephole optimizer infrastructure, the resulting code is besides a few improvements the same
git-svn-id: trunk@33542 -
2016-04-21 20:14:01 +00:00
florian
1266491085 o refactored some peephole optimizer code:
* updated TAOptObj.RegUsedAfterInstruction with the arm implementation and removed the arm specific implementation
  * RegLoadedWithNewValue and InstructionLoadsFromReg are now a methods of TAoptBase
  * moved RegEndOfLife to TAOptObj
* during this refactoring, fixed also TCpuAsmOptimizer.RegLoadedWithNewValue for arm regarding post/preindexed 
  memory references: those modify the register but do not load it with a new value in the sense of RegLoadedWithNewValue

git-svn-id: trunk@33000 -
2016-01-24 15:25:16 +00:00
yury
5771073e0b * Fixed general peephole optimization of conditional jumps after r30446. It has been broken, since r30446 had added some IsJumpToLabel() checks, which tests for unconditional jump, but the optimization code expects also conditional jumps.
- Renamed IsJumpToLabel() to IsJumpToLabelUncond() to avoid confusions.
  - Added IsJumpToLabel() to check for any jump to a label.
  - Added comments.

git-svn-id: trunk@32114 -
2015-10-21 15:35:54 +00:00
yury
11a9ff4a43 * Removed unused vars for mipsel compiler.
git-svn-id: trunk@31745 -
2015-09-17 15:46:30 +00:00