Commit Graph

161 Commits

Author SHA1 Message Date
Bob Wilson 7149cfcda3 Fix a mistake in my previous change r105437: don't access operand 2 and assume
that it is an immediate before checking that the instruction is an
EXTRACT_SUBREG.

llvm-svn: 105585
2010-06-07 23:48:46 +00:00
Bob Wilson a733daf18c Add some missing checks in TwoAddressInstructionPass::CoalesceExtSubRegs.
Check that all the instructions are in the same basic block, that the
EXTRACT_SUBREGs write to the same subregs that are being extracted, and that
the source and destination registers are in the same regclass.  Some of
these constraints can be relaxed with a bit more work.  Jakob suggested
that the loop that checks for subregs when NewSubIdx != 0 should use the
"nodbg" iterator, so I made that change here, too.

llvm-svn: 105437
2010-06-03 23:53:58 +00:00
Jakob Stoklund Olesen a8ad97743d Slightly change the meaning of the reMaterialize target hook when the original
instruction defines subregisters.

Any existing subreg indices on the original instruction are preserved or
composed with the new subreg index.

Also substitute multiple operands mentioning the original register by using the
new MachineInstr::substituteRegister() function. This is necessary because there
will soon be <imp-def> operands added to non read-modify-write partial
definitions. This instruction:

  %reg1234:foo = FLAP %reg1234<imp-def>

will reMaterialize(%reg3333, bar) like this:

  %reg3333:bar-foo = FLAP %reg333:bar<imp-def>

Finally, replace the TargetRegisterInfo pointer argument with a reference to
indicate that it cannot be NULL.

llvm-svn: 105358
2010-06-02 22:47:25 +00:00
Bob Wilson 2d35a9e810 Rename canCombinedSubRegIndex method to something more grammatically correct
and tidy up the comment describing it.

llvm-svn: 105339
2010-06-02 18:54:47 +00:00
Bob Wilson f4a34b97b8 Fix an obvious mistake: don't change the operands until all of them have been
checked and it is safe to proceed with the changes.

llvm-svn: 105304
2010-06-02 00:16:08 +00:00
Jakob Stoklund Olesen ab6223949e Handle composed subreg indices when processing REQ_SEQUENCE instructions.
llvm-svn: 105066
2010-05-29 00:14:14 +00:00
Evan Cheng 3858451e09 - Change MachineInstr::findRegisterDefOperandIdx so it can also look for defs
that are aliases of the specified register.
- Rename modifiesRegister to definesRegister since it's looking a def of the
specific register or one of its super-registers. It's not looking for def of a
sub-register or alias that could change the specified register.
- Added modifiesRegister to look for defs of aliases.

llvm-svn: 104377
2010-05-21 20:53:24 +00:00
Jakob Stoklund Olesen e11cdf8cc8 TwoAddressInstructionPass doesn't really know how to merge live intervals when
lowering REG_SEQUENCE instructions.

Insert copies for REG_SEQUENCE sources not killed to avoid breaking later passes.

llvm-svn: 104146
2010-05-19 20:08:00 +00:00
Evan Cheng 1e4f55200d Fix PR7175. Insert copies of a REG_SEQUENCE source if it is used by other REG_SEQUENCE instructions.
llvm-svn: 103994
2010-05-17 23:24:12 +00:00
Evan Cheng f2c9a96f3c Fix PR7156. If the sources of a REG_SEQUENCE are all IMPLICIT_DEF's. Replace it with an IMPLICIT_DEF rather than deleting it or else it would be left without a def.
llvm-svn: 103984
2010-05-17 22:09:49 +00:00
Evan Cheng 29c463862e Careful with reg_sequence coalescing to not to overwrite sub-register indices.
llvm-svn: 103971
2010-05-17 20:57:12 +00:00
Evan Cheng 8c2d062ea6 Teach two-address pass to do some coalescing while eliminating REG_SEQUENCE
instructions.

e.g.
%reg1026<def> = VLDMQ %reg1025<kill>, 260, pred:14, pred:%reg0
%reg1027<def> = EXTRACT_SUBREG %reg1026, 6
%reg1028<def> = EXTRACT_SUBREG %reg1026<kill>, 5
...
%reg1029<def> = REG_SEQUENCE %reg1028<kill>, 5, %reg1027<kill>, 6, %reg1028, 7, %reg1027, 8, %reg1028, 9, %reg1027, 10, %reg1030<kill>, 11, %reg1032<kill>, 12

After REG_SEQUENCE is eliminated, we are left with:

%reg1026<def> = VLDMQ %reg1025<kill>, 260, pred:14, pred:%reg0
%reg1029:6<def> = EXTRACT_SUBREG %reg1026, 6
%reg1029:5<def> = EXTRACT_SUBREG %reg1026<kill>, 5

