Commit Graph

64 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen 8e96c6abf7 Remove RegisterScavenger::isSuperRegUsed(). This completely reverses the mistaken commit r77904.
Now there is no special treatment of instructions that redefine part of a
super-register. Instead, the super-register is marked with <imp-use,kill> and
<imp-def>. For instance, from LowerSubregs on ARM:

subreg: CONVERTING: %Q1<def> = INSERT_SUBREG %Q1<undef>, %D1<kill>, 5
subreg: %D2<def> = FCPYD %D1<kill>, 14, %reg0, %Q1<imp-def>

subreg: CONVERTING: %Q1<def> = INSERT_SUBREG %Q1, %D0<kill>, 6
subreg: %D3<def> = FCPYD %D0<kill>, 14, %reg0, %Q1<imp-use,kill>, %Q1<imp-def>
llvm-svn: 78466
2009-08-08 13:19:10 +00:00
Jakob Stoklund Olesen ac51533b8a Simplify RegScavenger::forward a bit more.
Verify that early clobber registers and their aliases are not used.

All changes to RegsAvailable are now done as a transaction so the order of
operands makes no difference.

The included test case is from PR4686. It has behaviour that was dependent on the order of operands.

llvm-svn: 78465
2009-08-08 13:18:47 +00:00
Evan Cheng 8611e90668 Back out some of recent register scavenger change by John Mosby. It broke a number of ARM tests.
llvm-svn: 78421
2009-08-07 22:39:43 +00:00
Jakob Stoklund Olesen 1e455c0f3b Get rid of RegScavenger::backwards() before the bitrot spreads.
If we need it one day, there is nothing wrong with putting it back in.

llvm-svn: 78337
2009-08-06 21:19:03 +00:00
John Mosby beb7ea2931 Reg Scavenging generalization (Thumb support):
- start support for new PEI w/reg alloc, allow running RS from emit{Pro,Epi}logue() target hooks.
- fix minor issue with recursion detection.

llvm-svn: 78318
2009-08-06 16:32:47 +00:00
Jakob Stoklund Olesen 0e0b5405f5 Clean up the handling of two-address operands in RegScavenger.
This fixes PR4528.

llvm-svn: 78107
2009-08-04 21:30:30 +00:00
Jakob Stoklund Olesen 86cdcdc3d2 Don't give implicit machine operands special treatment in the register scavenger.
Imp-def is *not* allowed to redefine a live register.
Imp-use is *not* allowed to use a dead register.

llvm-svn: 78106
2009-08-04 21:29:11 +00:00
Evan Cheng 206ee96bd6 Fix PR4528. This scavenger assertion is too strict. The two-address value is
killed by another operand.

There is probably a better fix. Either 1) scavenger can look at other operands, or
2) livevariables can be smarter about kill markers. Patches welcome.

llvm-svn: 78072
2009-08-04 16:52:44 +00:00
Jakob Stoklund Olesen 185eb035e9 Fix issue in regscavenger when scavenging a callee-saved register that has not been spilled.
llvm-svn: 77912
2009-08-02 20:29:41 +00:00
Jakob Stoklund Olesen 5d52bfbbc9 Scavenger asserts.
Allow imp-def and imp-use of anything in the scavenger asserts, just like the machine code verifier.
Allow redefinition of a sub-register of a live register.

llvm-svn: 77904
2009-08-02 18:28:41 +00:00
Evan Cheng d2d52d1906 Ignore undef uses.
llvm-svn: 76799
2009-07-22 21:51:42 +00:00
Jakob Stoklund Olesen 41ed90f03e Fix bug in RegScavenger::scavengeRegister().
Reserved registers are not candidates for scavenging, and they were removed
from the candidate list like this:

CreateRegClassMask(RC, Candidates);
Candidates ^= ReservedRegs;

However, when there are reserved registers outside RC, this causes invalid
bits to be set in Candidates.

llvm-svn: 75847
2009-07-15 22:32:11 +00:00
Torok Edwin 08954aa4e1 Fix assert(0) conversion, as suggested by Chris.
llvm-svn: 75423
2009-07-12 20:07:01 +00:00
Torok Edwin ccb29cd290 Convert more assert(0)+abort() -> LLVM_UNREACHABLE,
and abort()/exit() -> llvm_report_error().

