1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 20:12:56 +02:00
Commit Graph

875 Commits

Author SHA1 Message Date
Chris Lattner
9c9c1158cb Fix some issues in WalkChainUsers dealing with
CopyToReg/CopyFromReg/INLINEASM.  These are annoying because
they have the same opcode before an after isel.  Fix this by
setting their NodeID to -1 to indicate that they are selected,
just like what automatically happens when selecting things that
end up being machine nodes.

With that done, give IsLegalToFold a new flag that causes it to
ignore chains.  This lets the HandleMergeInputChains routine be
the one place that validates chains after a match is successful,
enabling the new hotness in chain processing.  This smarter
chain processing eliminates the need for "PreprocessRMW" in the
X86 and MSP430 backends and enables MSP to start matching it's
multiple mem operand instructions more aggressively.

I currently #if out the dead code in the X86 backend and MSP 
backend, I'll remove it for real in a follow-on patch.

The testcase changes are:
  test/CodeGen/X86/sse3.ll: we generate better code
  test/CodeGen/X86/store_op_load_fold2.ll: PreprocessRMW was 
      miscompiling this before, we now generate correct code
      Convert it to filecheck while I'm at it.
  test/CodeGen/MSP430/Inst16mm.ll: Add a testcase for mem/mem
      folding to make anton happy. :)

llvm-svn: 97596
2010-03-02 22:20:06 +00:00
Chris Lattner
0c14477270 run HandleMergeInputChains even if we only have one input chain.
llvm-svn: 97581
2010-03-02 19:34:59 +00:00
Chris Lattner
2019e2922f Fix the xfail I added a couple of patches back. The issue
was that we weren't properly handling the case when interior
nodes of a matched pattern become dead after updating chain
and flag uses.  Now we handle this explicitly in 
UpdateChainsAndFlags.

llvm-svn: 97561
2010-03-02 07:50:03 +00:00
Chris Lattner
d23cbd049d I was confused about this, it turns out that MorphNodeTo
*does* delete ex-operands that become dead.

llvm-svn: 97559
2010-03-02 07:14:49 +00:00
Chris Lattner
bd1d913a9d factor node morphing out to its own helper method.
llvm-svn: 97558
2010-03-02 06:55:04 +00:00
Chris Lattner
1707a88a2c Sink InstructionSelect() out of each target into SDISel, and rename it
DoInstructionSelection.  Inline "SelectRoot" into it from DAGISelHeader.
Sink some other stuff out of DAGISelHeader into SDISel.

Eliminate the various 'Indent' stuff from various targets, which dates
to when isel was recursive.

 17 files changed, 114 insertions(+), 430 deletions(-)

llvm-svn: 97555
2010-03-02 06:34:30 +00:00
Chris Lattner
9a28d163c2 Use the right induction variable.
llvm-svn: 97541
2010-03-02 02:37:23 +00:00
Chris Lattner
0b41a42411 Rewrite chain handling validation and input TokenFactor handling
stuff now that we don't care about emulating the old broken 
behavior of the old isel.  This eliminates the 
'CheckChainCompatible' check (along with IsChainCompatible) which
did an incorrect and inefficient scan *up* the chain nodes which
happened as the pattern was being formed and does the validation
at the end in HandleMergeInputChains when it forms a structural 
pattern.  This scans "down" the graph, which means that it is
quickly bounded by nodes already selected.  This also handles
token factors that get "trapped" in the dag.

Removing the CheckChainCompatible nodes also shrinks the 
generated tables by about 6K for X86 (down to 83K).

There are two pieces remaining before I can nuke PreprocessRMW:
1. I xfailed a test because we're now producing worse code in a 
   case that has nothing to do with the change: it turns out that
   our use of MorphNodeTo will leave dead nodes in the graph
   which (depending on how the graph is walked) end up causing
   bogus uses of chains and blocking matches.  This is really 
   bad for other reasons, so I'll fix this in a follow-up patch.

2. CheckFoldableChainNode needs to be improved to handle the TF.

llvm-svn: 97539
2010-03-02 02:22:10 +00:00
Chris Lattner
53bd8b1717 remove dead code.
llvm-svn: 97529
2010-03-02 00:40:26 +00:00
Chris Lattner
e6f86e288c refactor some code out of OPC_EmitMergeInputChains into a
new helper function.

llvm-svn: 97525
2010-03-02 00:00:03 +00:00
Chris Lattner
b65ac4a796 Accelerate isel dispatch for tables that start with a top-level
OPC_SwitchOpcode to use a table lookup instead of having to go
through the interpreter for this.

llvm-svn: 97469
2010-03-01 18:47:11 +00:00
Chris Lattner
f62ad24616 some trivial microoptimizations.
llvm-svn: 97441
2010-03-01 07:43:08 +00:00
Chris Lattner
cdfa80eaaf eliminate the CheckMultiOpcodeMatcher code and have each
ComplexPattern at the root be generated multiple times, once
for each opcode they are part of.  This encourages factoring
because the opcode checks get treated just like everything
else in the matcher.