The regular coalescer will not be able to coalesce reg1026 and reg1029 because it doesn't
know how to combine sub-register indices 5 and 6. Now 2-address pass will consult the
target whether sub-registers 5 and 6 of reg1026 can be combined to into a larger
sub-register (or combined to be reg1026 itself as is the case here). If it is possible, 
it will be able to replace references of reg1026 with reg1029 + the larger sub-register
index.

llvm-svn: 103835
2010-05-14 23:21:14 +00:00
Evan Cheng 4aab8b5425 If REG_SEQUENCE source is livein, copy it first. Also, update livevariables information when a copy is introduced.
llvm-svn: 103680
2010-05-13 00:00:35 +00:00
Evan Cheng 0c6ebc7d95 Code clean up.
llvm-svn: 103538
2010-05-12 01:27:49 +00:00
Evan Cheng b58b6f9a85 Ensure REG_SEQUENCE source operands are unique.
llvm-svn: 103449
2010-05-11 00:04:31 +00:00
Evan Cheng 9d55b23425 Clear RegSequences vector after eliminating REG_SEQUENCE instructions.
llvm-svn: 103435
2010-05-10 21:24:55 +00:00
Dan Gohman 779c69bbc5 Add a DebugLoc argument to TargetInstrInfo::copyRegToReg, so that it
doesn't have to guess.

llvm-svn: 103194
2010-05-06 20:33:48 +00:00
Evan Cheng 4b6abd8c2b Move REG_SEQUENCE removal to 2addr pass.
llvm-svn: 103109
2010-05-05 18:45:40 +00:00
Evan Cheng 77be42a07f Ignore dbg_value's.
llvm-svn: 99321
2010-03-23 20:36:12 +00:00
Evan Cheng f94d68398a Add MachineRegisterInfo::hasOneUse and hasOneNonDBGUse.
llvm-svn: 97663
2010-03-03 21:18:38 +00:00
Evan Cheng 62e795ab8c Swap parameters of isSafeToMove and isSafeToReMat for consistency.
llvm-svn: 97578
2010-03-02 19:03:01 +00:00
Dale Johannesen 12565de705 Don't allow DBG_VALUE to affect codegen.
llvm-svn: 95889
2010-02-11 18:22:31 +00:00
Dale Johannesen 8bba1608bd Skip debug info in a couple of places.
llvm-svn: 95814
2010-02-10 21:47:48 +00:00
Chris Lattner b06015aa69 move target-independent opcodes out of TargetInstrInfo
into TargetOpcodes.h.  #include the new TargetOpcodes.h
into MachineInstr.  Add new inline accessors (like isPHI())
to MachineInstr, and start using them throughout the 
codebase.

llvm-svn: 95687
2010-02-09 19:54:29 +00:00
Dale Johannesen c3adf44885 Skip DEBUG_VALUE in some places where it was affecting codegen.
llvm-svn: 95647
2010-02-09 02:01:46 +00:00
David Greene ac9f8199ba Change errs() to dbgs().
llvm-svn: 92565
2010-01-05 01:24:21 +00:00
Chris Lattner a48f44d9ee improve portability to avoid conflicting with std::next in c++'0x.
Patch by Howard Hinnant!

llvm-svn: 90365
2009-12-03 00:50:42 +00:00
Jakob Stoklund Olesen 575c3f3d72 Fix PR5300.
When TwoAddressInstructionPass deletes a dead instruction, make sure that all
register kills are accounted for. The 2-addr register does not get special
treatment.

llvm-svn: 89246
2009-11-18 21:33:35 +00:00
Evan Cheng 6ad7da96fe - Change TargetInstrInfo::reMaterialize to pass in TargetRegisterInfo.
- If destination is a physical register and it has a subreg index, use the
  sub-register instead.
This fixes PR5423.

llvm-svn: 88745
2009-11-14 02:55:43 +00:00
Nick Lewycky 974e12b2d3 Remove includes of Support/Compiler.h that are no longer needed after the
VISIBILITY_HIDDEN removal.

llvm-svn: 85043
2009-10-25 06:57:41 +00:00
Nick Lewycky 02d5f77d26 Remove VISIBILITY_HIDDEN from class/struct found inside anonymous namespaces.
Chris claims we should never have visibility_hidden inside any .cpp file but
that's still not true even after this commit.

llvm-svn: 85042
2009-10-25 06:33:48 +00:00
Dan Gohman 87b02d5bbc Factor out LiveIntervalAnalysis' code to determine whether an instruction
is trivially rematerializable and integrate it into
TargetInstrInfo::isTriviallyReMaterializable. This way, all places that
need to know whether an instruction is rematerializable will get the
same answer.