llvm-svn: 75363
2009-07-11 13:10:19 +00:00
Evan Cheng 2a5efe14a7 Remove special handling of implicit_def. Fix a couple more bugs in liveintervalanalysis and coalescer handling of implicit_def.
Note, isUndef marker must be placed even on implicit_def def operand or else the scavenger will not ignore it. This is necessary because -O0 path does not use liveintervalanalysis, it treats implicit_def just like any other def.

llvm-svn: 74601
2009-07-01 08:19:36 +00:00
Evan Cheng d379e896ff Handle IMPLICIT_DEF with isUndef operand marker, part 2. This patch moves the code to annotate machineoperands to LiveIntervalAnalysis. It also add markers for implicit_def that define physical registers. The rest, is just a lot of details.
llvm-svn: 74580
2009-07-01 01:59:31 +00:00
Evan Cheng dcf1f59305 Temporarily restore the scavenger implicit_def checking code. MachineOperand isUndef mark is not being put on implicit_def of physical registers (created for parameter passing, etc.).
llvm-svn: 74519
2009-06-30 09:19:42 +00:00
Evan Cheng 0dc101b897 Add a bit IsUndef to MachineOperand. This indicates the def / use register operand is defined by an implicit_def. That means it can def / use any register and passes (e.g. register scavenger) can feel free to ignore them.
The register allocator, when it allocates a register to a virtual register defined by an implicit_def, can allocate any physical register without worrying about overlapping live ranges. It should mark all of operands of the said virtual register so later passes will do the right thing.

This is not the best solution. But it should be a lot less fragile to having the scavenger try to track what is defined by implicit_def.

llvm-svn: 74518
2009-06-30 08:49:04 +00:00
Evan Cheng b6cf8dbb96 If killed register is defined by implicit_def, do not clear it since it's live range may overlap another def of same register.
llvm-svn: 73255
2009-06-12 21:34:26 +00:00
Bob Wilson 51856173c8 Fix pr3954. The register scavenger asserts for inline assembly with
register destinations that are tied to source operands.  The
TargetInstrDescr::findTiedToSrcOperand method silently fails for inline
assembly.  The existing MachineInstr::isRegReDefinedByTwoAddr was very
close to doing what is needed, so this revision makes a few changes to
that method and also renames it to isRegTiedToUseOperand (for consistency
with the very similar isRegTiedToDefOperand and because it handles both
two-address instructions and inline assembly with tied registers).

llvm-svn: 68714
2009-04-09 17:16:43 +00:00
Dan Gohman 906152a20f Tidy up #includes, deleting a bunch of unnecessary #includes.
llvm-svn: 61715
2009-01-05 17:59:02 +00:00
Devang Patel 323dbe57a6 Silience unused warnings.
llvm-svn: 61390
2008-12-23 21:55:04 +00:00
Dan Gohman 8c82a8a984 Initialize the ImplicitDefed member, to avoid getting stale
data from a previous block.

llvm-svn: 61237
2008-12-19 00:46:20 +00:00
Dan Gohman 7e9daef644 Fix a typo in a comment.
llvm-svn: 60434
2008-12-02 19:27:20 +00:00
Evan Cheng c22215a090 - Register scavenger should use MachineRegisterInfo and internal map to find the first use of a register after a given machine instruction.
- When scavenging a register, in addition to the spill, insert a restore before the first use.
- Abort if client is looking to scavenge a register even when a previously scavenged register is still live.

llvm-svn: 59697
2008-11-20 02:32:35 +00:00
Evan Cheng cdbbc00a4f Make the same change to RegScavenger::backward.
llvm-svn: 59566
2008-11-18 23:54:01 +00:00
Evan Cheng 6cea453271 We also need to keep the operand index for two address check.
llvm-svn: 59562
2008-11-18 22:56:19 +00:00
Evan Cheng 3095c32c89 Register scavenger should process early clobber defs first. A dead early clobber def should not interfere with a normal def which happens one slot later.
llvm-svn: 59559
2008-11-18 22:28:38 +00:00
Dan Gohman 0d1e9a8e04 Switch the MachineOperand accessors back to the short names like
isReg, etc., from isRegister, etc.