llvm-svn: 97439
2010-03-01 07:17:40 +00:00
Chris Lattner
8529ea0237 add a new OPC_SwitchOpcode which is semantically equivalent
to a scope where every child starts with a CheckOpcode, but
executes more efficiently.  Enhance DAGISelMatcherOpt to 
form it.

This also fixes a bug in CheckOpcode: apparently the SDNodeInfo
objects are not pointer comparable, we have to compare the
enum name.

llvm-svn: 97438
2010-03-01 06:59:22 +00:00
Chris Lattner
4408939f12 eliminate GetInt1/2
llvm-svn: 97426
2010-02-28 22:38:43 +00:00
Chris Lattner
afa7d2eacc hoist the new isel interpreter out of DAGISelHeader.h
(which gets #included into the middle of each 
target's DAGISel class) into a .cpp file where it is
only compiled once.

llvm-svn: 97425
2010-02-28 22:37:22 +00:00
Chris Lattner
f6e9f39042 fix a bug in findNonImmUse (used by IsLegalToFold) where nodes with
no id's would cause early exit allowing IsLegalToFold to return true
instead of false, producing a cyclic dag.

This was striking the new isel because it isn't using SelectNodeTo yet,
which theoretically is just an optimization.

llvm-svn: 96972
2010-02-23 19:32:27 +00:00
Chris Lattner
955ce23e27 sink special case "cannotyetselect" for intrinsics out of the
tblgen splatted code into the implementation.

llvm-svn: 96460
2010-02-17 06:28:22 +00:00
Evan Cheng
b5fe25544c Split SelectionDAGISel::IsLegalAndProfitableToFold to
IsLegalToFold and IsProfitableToFold. The generic version of the later simply checks whether the folding candidate has a single use.

This allows the target isel routines more flexibility in deciding whether folding makes sense. The specific case we are interested in is folding constant pool loads with multiple uses.

llvm-svn: 96255
2010-02-15 19:41:07 +00:00
Evan Cheng
8bee7fb61d Now that ShrinkDemandedOps() is separated out from DAG combine. It sometimes leave some obvious nops which dag combine used to clean up afterwards e.g. (trunk (ext n)) -> n. Look for them and squash them.
llvm-svn: 95757
2010-02-10 02:17:34 +00:00
Chris Lattner
7acf9be6c4 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
Bill Wendling
7449bb010b Remove the '-disable-scheduling' flag and replace it with the 'source' option of
the '-pre-RA-sched' flag. It actually makes more sense to do it this way. Also,
keep track of the SDNode ordering by default. Eventually, we would like to make
this ordering a way to break a "tie" in the scheduler. However, doing that now
breaks the "CodeGen/X86/abi-isel.ll" test for 32-bit Linux.

llvm-svn: 94308
2010-01-23 10:26:57 +00:00
David Greene
fde2825063 Add some new debugging APIs to print out "raw" SelectionDAGs to make
understanding CannotYTetSelect and other errors easier.

llvm-svn: 93901
2010-01-19 20:37:34 +00:00
David Greene
d8faccbeab Add some debug routines to SelectionDAG to dump full DAGs.
print/dumpWithDepth allows one to dump a DAG up to N levels deep.
dump/printWithFullDepth prints the whole DAG, subject to a depth limit
on 100 in the default case (to prevent infinite recursion).

Have CannotYetSelect to a dumpWithFullDepth so it is clearer exactly
what the non-matching DAG looks like.

llvm-svn: 93538
2010-01-15 19:43:23 +00:00
Jim Grosbach
7239c4c92e fix 80-column violations
llvm-svn: 93487
2010-01-15 00:36:15 +00:00
Dan Gohman
2cd1b789c7 Update a partially obsolete comment.
llvm-svn: 93228
2010-01-12 04:32:35 +00:00
Jakob Stoklund Olesen
f1c71ef6ba Avoid adding PHI arguments for a predecessor that has gone away when a BRCOND was constant folded.
This fixes PR5980.

llvm-svn: 93184
2010-01-11 21:02:33 +00:00
Evan Cheng
afa00d14db Dan pointed out checking whether a node is dead by comparing its opcode to ISD::DELETED_NODE is not safe. Use a DAGUpdateListener to remove dead nodes from work list instead.
llvm-svn: 93031
2010-01-09 00:21:08 +00:00
Evan Cheng
f96a9ec02b ReplaceAllUsesOfValueWith may delete other nodes that the one being replaced. Do not delete dead nodes again.
llvm-svn: 92988
2010-01-08 02:36:12 +00:00
Benjamin Kramer
22ec2524fd Use pop_back_val instead of back()+pop_back.
llvm-svn: 92918
2010-01-07 17:27:56 +00:00
Evan Cheng
f9dade0634 Comment.
llvm-svn: 92850
2010-01-06 19:43:21 +00:00
Evan Cheng
25dcf9b830 Teach dag combine to fold the following transformation more aggressively:
(OP (trunc x), (trunc y)) -> (trunc (OP x, y))

Unfortunately this simple change causes dag combine to infinite looping. The problem is the shrink demanded ops optimization tend to canonicalize expressions in the opposite manner. That is badness. This patch disable those optimizations in dag combine but instead it is done as a late pass in sdisel.

This also exposes some deficiencies in dag combine and x86 setcc / brcond lowering. Teach them to look pass ISD::TRUNCATE in various places.

llvm-svn: 92849
2010-01-06 19:38:29 +00:00
Benjamin Kramer
e90a3c66c4 Avoid going through the LLVMContext for type equality where it's safe to dereference the type pointer.
llvm-svn: 92726
2010-01-05 13:12:22 +00:00
David Greene
e5bee4794b Change errs() to dbgs().
llvm-svn: 92597
2010-01-05 01:26:11 +00:00
Dan Gohman
9bcfdf98f1 Change SelectCode's argument from SDValue to SDNode *, to make it more
clear what information these functions are actually using.

This is also a micro-optimization, as passing a SDNode * around is
simpler than passing a { SDNode *, int } by value or reference.

llvm-svn: 92564
2010-01-05 01:24:18 +00:00
Chris Lattner
84e9de4a58 Final step in the metadata API restructuring: move the
getMDKindID/getMDKindNames methods to LLVMContext (and add
convenience methods to Module), eliminating MetadataContext.
Move the state that it maintains out to LLVMContext.

llvm-svn: 92259
2009-12-29 09:01:33 +00:00
Chris Lattner
9ec640a902 This is a major cleanup of the instruction metadata interfaces that
I asked Devang to do back on Sep 27.  Instead of going through the
MetadataContext class with methods like getMD() and getMDs(), just
ask the instruction directly for its metadata with getMetadata()
and getAllMetadata().

This includes a variety of other fixes and improvements: previously
all Value*'s were bloated because the HasMetadata bit was thrown into
value, adding a 9th bit to a byte.  Now this is properly sunk down to
the Instruction class (the only place where it makes sense) and it
will be folded away somewhere soon.

This also fixes some confusion in getMDs and its clients about 
whether the returned list is indexed by the MDID or densely packed.
This is now returned sorted and densely packed and the comments make
this clear.

This introduces a number of fixme's which I'll follow up on.

llvm-svn: 92235
2009-12-28 23:41:32 +00:00
Chris Lattner
cd3aa9d1ff rename getMDKind -> getMDKindID, make it autoinsert if an MD Kind
doesn't exist already, eliminate registerMDKind.  Tidy up a bunch
of random stuff.

llvm-svn: 92225
2009-12-28 20:45:51 +00:00
Bill Wendling
3fbb708d4f Remove dead store.
llvm-svn: 92190
2009-12-28 01:51:30 +00:00
Dale Johannesen
b4485fd8a9 Use more sensible type for flags in asms. PR 5570.
Patch by Sylve`re Teissier (sorry, ASCII only).

llvm-svn: 91988
2009-12-23 07:32:51 +00:00
Dan Gohman
e4169d615e Fix this to properly clear the FastISel debug location. Thanks to
Bill for spotting this!

llvm-svn: 91355
2009-12-14 23:08:09 +00:00
Dan Gohman
e6ce676cb2 Remove old DBG_LABEL code.
llvm-svn: 90669
2009-12-05 17:56:26 +00:00
Dan Gohman
d2797bf9ae Remove the unused DisableLegalizeTypes option and related code.
llvm-svn: 90668
2009-12-05 17:51:33 +00:00
Dan Gohman
b352b42391 Don't blindly set the debug location for PHI node copies.
llvm-svn: 90637
2009-12-05 01:29:04 +00:00
Dan Gohman
c9454cd34f Make TargetSelectInstruction protected and called from FastISel.cpp
instead of SelectionDAGISel.cpp.

llvm-svn: 90636
2009-12-05 01:27:58 +00:00
Dan Gohman
feeb2f07a1 The debug information for an LLVM Instruction applies to that Instruction
and that Instruction only. Implement this by setting the "current debug position"
back to Unknown after processing each instruction.

llvm-svn: 90632
2009-12-05 00:27:08 +00:00
Chris Lattner
9ce833945e 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
Dan Gohman
153de919a3 Move CopyCatchInfo into FunctionLoweringInfo.cpp too, for consistency.
llvm-svn: 89683
2009-11-23 18:12:11 +00:00
Dan Gohman
d23a0a12d9 Rename SelectionDAGLowering to SelectionDAGBuilder, and rename
SelectionDAGBuild.cpp to SelectionDAGBuilder.cpp.

llvm-svn: 89681
2009-11-23 18:04:58 +00:00
Dan Gohman
086e19c874 Move the FunctionLoweringInfo class and some related utility functions out
of SelectionDAGBuild.h/cpp into its own files, to help separate
general lowering logic from SelectionDAG-specific lowering logic.

llvm-svn: 89667
2009-11-23 17:16:22 +00:00