This enables the useful parts of the aggressive-remat option by
default -- using AliasAnalysis to determine whether a memory location
is invariant, and removes the questionable parts -- rematting operations
with virtual register inputs that may not be live everywhere.

llvm-svn: 83687
2009-10-09 23:27:56 +00:00
Bob Wilson 5c7d9ca53d Overhaul the TwoAddressInstructionPass to simplify the logic, especially
for the complicated case where one register is tied to multiple destinations.
This avoids the extra scan of instruction operands that was introduced by
my recent change.  I also pulled some code out into a separate
TryInstructionTransform method, added more comments, and renamed some
variables.

Besides all those changes, this takes care of a FIXME in the code regarding
an assumption about there being a single tied use of a register when
converting to a 3-address form.  I'm not aware of cases where that assumption
is violated, but the code now only attempts to transform an instruction,
either by commuting its operands or by converting to a 3-address form,
for the simple case where there is a single pair of tied operands.

llvm-svn: 80945
2009-09-03 20:58:42 +00:00
Bob Wilson bc751989f1 Rearrange code to eliminate redundancy and avoid gotos.
llvm-svn: 80798
2009-09-02 16:35:35 +00:00
Bob Wilson fcd618bf1d Avoid calling removeVirtualRegisterKilled which iterates over the operands
to find the kill, since we already have the operand.

llvm-svn: 80736
2009-09-01 23:18:46 +00:00
Bob Wilson efe96918f8 Refactor some code into separate functions. No functional changes.
llvm-svn: 80733
2009-09-01 22:51:08 +00:00
Bob Wilson 71e77ea89b Move use of LV inside condition that guards for null LV.
llvm-svn: 80731
2009-09-01 22:19:00 +00:00
Bob Wilson 33b408a10f Fix pr4843: When an instruction has multiple destination registers that are
tied to different source registers, the TwoAddressInstructionPass needs to
be smarter.  Change it to check before replacing a source register whether
that source register is tied to a different destination register, and if so,
defer handling it until a subsequent iteration.

llvm-svn: 80654
2009-09-01 04:18:40 +00:00
Bob Wilson e98396d3fc Use early exit and reduce indentation.
llvm-svn: 80631
2009-08-31 21:54:55 +00:00
Bob Wilson 53b6a02dd1 If the tied registers are already the same, there is no need to change
them.  Move the code to make that change inside the conditional.

llvm-svn: 80630
2009-08-31 21:54:16 +00:00
Chris Lattner ed03a01af1 remove some DOUTs
llvm-svn: 79812
2009-08-23 03:20:44 +00:00
Evan Cheng 10af5d621c Code clean up.
llvm-svn: 78360
2009-08-07 00:28:58 +00:00
Dan Gohman 0402315d41 Use setPreservesAll and setPreservesCFG in CodeGen passes.
llvm-svn: 77754
2009-07-31 23:37:33 +00:00
Daniel Dunbar 0dd5e1ed39 More migration to raw_ostream, the water has dried up around the iostream hole.
- Some clients which used DOUT have moved to DEBUG. We are deprecating the
   "magic" DOUT behavior which avoided calling printing functions when the
   statement was disabled. In addition to being unnecessary magic, it had the
   downside of leaving code in -Asserts builds, and of hiding potentially
   unnecessary computations.

llvm-svn: 77019
2009-07-25 00:23:56 +00:00
Evan Cheng 57106d6dc0 Use TII->findCommutedOpIndices to find the commute operands (rather than guessing).
llvm-svn: 76472
2009-07-20 21:16:08 +00:00
Evan Cheng 84517443ca Let callers decide the sub-register index on the def operand of rematerialized instructions.
Avoid remat'ing instructions whose def have sub-register indices for now. It's just really really hard to get all the cases right.

llvm-svn: 75900
2009-07-16 09:20:10 +00:00
Evan Cheng b4dfce2dba Two-address pass should use findCommutedOpIndices to determine what registers are commuted.
llvm-svn: 75317
2009-07-11 00:04:23 +00:00
Evan Cheng 7061ee968c Eliminate VarInfo::UsedBlocks.
llvm-svn: 72411
2009-05-26 06:25:46 +00:00
Lang Hames 2646b72424 Fix for PR4124. Make TwoAddressFormPass::FindLastUseInMBB return the real last use.
llvm-svn: 71769
2009-05-14 04:26:30 +00:00
Lang Hames 8d4636d516 Fix for PR4121. If TwoAddressInstructionPass removes a dead def, and the regB
operand was killed, the kill needs to be removed from regB's VarInfo.

llvm-svn: 71635
2009-05-13 04:18:47 +00:00