llvm-svn: 57006
2008-10-03 15:45:36 +00:00
Dan Gohman c7fc432b19 Minor const-correctness fixes.
llvm-svn: 53196
2008-07-07 20:06:06 +00:00
Duncan Sands 698348dfac Fix some constructs that gcc-4.4 warns about.
llvm-svn: 51591
2008-05-27 11:50:51 +00:00
Evan Cheng 2cb98eb4bb Allow registers defined by implicit_def to be clobbered.
llvm-svn: 49512
2008-04-10 23:47:53 +00:00
Evan Cheng b5fdc923d3 1. IMPLICIT_DEF can *re-define* any register.
2. Coalescer can now create an interesting situation where a register def can
   reaches itself without being killed.

llvm-svn: 49246
2008-04-05 01:27:09 +00:00
Bill Wendling d6951455e4 Something that kills a super-register also
kills the sub-register.

llvm-svn: 48038
2008-03-07 23:45:15 +00:00
Evan Cheng 39a3221e27 Fixed a register scavenger bug. If a def is re-defining part of a super register, there must be an implicit def of the super-register on the MI.
llvm-svn: 48024
2008-03-07 20:12:54 +00:00
Bill Wendling 55bfd8c3f7 When setting the "unused" info, take into account something like this:
%r3<def> = OR %x3<kill>, %x3

We don't want to mark the %r3 as unused even though it's a sub-register of %x3.

llvm-svn: 48003
2008-03-06 23:22:43 +00:00
Evan Cheng 6325446666 Refactor code. Remove duplicated functions that basically do the same thing as
findRegisterUseOperandIdx, findRegisterDefOperandIndx. Fix some naming inconsistencies.

llvm-svn: 47927
2008-03-05 00:59:57 +00:00
Bill Wendling 528083bc28 Make the register scavenger update the bookkeeping values for sub/super
registers.

llvm-svn: 47861
2008-03-03 22:12:25 +00:00
Bill Wendling f861fbaae8 Fix typos.
llvm-svn: 47200
2008-02-16 01:09:25 +00:00
Dan Gohman 3a4be0fdef Rename MRegisterInfo to TargetRegisterInfo.
llvm-svn: 46930
2008-02-10 18:45:23 +00:00
Chris Lattner 03ad885039 rename TargetInstrDescriptor -> TargetInstrDesc.
Make MachineInstr::getDesc return a reference instead
of a pointer, since it can never be null.

llvm-svn: 45695
2008-01-07 07:27:27 +00:00
Chris Lattner a98c679de0 Rename MachineInstr::getInstrDescriptor -> getDesc(), which reflects
that it is cheap and efficient to get.

Move a variety of predicates from TargetInstrInfo into 
TargetInstrDescriptor, which makes it much easier to query a predicate
when you don't have TII around.  Now you can use MI->getDesc()->isBranch()
instead of going through TII, and this is much more efficient anyway. Not
all of the predicates have been moved over yet.

Update old code that used MI->getInstrDescriptor()->Flags to use the
new predicates in many places.

llvm-svn: 45674
2008-01-07 01:56:04 +00:00
Owen Anderson eee14601b1 Move some more instruction creation methods from RegisterInfo into InstrInfo.
llvm-svn: 45484
2008-01-01 21:11:32 +00:00
Chris Lattner f3ebc3f3d2 Remove attribution from file headers, per discussion on llvmdev.
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Evan Cheng bb26301864 Add a argument to storeRegToStackSlot and storeRegToAddr to specify whether
the stored register is killed.

llvm-svn: 44600
2007-12-05 03:14:33 +00:00
Dan Gohman 9da02f5ee2 Remove isReg, isImm, and isMBB, and change all their users to use
isRegister, isImmediate, and isMachineBasicBlock, which are equivalent,
and more popular.

llvm-svn: 41958
2007-09-14 20:33:02 +00:00
Evan Cheng bb6ecf0067 Better assertion messages.
llvm-svn: 37890
2007-07-05 07:05:38 +00:00
Evan Cheng 8cd28f0fb1 If call frame is not part of stack frame and no dynamic alloc, eliminateFrameIndex() must adjust SP offset with size of call frames.
llvm-svn: 36625
2007-05-01 09:01:42 +00:00
Evan Cheng 910c80851e Rename findRegisterUseOperand to findRegisterUseOperandIdx to avoid confusion.
llvm-svn: 36483
2007-04-26 19:00:32 +00:00
Evan Cheng 06a7041ff9 Bad bad bug. findRegisterUseOperand() returns -1 if a use if not found.
llvm-svn: 35618
2007-04-03 06:43:29 +00:00