Commit Graph

4839 Commits

Author SHA1 Message Date
Evan Cheng
cdbcfccece Some code clean up.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47060 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 09:56:03 +00:00
Evan Cheng
9cec00e7f1 Simplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47058 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 09:13:21 +00:00
Evan Cheng
e984e504b5 Fix a potential serious problem where kills belonging to the val# defined by a two-address instruction is also on the val# that defines the input.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47057 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 09:06:18 +00:00
Evan Cheng
e35a6d1dfb * Cannot safely commute an instruction there are other defs which can reach its uses.
* Ignore copy instructions which have already been coalesced.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47056 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 08:41:08 +00:00
Chris Lattner
86ca3cacc5 In SDISel, for targets that support FORMAL_ARGUMENTS nodes, lower this
node as soon as we create it in SDISel.  Previously we would lower it in
legalize.  The problem with this is that it only exposes the argument
loads implied by FORMAL_ARGUMENTs after legalize, so that only dag combine 2
can hack on them.  This causes us to miss some optimizations because 
datatype expansion also happens here.

Exposing the loads early allows us to do optimizations on them.  For example
we now compile arg-cast.ll to:

_foo:
	movl	$2147483647, %eax
	andl	8(%esp), %eax
	ret

where we previously produced:

_foo:
	subl	$12, %esp
	movsd	16(%esp), %xmm0
	movsd	%xmm0, (%esp)
	movl	$2147483647, %eax
	andl	4(%esp), %eax
	addl	$12, %esp
	ret

It might also make sense to do this for ISD::CALL nodes, which have implicit
stores on many targets.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47054 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 07:39:09 +00:00
Chris Lattner
fec42eb6da teach dag combiner how to eliminate MERGE_VALUES nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47052 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 07:25:05 +00:00
Nate Begeman
0325d90348 Support legalizing insert_vector_elt on targets where the element
type is not legal.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47048 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 06:43:04 +00:00
Evan Cheng
70071434ae Initial support for copy elimination by commuting its definition MI.
PR1877.
A3 = op A2 B0<kill>                                                                                                                                                                            
...                                                                                                                                                                                     
B1 = A3      <- this copy                                                                                                                                                                      
...                                                                                                                                                                                          
   = op A3   <- more uses                                                                                                                                                                      
                                                                                                                                                                                                 
==>                                                                                                                                                                                             
                                                                                                                                                                                            
B2 = op B0 A2<kill>                                                                                                                                                                            
...                                                                                                                                                                                          
B1 = B2      <- now an identify copy                                                                                                                                                           
...                                                                                                                                                                                          
   = op B2   <- more uses

This speeds up FreeBench/neural by 29%, Olden/bh by 12%, oopack_v1p8 by 53%.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47046 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 03:01:43 +00:00
Evan Cheng
d2b8d7bc51 - Added removeValNo() to remove all live ranges of a particular value#.
- removeRange() can now update value# information.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47044 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 02:48:26 +00:00
Evan Cheng
a4d16a1f0d commuteInstr() can now commute non-ssa machine instrs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47043 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 02:46:49 +00:00
Evan Cheng
1eb5cf9c7d Added debugging routine dumpUses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47042 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 02:45:38 +00:00
Dan Gohman
fd29e0eb06 Convert SelectionDAG::ComputeMaskedBits to use APInt instead of uint64_t.
Add an overload that supports the uint64_t interface for use by clients
that haven't been updated yet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47039 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 00:35:47 +00:00
Duncan Sands
014e04a5da Generalize getCopyFromParts and getCopyToParts to
handle arbitrary precision integers and any number
of parts.  For example, on a 32 bit machine an i50
corresponds to two i32 parts.  getCopyToParts will
extend the i50 to an i64 then write half of the i64
to each part; getCopyFromParts will combine the two
i32 parts into an i64 then truncate the result to
i50.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47024 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-12 20:46:31 +00:00
Duncan Sands
b988baccc2 Generalize the handling of call and return arguments,
in preparation for apint support.  These changes are
intended to have no functional effect.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46967 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-11 20:58:28 +00:00
Dan Gohman
cc20cd59e6 From Chris' review: use isa instead of explicitly using classof.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46964 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-11 19:00:34 +00:00
Dan Gohman
027ee7e3ca From Chris' review: minor corrections in comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46963 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-11 19:00:03 +00:00
Dan Gohman
bbbbb9c3dd From Chris' review: use cast instead of dyn_cast with an assert.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46962 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-11 18:58:42 +00:00
Dan Gohman
debeeba6ec From Chris' review: fix 80 column violations
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46961 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-11 18:57:43 +00:00
Ted Kremenek
1f801fa5ad Added "Profile" method to APFloat for use with FoldingSet.
Added member template "Add" to FoldingSetNodeID that allows "adding" arbitrary
objects to a profile via dispatch to FoldingSetTrait<T>::Profile().

Removed FoldingSetNodeID::AddAPFloat and FoldingSetNodeID::APInt, as their
functionality is now replaced using the above mentioned member template.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46957 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-11 17:24:50 +00:00
Duncan Sands
0753fc1850 Add a isBigEndian method to complement isLittleEndian.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46954 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-11 10:37:04 +00:00
Evan Cheng
431bfcbe37 Determine whether a spill kills the register it's spilling before insertion rather than trying to undo the kill marker afterwards.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46953 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-11 08:30:52 +00:00
Dan Gohman
6f0d024a53 Rename MRegisterInfo to TargetRegisterInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46930 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-10 18:45:23 +00:00
Duncan Sands
d885dbdf9e Add truncate and AssertZext result expansion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46926 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-10 10:08:52 +00:00
Bill Wendling
91b9ad1824 Return "(c1 + c2)" instead of yet another ADD node (which made this a
no-op).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46922 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-10 08:10:24 +00:00
Chris Lattner
be036a94c3 add anote
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46918 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-10 01:01:35 +00:00
Evan Cheng
63a18c491a Remove unused hidden option.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46903 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-09 08:36:28 +00:00
Dan Gohman
6394b099e8 Change ConstantSDNode to store an APInt instead of a uint64_t, and
begin adding some methods to use it this way.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46899 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-08 22:59:30 +00:00
Evan Cheng
f2f8c2ae07 Forgot these files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46896 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-08 22:05:27 +00:00
Evan Cheng
bbd8322daa Also print alignment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46895 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-08 22:05:07 +00:00
Dan Gohman
547ca537b6 Avoid needlessly casting away const qualifiers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46876 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-08 03:26:46 +00:00
Evan Cheng
27240c7d50 Remove remnant of load folding in local register allocator. Patch by Holger Schurig.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46861 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-07 19:46:55 +00:00
Dan Gohman
3069b87437 Follow Chris' suggestion; change the PseudoSourceValue accessors
to return pointers instead of references, since this is always what
is needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46857 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-07 18:41:25 +00:00
Dan Gohman
2bfe6ff605 Don't abort if a MemOperand is missing a SourceValue; just print it
as <unknown>. And make some minor adjustments to the MemOperand
dump format.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46853 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-07 16:18:00 +00:00
Nick Lewycky
33d4f7792f Don't make up new directives. (".set_foobar")
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46848 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-07 06:36:26 +00:00
Dan Gohman
69de1932b3 Re-apply the memory operand changes, with a fix for the static
initializer problem, a minor tweak to the way the
DAGISelEmitter finds load/store nodes, and a renaming of the
new PseudoSourceValue objects.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46827 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-06 22:27:42 +00:00
Evan Cheng
2fc628d662 Fix a number of local register allocator issues: PR1609.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46821 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-06 19:16:53 +00:00
Evan Cheng
22ff3eeebe RegAllocaLocal still *requires* LiveVariables since it runs PHIElimination, followed by TwoAddress which requires LiveVariables. We cannot run LiveVariables on non-SSA code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46813 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-06 08:00:32 +00:00
Evan Cheng
a58891ff1e Fix PR1975: dag isel emitter produces patterns that isel wrong flag result.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46776 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-05 22:50:29 +00:00
Evan Cheng
bb4151bd1f If a vr is already marked alive in a bb, then it has PHI uses that are visited earlier, then it is not killed in the def block (i.e. not dead).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46763 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-05 20:04:18 +00:00
Evan Cheng
fc718542a3 Typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46725 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-04 23:10:38 +00:00
Evan Cheng
4e3f5a4e9c Dwarf requires variable entries to be in the source order. Right now, since we are recording variable information at isel time this means parameters would appear in the reverse order. The short term fix is to issue recordVariable() at asm printing time instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46724 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-04 23:06:48 +00:00
Duncan Sands
6cb7e6d36b I don't see how NodeUpdated can be called with a
ReadyToProcess node - add an assertion to check
this.  Add an assertion to NodeDeleted that checks
that processed/ready nodes are indeed not deleted.
It is because they are never deleted that none of
the maps can have a deleted node as the source of
a mapping.  It does however seem to be possible in
theory to have a deleted value as the target of a
mapping, however this has not yet been spotted in
the wild.  Still mulling on what to do about this.
[The theoretical situation is this: a node A is
expanded/promoted/whatever to a newly created node
B.  Thus A->B is added to a map.  When the subtree
rooted at B is legalized it is conceivable that B
is deleted due to RAUW on a node somewhere above
it].


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46705 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-04 09:29:17 +00:00
Chris Lattner
9d3e5d476c Fix typo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46682 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-03 07:30:27 +00:00
Chris Lattner
fcd8e9e3a2 handle the case where a node can become ready to process
multiple times due to a RAUW.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46680 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-03 07:13:32 +00:00
Chris Lattner
42bd25f8ec Use the new infrastructure for listening to node updates to
keep the LegalizeTypes node flags up to date when doing a RAUW.
This fixes a nasty bug that Duncan ran into and makes the 
previous (nonbuggy case) more efficent.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46679 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-03 07:08:51 +00:00
Chris Lattner
d8cd3be370 the world doesn't need my debugging code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46678 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-03 07:01:05 +00:00
Chris Lattner
f8dc0617ba Change the 'global modification' APIs in SelectionDAG to take a new
DAGUpdateListener object pointer instead of just returning a vector 
of deleted nodes.  This makes the interfaces more efficient (no more
allocating a vector [at least a malloc], filling it in, then walking
it) and more clean.  This also allows the client to be notified of
nodes that are *changed* but not deleted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46677 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-03 06:49:24 +00:00
Chris Lattner
11d049c87f Generalize the SDOperand->SDOperand form of
SelectionDAG::ReplaceAllUsesWith to handle replacement of
an SDOperand with *any* sdoperand, not just one for a node with
a single result.  Note that this has a horrible FIXME'd hack in it
to work around PR1975.  This should be removed when PR1975 is fixed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46674 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-03 03:35:22 +00:00
Chris Lattner
a658baba78 add a -view-legalize-types-dags option, for viewing the dags going into legalize types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46672 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-03 02:05:04 +00:00
Evan Cheng
4eecdeb3fa Get rid of the annoying blank lines before labels.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46667 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-02 08:39:46 +00:00
Evan Cheng
a844bdeab3 SDIsel processes llvm.dbg.declare by recording the variable debug information descriptor and its corresponding stack frame index in MachineModuleInfo. This only works if the local variable is "homed" in the stack frame. It does not work for byval parameter, etc.
Added ISD::DECLARE node type to represent llvm.dbg.declare intrinsic. Now the intrinsic calls are lowered into a SDNode and lives on through out the codegen passes.
For now, since all the debugging information recording is done at isel time, when a ISD::DECLARE node is selected, it has the side effect of also recording the variable. This is a short term solution that should be fixed in time.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46659 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-02 04:07:54 +00:00
Evan Cheng
1b08bbca55 Remove the nasty LABEL hack with a much less evil one. Now llvm.dbg.func.start implies a stoppoint is set. SelectionDAGISel records a new source line but does not create a ISD::LABEL node for this special stoppoint. Asm printer will magically print this label. This ensures nothing is emitted before.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46635 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-01 09:10:45 +00:00
Evan Cheng
a647c92ec2 Rename RecordLabel to RecordSourceLine because that's what it is doing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46628 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-01 02:05:57 +00:00
Evan Cheng
334dc1f58d Revert 46556 and 46585. Dan please fix the PseudoSourceValue problem and re-commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46623 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 21:00:00 +00:00
Evan Cheng
7bdc5f734f Add a comment for a nasty short term hack.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46610 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 10:05:13 +00:00
Evan Cheng
bb81d97feb Add an extra operand to LABEL nodes which distinguishes between debug, EH, or misc labels. This fixes the EH breakage. However I am not convinced this is *the* solution.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46609 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 09:59:15 +00:00
Christopher Lamb
175e81598a Add more thorough error checking for NULL register classes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46605 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 07:09:08 +00:00
Evan Cheng
72bebb9205 MRegisterInfo::getLocation() is a really bad idea. Its function is to calculate the offset from frame pointer to a stack slot and then storing the delta in a MachineLocation object. The name is bad (it implies a getter), and MRegisterInfo doesn't need to know about MachineLocation.
Replace getLocation() with getFrameIndexOffset() which returns the delta from frame pointer to stack slot. Dwarf writer can then use the information for whatever it wants.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46597 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 03:37:28 +00:00
Dan Gohman
1a0248690a Rename ISD::FLT_ROUNDS to ISD::FLT_ROUNDS_ to avoid conflicting
with the real FLT_ROUNDS (defined in <float.h>).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46587 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 00:41:03 +00:00
Evan Cheng
00dff8dda2 Also avoid adding callee save code before debug labels.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46586 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 00:27:49 +00:00
Dan Gohman
c6c391dadd Create a new class, MemOperand, for describing memory references
in the backend. Introduce a new SDNode type, MemOperandSDNode, for
holding a MemOperand in the SelectionDAG IR, and add a MemOperand
list to MachineInstr, and code to manage them. Remove the offset
field from SrcValueSDNode; uses of SrcValueSDNode that were using
it are all all using MemOperandSDNode now.

Also, begin updating some getLoad and getStore calls to use the
PseudoSourceValue objects.

Most of this was written by Florian Brander, some
reorganization and updating to TOT by me.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46585 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 00:25:39 +00:00
Evan Cheng
294e652491 Fixed a bug in MergeValueInAsValue() pointed out by David Greene. Replace val# with previous liverange's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46579 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-30 22:44:55 +00:00
Evan Cheng
965d1b4bba Treat the label for the first @llvm.dbg.stoppoint the same way as the dbg_func_start label. Make sure nothing else is inserted before them.
Note this solution might be somewhat fragile since ISD::LABEL may be used for other
purposes. If that ends up to be an issue, we may need to introduce a different node
for debug labels.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46571 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-30 20:08:35 +00:00
Dale Johannesen
43b8f3b7d3 Adjust loop per review feedback.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46569 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-30 19:44:39 +00:00
Evan Cheng
6b2cf285bd A semi-gross fix for a debug info issue. When inserting the "function start" label (i.e. first label in the entry block) take care to insert it at the beginning of the block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46568 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-30 19:35:32 +00:00
Dale Johannesen
7757fff6ae Accept getelementptr starting at GV with all 0 indices as a
legitimate way of representing global variable GV in debug info.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46565 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-30 19:00:21 +00:00
Evan Cheng
ff9b373e8f Even though InsertAtEndOfBasicBlock is an ugly hack it still deserves a proper name. Rename it to EmitInstrWithCustomInserter since it does not necessarily insert
instruction at the end.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46562 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-30 18:18:23 +00:00
Dan Gohman
f38dc192dd Add a new PseudoSourceValue class, which will be used to help track
memory reference information in the backend. Most of this was written by
Florian Brander, cleanup and updating to TOT by me.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46556 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-30 16:35:31 +00:00
Dan Gohman
b625f2f896 Factor the addressing mode and the load/store VT out of LoadSDNode
and StoreSDNode into their common base class LSBaseSDNode. Member
functions getLoadedVT and getStoredVT are replaced with the common
getMemoryVT to simplify code that will handle both loads and stores.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46538 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-30 00:15:11 +00:00
Duncan Sands
648f880dc9 When expanding an operand, it's not the result value
type that matters but the operand type.  This fixes
2008-01-08-IllegalCMP.ll which crashed with the new
legalize infrastructure because SETCC with result
type i8 and operand type i64 was being custom expanded
by the X86 backend.  With this fix, the gcc build gets
as far as the first libcall.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46525 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 19:29:08 +00:00
Dan Gohman
3035959425 Use empty() instead of comparing size() with zero.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46514 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 13:02:09 +00:00
Dan Gohman
9f65c39f80 Fix a typo in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46513 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 12:43:50 +00:00
Dan Gohman
6ee9661390 Fix a typo in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46508 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 12:07:11 +00:00
Duncan Sands
d102593b42 Use getPreferredAlignmentLog or getPreferredAlignment
to get the alignment of global variables, rather than
using hand-made versions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46495 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 06:23:44 +00:00
Owen Anderson
8822eabe36 RegAllocBigBlock doesn't need LiveVariables either.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46488 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 02:32:13 +00:00
Nate Begeman
55030dc460 Properly expand extract-element for non-power-of-2 codegen
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46486 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 02:24:00 +00:00
Dale Johannesen
ba2a0b960e Handle 'X' constraint in asm's better.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46485 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 02:21:21 +00:00
Chris Lattner
f32aac3090 Fix PowerPC/./2007-10-18-PtrArithmetic.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46424 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-27 23:32:17 +00:00
Chris Lattner
ee339f4b2a fix a crash on CodeGen/X86/vector-rem.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46422 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-27 23:21:58 +00:00
Owen Anderson
c66a4f912f Reg alloc doesn't really need LiveVariables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46420 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-27 22:00:00 +00:00
Chris Lattner
3bd39d4ca8 Implement some dag combines that allow doing fneg/fabs/fcopysign in integer
registers if used by a bitconvert or using a bitconvert.  This allows us to
avoid constant pool loads and use cheaper integer instructions when the
values come from or end up in integer regs anyway.  For example, we now 
compile CodeGen/X86/fp-in-intregs.ll to:

_test1:
	movl	$2147483648, %eax
	xorl	4(%esp), %eax
	ret
_test2:
	movl	$1065353216, %eax
	orl	4(%esp), %eax
	andl	$3212836864, %eax
	ret

Instead of:
_test1:
	movss	4(%esp), %xmm0
	xorps	LCPI2_0, %xmm0
	movd	%xmm0, %eax
	ret
_test2:
	movss	4(%esp), %xmm0
	andps	LCPI3_0, %xmm0
	movss	LCPI3_1, %xmm1
	andps	LCPI3_2, %xmm1
	orps	%xmm0, %xmm1
	movd	%xmm1, %eax
	ret

bitconverts can happen due to various calling conventions that require
fp values to passed in integer regs in some cases, e.g. when returning
a complex.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46414 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-27 17:42:27 +00:00
Chris Lattner
553c116a1b For long double constants, print an approximation of their value to the .s file to make it easier to read.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46407 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-27 06:09:28 +00:00
Chris Lattner
1329cb8d89 Infer alignment of loads and increase their alignment when we can tell they are
from the stack.  This allows us to compile stack-align.ll to:

_test:
	movsd	LCPI1_0, %xmm0
	movapd	%xmm0, %xmm1
***	andpd	4(%esp), %xmm1
	andpd	_G, %xmm0
	addsd	%xmm1, %xmm0
	movl	20(%esp), %eax
	movsd	%xmm0, (%eax)
	ret

instead of:

_test:
	movsd	LCPI1_0, %xmm0
**	movsd	4(%esp), %xmm1
**	andpd	%xmm0, %xmm1
	andpd	_G, %xmm0
	addsd	%xmm1, %xmm0
	movl	20(%esp), %eax
	movsd	%xmm0, (%eax)
	ret



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46401 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-26 19:45:50 +00:00
Chris Lattner
5eee427594 Fix some bugs in SimplifyNodeWithTwoResults where it would call deletenode to
delete a node even if it was not dead in some cases.  Instead, just add it to
the worklist.  Also, make sure to use the CombineTo methods, as it was doing
things that were unsafe: the top level combine loop could touch dangling memory.

This fixes CodeGen/Generic/2008-01-25-dag-combine-mul.ll



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46384 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-26 01:09:19 +00:00
Chris Lattner
9967c15183 don't bother making x&-1 only to simplify it in dag combine. This commonly occurs expanding i64 ops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46383 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-26 01:05:42 +00:00
Chris Lattner
50d8e491a2 reduce indentation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46377 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-25 23:34:24 +00:00
Chris Lattner
5bab78527a fix long lines.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46355 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-25 17:24:52 +00:00
Chris Lattner
00161a63dd Add skeletal code to increase the alignment of loads and stores when
we can infer it.  This will eventually help stuff, though it doesn't
do much right now because all fixed FI's have an alignment of 1.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46349 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-25 07:20:16 +00:00
Chris Lattner
1612faae3c move MachineFrameInfo::CreateFixedObject out of line, give MachineFrameInfo
a reference to TargetFrameInfo.  Rearrange order of fields in StackObject to
save a word.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46348 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-25 07:19:06 +00:00
Chris Lattner
94ffc7eb46 include alignment and volatility information in -view-*-dags output
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46347 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-25 06:40:45 +00:00
Chris Lattner
40743b83bf Don't dump the function!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46320 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-24 19:28:11 +00:00
Chris Lattner
23e202dee0 clarify a comment, thanks Duncan.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46313 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-24 17:10:01 +00:00
Chris Lattner
125991a1f6 Fix this buggy transformation. Two observations:
1. we already know the value is dead, so don't bother replacing 
   it with undef.
2. The very case the comment describes actually makes the load
   live which asserts in deletenode.  If we do the replacement
   and the node becomes live, just treat it as new.  This fixes
   a failure on X86/2008-01-16-InvalidDAGCombineXform.ll with
   some local changes in my tree.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46306 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-24 07:57:06 +00:00
Chris Lattner
20e3d86766 The dag combiner is missing revisiting nodes that it really should, and thus leaving
dead stuff around.  This gets fed into the isel pass and causes certain foldings from
happening because nodes have extraneous uses floating around.  For example, if we turned
foo(bar(x)) -> baz(x), we sometimes left bar(x) around.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46305 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-24 07:18:21 +00:00
Chris Lattner
0aa5e6f3fb fold fp_round(fp_round(x)) -> fp_round(x).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46304 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-24 06:45:35 +00:00
Owen Anderson
b487e7215c Move some functionality for adding flags to MachineInstr's into methods on MachineInstr rather than LiveVariables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46295 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-24 01:10:07 +00:00
Evan Cheng
3ae054385c Forgot these.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46292 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-24 00:22:01 +00:00
Duncan Sands
f9c98e650d The last pieces needed for loading arbitrary
precision integers.  This won't actually work
(and most of the code is dead) unless the new
legalization machinery is turned on.  While
there, I rationalized the handling of i1, and
removed some bogus (and unused) sextload patterns.
For i1, this could result in microscopically
better code for some architectures (not X86).
It might also result in worse code if annotating
with AssertZExt nodes turns out to be more harmful
than helpful.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46280 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-23 20:39:46 +00:00
Owen Anderson
97ca75e4bb Fix an iterator invalidation issue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46263 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-22 23:58:54 +00:00
Chris Lattner
8e1f7ac87d Simplify SelectionDAG::getNode so that a big switch stmt is not #ifndef
NDEBUG.  This is in response to a really nasty bug I introduced that 
Dale tracked down, hopefully this won't happen in the future.  
Many thanks Dale.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46254 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-22 19:09:33 +00:00
Duncan Sands
7e857201f3 The final piece needed for storing arbitrary precision
integers.  Handle truncstore of a legal type to an unusual
number of bits.  Most of this code is not reachable unless
the new legalize infrastructure is turned on.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46249 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-22 07:17:34 +00:00
Owen Anderson
a6b1926531 Clarify a deviation from the original algorithm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46218 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-21 22:03:00 +00:00
Owen Anderson
3b489522df Improve a few comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46217 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-21 22:01:01 +00:00
Dale Johannesen
da9bb3578e Move DAG-changing code out of #ifndef NDEBUG.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46204 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-21 01:00:34 +00:00
Dale Johannesen
713ed3f7c0 Do not generate a FP_ROUND of f64 to f64.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46195 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-20 01:18:38 +00:00
Chris Lattner
c9133f9772 remove extraneous &'s.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46171 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-18 19:36:20 +00:00
Chris Lattner
ddf89566a9 This commit changes:
1. Legalize now always promotes truncstore of i1 to i8. 
2. Remove patterns and gunk related to truncstore i1 from targets.
3. Rename the StoreXAction stuff to TruncStoreAction in TLI.
4. Make the TLI TruncStoreAction table a 2d table to handle from/to conversions.
5. Mark a wide variety of invalid truncstores as such in various targets, e.g.
   X86 currently doesn't support truncstore of any of its integer types.
6. Add legalize support for truncstores with invalid value input types.
7. Add a dag combine transform to turn store(truncate) into truncstore when
   safe.

The later allows us to compile CodeGen/X86/storetrunc-fp.ll to:

_foo:
	fldt	20(%esp)
	fldt	4(%esp)
	faddp	%st(1)
	movl	36(%esp), %eax
	fstps	(%eax)
	ret

instead of:

_foo:
	subl	$4, %esp
	fldt	24(%esp)
	fldt	8(%esp)
	faddp	%st(1)
	fstps	(%esp)
	movl	40(%esp), %eax
	movss	(%esp), %xmm0
	movss	%xmm0, (%eax)
	addl	$4, %esp
	ret



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46140 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-17 19:59:44 +00:00
Chris Lattner
4626b250a2 code cleanups, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46126 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-17 07:20:38 +00:00
Chris Lattner
0bd4893a07 * Introduce a new SelectionDAG::getIntPtrConstant method
and switch various codegen pieces and the X86 backend over
  to using it.

* Add some comments to SelectionDAGNodes.h

* Introduce a second argument to FP_ROUND, which indicates
  whether the FP_ROUND changes the value of its input. If
  not it is safe to xform things like fp_extend(fp_round(x)) -> x.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46125 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-17 07:00:52 +00:00
Evan Cheng
839b759c38 When a live virtual register is being clobbered by an implicit def, it is spilled
and the spill is its kill. However, if the local allocator has determined the
register has not been modified (possible when its value was reloaded), it would
not issue a restore. In that case, mark the last use of the virtual register as
kill.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46111 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-17 02:08:17 +00:00
Evan Cheng
644340a9bd Replace std::vector<bool> with BitVector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46104 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-17 00:35:26 +00:00
Evan Cheng
02c4285643 Fixes a nasty dag combiner bug that causes a bunch of tests to fail at -O0.
It's not safe to use the two value CombineTo variant to combine away a dead load.
e.g. 
v1, chain2 = load chain1, loc
v2, chain3 = load chain2, loc
v3         = add v2, c 
Now we replace use of v1 with undef, use of chain2 with chain1.
ReplaceAllUsesWith() will iterate through uses of the first load and update operands:
v1, chain2 = load chain1, loc
v2, chain3 = load chain1, loc
v3         = add v2, c 
Now the second load is the same as the first load, SelectionDAG cse will ensure
the use of second load is replaced with the first load.
v1, chain2 = load chain1, loc
v3         = add v1, c
Then v1 is replaced with undef and bad things happen.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46099 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-16 23:11:54 +00:00
Dale Johannesen
48ae02fe62 Do not mark EH tables no-dead-strip unless the
associated function is so marked.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46088 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-16 19:59:28 +00:00
Chris Lattner
7e2e033e23 Fix a ppc long double regression I introduced yesterday due to a
simplification.  This fixes automotive-basicmath on PPC.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46072 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-16 17:59:31 +00:00
Chris Lattner
a66bb39e97 merge a few pieces of code that do the store/load to stack
pattern to use EmitStackConvert now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46066 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-16 07:51:34 +00:00
Chris Lattner
1401d15c99 rename ExpandBIT_CONVERT to EmitStackConvert, generalizing
it to allow it to emit different load and store kinds.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46065 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-16 07:45:30 +00:00
Chris Lattner
23594d4537 simplify a bunch of code by using SelectionDAG::CreateStackTemporary
instead of inlining its body.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46062 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-16 07:03:22 +00:00
Chris Lattner
f2670a89a7 Change legalizeop of FP_ROUND and FP_EXTEND to not fall through
into the ANY_EXTEND/ZERO_EXTEND/SIGN_EXTEND code to simplify it.

Unmerge the code for FP_ROUND and FP_EXTEND from each other to 
make each one simpler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46061 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-16 06:57:07 +00:00
Chris Lattner
572dee71af Factor the ReachesChainWithoutSideEffects out of dag combiner into
a public SDOperand::reachesChainWithoutSideEffects method.  No 
functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46050 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-16 05:49:24 +00:00
Dale Johannesen
4af3494452 Fix and enable EH for x86-64 Darwin. Adds
ShortenEHDataFor64Bits as a not-very-accurate
abstraction to cover all the changes in DwarfWriter.
Some cosmetic changes to Darwin assembly code for
gcc testsuite compatibility.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46029 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15 23:24:56 +00:00
Owen Anderson
40a627ddf8 Move some calls to getVRegDef higher in the callgraph, so they don't get executed as frequently in performance sensitive code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46027 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15 22:58:11 +00:00
Chris Lattner
034f12ea08 The type of the 'abort' node should be pointer type (because
it's a function pointer) not MVT::Other.  This fixes builtin_trap
lowering on ppc, alpha, ia64


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46018 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15 22:09:33 +00:00
Owen Anderson
7047dd4d22 Remove DefInst from LiveVariables::VarInfo. Use the facilities on MachineRegisterInfo instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46016 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15 22:02:46 +00:00
Chris Lattner
41bab0beac Add support for targets that have a legal ISD::TRAP.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46014 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15 21:58:08 +00:00
Evan Cheng
4c46fc6bbf Oops. Forgot to commit this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46002 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15 07:49:36 +00:00
Anton Korobeynikov
66fac79b89 For PR1839: add initial support for __builtin_trap. llvm-gcc part is missed
as well as PPC codegen


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46001 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15 07:02:33 +00:00
Evan Cheng
c67e6e8e82 ByVal stack slot alignment should be at least as large as pointer ABI alignment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45995 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15 03:14:05 +00:00
Chris Lattner
459525df1e don't create the post-ra scheduler unless it is enabled.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45972 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-14 19:00:06 +00:00
Chris Lattner
a6c3f80d97 remove dead #include
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45971 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-14 18:45:28 +00:00
Duncan Sands
a41d719803 Remove the assumption that byval has been applied to
a pointer to a struct.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45939 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-13 21:19:59 +00:00
Chris Lattner
aad193a7e9 implement support for sinking a load out the bottom of a block that
has no stores between the load and the end of block.  This works 
great and sinks hundreds of stores, but we can't turn it on because
machineinstrs don't have volatility information and we don't want to
sink volatile stores :(


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45894 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-12 00:17:41 +00:00
Chris Lattner
a22edc82ca Simplify the side effect stuff a bit more and make licm/sinking
both work right according to the new flags.

This removes the TII::isReallySideEffectFree predicate, and adds
TII::isInvariantLoad. 

It removes NeverHasSideEffects+MayHaveSideEffects and adds
UnmodeledSideEffects as machine instr flags.  Now the clients
can decide everything they need.

I think isRematerializable can be implemented in terms of the
flags we have now, though I will let others tackle that.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45843 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-10 23:08:24 +00:00
Chris Lattner
2445888208 Clamp down on sinking of lots of instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45841 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-10 22:35:15 +00:00
Duncan Sands
007f9847c4 Output sinl for a long double FSIN node, not sin.
Likewise fix up a bunch of other libcalls.  While
there I remove NEG_F32 and NEG_F64 since they are
not used anywhere.  This fixes 9 Ada ACATS failures.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45833 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-10 10:28:30 +00:00
Evan Cheng
8480293f41 Only remat loads from immutable stack slots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45831 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-10 08:24:38 +00:00
Evan Cheng
a07cec9e24 Simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45830 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-10 08:22:10 +00:00
Owen Anderson
c95f075c43 Don't use LiveVariables::VarInfo::DefInst.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45815 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-10 03:12:54 +00:00
Dale Johannesen
038129dd58 Emit unused EH frames for weak definitions on Darwin,
because assembler/linker can't cope with weak absolutes.
PR 1880.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45811 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-10 02:03:30 +00:00
Owen Anderson
ddd060ffcf Get rid of all uses of LiveVariables::VarInfo::DefInst in favor of the equivalent API from
MachineRegisterInfo.  Once all clients are switched over, the former will be going away.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45805 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-10 01:36:43 +00:00
Owen Anderson
dc4d6558e4 Add more comments explaining the basics of how the decision of when to rename and when to insert
copies is made.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45799 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-10 00:47:01 +00:00
Owen Anderson
b199cbec2e Get rid of the isKillInst predicate. LiveVariables already provides this information.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45797 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-10 00:33:11 +00:00
Owen Anderson
9c2efa8a8f Copies need to be inserted before the first terminator, not at the end of the block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45791 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-10 00:01:41 +00:00
Evan Cheng
19107563af Special copy SUnit's do not have SDNode's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45787 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-09 23:01:55 +00:00
Owen Anderson
ec1213fbbb Clean up StrongPHIElimination a bit, and add some more comments to the internal structures. There's
still more work to do on this front.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45783 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-09 22:40:54 +00:00
Owen Anderson
864e3a3762 StrongPHIElim: Now with even fewer trivial bugs!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45775 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-09 10:41:39 +00:00
Owen Anderson
719fef648d Fix an infinite recursion bug in InsertCopies.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45774 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-09 10:32:30 +00:00
Owen Anderson
cb7d949a19 Fix some simple bugs. StrongPHIElimination now does not crash on 164.gzip.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45773 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-09 06:19:05 +00:00
Chris Lattner
07649d9265 Make load->store deletion a bit smarter. This allows us to compile this:
void test(long long *P) { *P ^= 1; }

into just:

_test:
	movl	4(%esp), %eax
	xorl	$1, (%eax)
	ret

instead of code like this:

_test:
	movl	4(%esp), %ecx
        xorl    $1, (%ecx)
	movl	4(%ecx), %edx
	movl	%edx, 4(%ecx)
	ret



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45762 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-08 23:08:06 +00:00
Owen Anderson
0c5714bb99 Rename registers that do not need copies.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45759 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-08 21:54:52 +00:00
Owen Anderson
0d893b4038 Actually insert copies now!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45738 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-08 05:16:15 +00:00
Owen Anderson
0b4825c38b Oops, missed one.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45719 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 21:32:09 +00:00
Owen Anderson
9e549202a0 Make some predicates static.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45718 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 21:30:40 +00:00
Gordon Henriksen
c45d98d966 Pruning includes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45700 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 13:30:38 +00:00
Chris Lattner
f14cf85e33 remove #includage
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45697 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 07:42:25 +00:00
Chris Lattner
749c6f6b5e rename TargetInstrDescriptor -> TargetInstrDesc.
Make MachineInstr::getDesc return a reference instead
of a pointer, since it can never be null.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45695 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 07:27:27 +00:00
Chris Lattner
3db805ea80 simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45693 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 06:47:00 +00:00
Chris Lattner
0ff23966fe Rename all the M_* flags to be namespace qualified enums, and switch
all clients over to using predicates instead of these flags directly.
These are now private values which are only to be used to statically
initialize the tables.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45692 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 06:42:05 +00:00
Chris Lattner
e32d765f99 add more and significantly better comments to the rest of the machineinstr
flags that can be set.  Add predicates for the ones lacking it, and switch
some clients over to using the predicates instead of Flags directly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45690 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 06:21:53 +00:00
Chris Lattner
f86e1df877 simplify some code using new predicates
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45689 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 05:40:58 +00:00
Chris Lattner
8f707e15fb rename hasVariableOperands() -> isVariadic(). Add some comments.
Evan, please review the comments I added to getNumDefs to make sure
that they are accurate, thx.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45687 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 05:19:29 +00:00
Chris Lattner
349c495200 Move a bunch more accessors from TargetInstrInfo to TargetInstrDescriptor
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45680 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 03:13:06 +00:00
Chris Lattner
ba6da5d5b7 remove some uses of MachineOpCode, move getSchedClass
into TargetInstrDescriptor from TargetInstrInfo.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45678 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 02:46:03 +00:00
Chris Lattner
8ca5c67c6e Add predicates methods to TargetOperandInfo, and switch all clients
over to using them, instead of diddling Flags directly.  Change the
various flags from const variables to enums.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45677 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 02:39:19 +00:00
Gordon Henriksen
572742e876 Setting GlobalDirective in TargetAsmInfo by default rather than
providing a misleading facility. It's used once in the MIPS backend
and hardcoded as "\t.globl\t" everywhere else.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45676 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 02:31:11 +00:00
Chris Lattner
69244300b8 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.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45674 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 01:56:04 +00:00
Owen Anderson
6425f8be72 Update CodeGen for MRegisterInfo --> TargetInstrInfo changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45673 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 01:35:56 +00:00
Gordon Henriksen
93f96d00bf Ammending r45669 with a missing file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45671 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 01:33:09 +00:00
Gordon Henriksen
8fa8929177 With this patch, the LowerGC transformation becomes the
ShadowStackCollector, which additionally has reduced overhead with
no sacrifice in portability.

Considering a function @fun with 8 loop-local roots,
ShadowStackCollector introduces the following overhead
(x86):

; shadowstack prologue
        movl    L_llvm_gc_root_chain$non_lazy_ptr, %eax
        movl    (%eax), %ecx
        movl    $___gc_fun, 20(%esp)
        movl    $0, 24(%esp)
        movl    $0, 28(%esp)
        movl    $0, 32(%esp)
        movl    $0, 36(%esp)
        movl    $0, 40(%esp)
        movl    $0, 44(%esp)
        movl    $0, 48(%esp)
        movl    $0, 52(%esp)
        movl    %ecx, 16(%esp)
        leal    16(%esp), %ecx
        movl    %ecx, (%eax)

; shadowstack loop overhead
        (none)

; shadowstack epilogue
        movl    48(%esp), %edx
        movl    %edx, (%ecx)

; shadowstack metadata
        .align  3
___gc_fun:                              # __gc_fun
        .long   8
        .space  4

In comparison to LowerGC:

; lowergc prologue
        movl    L_llvm_gc_root_chain$non_lazy_ptr, %eax
        movl    (%eax), %ecx
        movl    %ecx, 48(%esp)
        movl    $8, 52(%esp)
        movl    $0, 60(%esp)
        movl    $0, 56(%esp)
        movl    $0, 68(%esp)
        movl    $0, 64(%esp)
        movl    $0, 76(%esp)
        movl    $0, 72(%esp)
        movl    $0, 84(%esp)
        movl    $0, 80(%esp)
        movl    $0, 92(%esp)
        movl    $0, 88(%esp)
        movl    $0, 100(%esp)
        movl    $0, 96(%esp)
        movl    $0, 108(%esp)
        movl    $0, 104(%esp)
        movl    $0, 116(%esp)
        movl    $0, 112(%esp)

; lowergc loop overhead
        leal    44(%esp), %eax
        movl    %eax, 56(%esp)
        leal    40(%esp), %eax
        movl    %eax, 64(%esp)
        leal    36(%esp), %eax
        movl    %eax, 72(%esp)
        leal    32(%esp), %eax
        movl    %eax, 80(%esp)
        leal    28(%esp), %eax
        movl    %eax, 88(%esp)
        leal    24(%esp), %eax
        movl    %eax, 96(%esp)
        leal    20(%esp), %eax
        movl    %eax, 104(%esp)
        leal    16(%esp), %eax
        movl    %eax, 112(%esp)

; lowergc epilogue
        movl    48(%esp), %edx
        movl    %edx, (%ecx)

; lowergc metadata
        (none)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45670 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 01:30:53 +00:00
Gordon Henriksen
ce2247755e Enabling the target-independent garbage collection infrastructure by hooking it
up to the various compiler pipelines.

This doesn't actually add support for any GC algorithms, which means it 
temporarily breaks a few tests. To be fixed shortly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45669 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 01:30:38 +00:00
Chris Lattner
834f1ce031 rename isLoad -> isSimpleLoad due to evan's desire to have such a predicate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45667 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-06 23:38:27 +00:00
Chris Lattner
2e48a70b35 rename isStore -> mayStore to more accurately reflect what it captures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45656 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-06 08:36:04 +00:00
Duncan Sands
920595a960 Remove an unused variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45655 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-06 07:43:13 +00:00
Chris Lattner
19033bf7f8 make this build with newer gcc's
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45637 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-05 23:29:51 +00:00
Nate Begeman
2281a99141 If custom lowering of insert element fails, the result Val will be 0.
Don't overwrite a variable used by the fallthrough code path in this
case.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45630 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-05 20:47:37 +00:00
Chris Lattner
54b62f3af5 Fix build issue on certain compilers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45629 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-05 20:15:42 +00:00
Chris Lattner
e430e1c072 The current impl is really trivial, add some comments about how it can be made better.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45625 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-05 06:47:58 +00:00
Chris Lattner
3c42f12118 allow sinking to be enabled for the jit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45624 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-05 06:14:16 +00:00
Chris Lattner
ba84ed7e92 don't sink anything with side effects, this makes lots of stuff work, but sinks almost nothing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45617 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-05 02:33:22 +00:00
Chris Lattner
9bb459b554 fix a common crash.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45614 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-05 01:39:17 +00:00
Owen Anderson
a393cd3306 I should not be allowed to commit when sleepy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45608 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-05 00:48:55 +00:00
Bill Wendling
67d65bb69d Don't recalculate the loop info and loop dominators analyses if they're
preserved.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45596 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-04 20:54:55 +00:00
Bill Wendling
2674d71df0 80-column violations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45574 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-04 08:59:18 +00:00
Bill Wendling
d5da7048c2 Add that this preserves some analyses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45573 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-04 08:48:49 +00:00
Bill Wendling
cc8f603f53 Move option to enable machine LICM into LLVMTargetMachine.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45572 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-04 08:11:03 +00:00
Bill Wendling
b082c6f5d9 Call the parent's getAnalysisUsage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45571 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-04 07:50:05 +00:00
Chris Lattner
c4ce73f666 Add a really quick hack at a machine code sinking pass, enabled with --enable-sinking.
It is missing validity checks, so it is known broken.  However, it is powerful enough
to compile this contrived code:

void test1(int C, double A, double B, double *P) {
  double Tmp = A*A+B*B;
  *P = C ? Tmp : A;
}

into:

_test1:
	movsd	8(%esp), %xmm0
	cmpl	$0, 4(%esp)
	je	LBB1_2	# entry
LBB1_1:	# entry
	movsd	16(%esp), %xmm1
	mulsd	%xmm1, %xmm1
	mulsd	%xmm0, %xmm0
	addsd	%xmm1, %xmm0
LBB1_2:	# entry
	movl	24(%esp), %eax
	movsd	%xmm0, (%eax)
	ret

instead of:

_test1:
	movsd	16(%esp), %xmm0
	mulsd	%xmm0, %xmm0
	movsd	8(%esp), %xmm1
	movapd	%xmm1, %xmm2
	mulsd	%xmm2, %xmm2
	addsd	%xmm0, %xmm2
	cmpl	$0, 4(%esp)
	je	LBB1_2	# entry
LBB1_1:	# entry
	movapd	%xmm2, %xmm1
LBB1_2:	# entry
	movl	24(%esp), %eax
	movsd	%xmm1, (%eax)
	ret

woo.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45570 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-04 07:36:53 +00:00
Chris Lattner
ac69582664 remove dead #includes and reorder the rest.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45569 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-04 06:41:45 +00:00
Bill Wendling
dde059a9de Use the correct MachineRegisterInfo object.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45499 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-02 21:10:54 +00:00
Bill Wendling
a4b662272d Remove dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45496 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-02 20:47:37 +00:00
Bill Wendling
9258cd3994 Use the new architecture to get the containing machine basic block for a machine
instruction. Also, use "splice" to move the new instruction instead of
remove/insert (where it was leaking memory anyway).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45492 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-02 19:32:43 +00:00
Owen Anderson
f6372aa1cc Move some more instruction creation methods from RegisterInfo into InstrInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45484 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-01 21:11:32 +00:00
Chris Lattner
80fe5311b5 Make MachineRegisterInfo::getVRegDef more efficient by aiming the keep the def of the vreg at the start of the list, so the list doesn't need to be traversed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45483 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-01 21:08:22 +00:00
Chris Lattner
e138b3dd1f switch the register iterator to act more like hte LLVM value iterator: dereferencing
it now returns the machineinstr of the use.  To get the operand, use I.getOperand().

Add a new MachineRegisterInfo::replaceRegWith, which is basically like
Value::replaceAllUsesWith.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45482 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-01 20:36:19 +00:00
Chris Lattner
a91a7d594f Add a trivial but handy function to efficiently return the machine
instruction that defines the specified vreg.  Crazy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45480 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-01 03:07:29 +00:00
Chris Lattner
62ed6b9ade Implement automatically updated def/use lists for all MachineInstr register
operands.  The lists are currently kept in MachineRegisterInfo, but it does
not yet provide an iterator interface to them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45477 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-01 01:12:31 +00:00
Chris Lattner
6410552250 Fix a problem where lib/Target/TargetInstrInfo.h would include and use
a header file from libcodegen.  This violates a layering order: codegen
depends on target, not the other way around.  The fix to this is to 
split TII into two classes, TII and TargetInstrInfoImpl, which defines
stuff that depends on libcodegen.  It is defined in libcodegen, where 
the base is not.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45475 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-01 01:03:04 +00:00
Duncan Sands
b027fa001f Fix PR1833 - eh.exception and eh.selector return two
values, which means doing extra legalization work.
It would be easier to get this kind of thing right if
there was some documentation...


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45472 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-31 18:35:50 +00:00
Owen Anderson
d10fd9791c Move copyRegToReg from MRegisterInfo to TargetInstrInfo. This is part of the
Machine-level API cleanup instigated by Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45470 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-31 06:32:00 +00:00
Chris Lattner
f20c1a497f properly encapsulate the parent field of MBB and MI with get/set accessors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45469 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-31 04:56:33 +00:00
Chris Lattner
534bcfb270 update a couple of references to SSARegMap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45468 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-31 04:16:08 +00:00
Chris Lattner
84bc5427d6 Rename SSARegMap -> MachineRegisterInfo in keeping with the idea
that "machine" classes are used to represent the current state of
the code being compiled.  Given this expanded name, we can start 
moving other stuff into it.  For now, move the UsedPhysRegs and
LiveIn/LoveOuts vectors from MachineFunction into it.

Update all the clients to match.

This also reduces some needless #includes, such as MachineModuleInfo
from MachineFunction.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45467 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-31 04:13:23 +00:00
Chris Lattner
8aa797aa51 Add new shorter predicates for testing machine operands for various types:
e.g. MO.isMBB() instead of MO.isMachineBasicBlock().  I don't plan on 
switching everything over, so new clients should just start using the 
shorter names.

Remove old long accessors, switching everything over to use the short
accessor: getMachineBasicBlock() -> getMBB(), 
getConstantPoolIndex() -> getIndex(), setMachineBasicBlock -> setMBB(), etc.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45464 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 23:10:15 +00:00
Chris Lattner
f73823000e More cleanups for MachineOperand:
- Eliminate the static "print" method for operands, moving it
    into MachineOperand::print.
  - Change various set* methods for register flags to take a bool
    for the value to set it to.  Remove unset* methods.
  - Group methods more logically by operand flavor in MachineOperand.h


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45461 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 21:56:09 +00:00
Chris Lattner
e3087890ac MachineOperand:
- Add getParent() accessors.
  - Move SubReg out of the AuxInfo union, to make way for future changes.
  - Remove the getImmedValue/setImmedValue methods.
  - in some MachineOperand::Create* methods, stop initializing fields that are dead.

MachineInstr:
  - Delete one copy of the MachineInstr printing code, now there is only one dump
    format and one copy of the code.
  - Make MachineOperand use the parent field to get info about preg register names if
    no target info is otherwise available.
  - Move def/use/kill/dead flag printing to the machineoperand printer, so they are
    always printed for an operand.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45460 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 21:31:53 +00:00
Chris Lattner
1c3e1e2ed0 fix typo duncan noticed!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45459 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 21:21:10 +00:00
Chris Lattner
e26dcfe6af simpilfy some register printing code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45458 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 21:08:36 +00:00
Chris Lattner
7da5313d3f eliminate a copy of the machineoperand printing stuff. Keep the copy that
knows how to print offsets.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45457 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 21:03:30 +00:00
Chris Lattner
fde5f801be Simplify and clean up some machine operand/instr printing/dumping stuff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45456 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 21:01:27 +00:00
Chris Lattner
0974d9a524 two register machineoperands are not identical unless their subregs match.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45455 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 20:55:08 +00:00
Chris Lattner
9e3304900f MachineOperand::getImmedValue -> MachineOperand::getImm
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45454 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 20:50:28 +00:00
Chris Lattner
e12d6abfdf make machine operands fatter: give each one an up-pointer to the
machineinstr that owns it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45449 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 06:11:04 +00:00
Chris Lattner
9ce2e9d5a0 use simplified operand addition methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45436 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 00:57:42 +00:00
Chris Lattner
fec65d5562 use simplified operand addition methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45435 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 00:51:11 +00:00
Chris Lattner
8019f41c0b Start using the simplified methods for adding operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45432 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 00:41:17 +00:00
Chris Lattner
a4161ee994 simplify some code by factoring operand construction better.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45428 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 00:12:25 +00:00
Chris Lattner
4ee451de36 Remove attribution from file headers, per discussion on llvmdev.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45418 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 20:36:04 +00:00
Chris Lattner
fc643c5e88 remove attribution from lib Makefiles.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45415 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 20:09:26 +00:00
Chris Lattner
63079f0757 Fold comparisons against a constant nan, and optimize ORD/UNORD
comparisons with a constant.  This allows us to compile isnan to:

_foo:
	fcmpu cr7, f1, f1
	mfcr r2
	rlwinm r3, r2, 0, 31, 31
	blr 

instead of:

LCPI1_0:					;  float
	.space	4
_foo:
	lis r2, ha16(LCPI1_0)
	lfs f0, lo16(LCPI1_0)(r2)
	fcmpu cr7, f1, f0
	mfcr r2
	rlwinm r3, r2, 0, 31, 31
	blr 



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45405 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 08:37:08 +00:00
Chris Lattner
b253a8b382 make sure not to zap volatile stores, thanks a lot to Dale for noticing this!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45402 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 07:15:45 +00:00
Chris Lattner
5938bef2d2 don't fold fp_round(fp_extend(load)) -> fp_round(extload)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45400 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 06:55:23 +00:00
Chris Lattner
3c87285af6 Delete a store whose input is a load from the same pointer:
x = load p
  store x -> p


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45398 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 06:26:16 +00:00
Owen Anderson
f1519e8361 Flesh out the Briggs implementation a little bit more, fix a few FIXMEs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45347 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-24 22:12:23 +00:00
Owen Anderson
efbcebc95d Sketch out an implementation of Briggs' copy placement algorithm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45334 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-23 15:37:26 +00:00
Chris Lattner
2ceb2cfa8e initial code for forming an FGETSIGN node. This is disabled until
legalizer support goes in.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45323 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-22 21:35:38 +00:00
Chris Lattner
d268a497f9 improve support for fgetsign
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45322 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-22 21:26:52 +00:00
Chris Lattner
b16f55f3c8 Tell TargetLoweringOpt whether it is running before
or after legalize.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45321 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-22 20:56:36 +00:00
Chris Lattner
1a3048bb8e Add a new FGETSIGN operation, which defaults to expand on all
targets.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45320 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-22 20:47:56 +00:00
Gordon Henriksen
a6c9925087 Use getIntrinsicID instead of looking up intrinsic prototypes. Also
fixes a bug with indirect calls. (Test case will be included with
ocaml collector patch.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45316 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-22 17:27:01 +00:00
Owen Anderson
cae8d8d4be Note what still needs doing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45310 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-22 04:59:10 +00:00
Owen Anderson
22c43b2988 Remove critical edge breaking. It won't be necessary as long as we are very careful when inserting copies.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45309 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-22 04:50:11 +00:00
Evan Cheng
180c210a1d More accurate checks for two-address constraints.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45259 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-20 09:25:31 +00:00
Evan Cheng
689494208b The physical register + virtual register joining requirement was much too strict.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45253 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-20 02:23:25 +00:00
Evan Cheng
d6c0758944 Bring back a burr scheduling heuristic that's still needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45252 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-20 02:22:36 +00:00
Bill Wendling
60ff1a3005 Updated comments to reflect what "side effects" means in this situation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45245 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-20 01:08:10 +00:00
Duncan Sands
6f74b48862 Simplify LowerCallTo by using a callsite.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45198 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-19 09:48:52 +00:00
Duncan Sands
481dc721c3 The C++ exception handling personality function wants
to know about calls that cannot throw ('nounwind'):
if such a call does throw for some reason then the
personality will terminate the program.  The distinction
between an ordinary call and a nounwind call is that
an ordinary call gets an entry in the exception table
but a nounwind call does not.  This patch sets up the
exception table appropriately.  One oddity is that
I've chosen to bracket nounwind calls with labels (like
invokes) - the other choice would have been to bracket
ordinary calls with labels.  While bracketing
ordinary calls is more natural (because bracketing
by labels would then correspond exactly to getting an
entry in the exception table), I didn't do it because
introducing labels impedes some optimizations and I'm
guessing that ordinary calls occur more often than
nounwind calls.  This fixes the gcc filter2 eh test,
at least at -O0 (the inliner needs some tweaking at
higher optimization levels).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45197 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-19 07:36:31 +00:00
Evan Cheng
02132d62c1 Don't leave newly created nodes around if it turns out they are not needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45186 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-19 01:34:38 +00:00
Bill Wendling
280f4565eb Add debugging info. Use the newly created "hasUnmodelledSideEffects" method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45178 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-18 21:38:04 +00:00
Anton Korobeynikov
feb8893d17 Support more insane CEP's in AsmPrinter (Yes, PyPy folks do really use them).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45172 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-18 20:53:41 +00:00
Evan Cheng
636e5a216c Fix PR1872: SrcValue and SrcValueOffset should not be used to compute load / store node id.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45167 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-18 19:38:14 +00:00
Evan Cheng
8131013861 Also print alignment and volatileness.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45164 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-18 19:06:30 +00:00
Evan Cheng
beec823d4b FIX for PR1799: When a load is unfolded from an instruction, check if it is a new node. If not, do not create a new SUnit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45157 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-18 08:42:10 +00:00
Evan Cheng
88ce93e0ef SelectionDAG::dump() should print SrcValue of LoadSDNode and StoreSDNode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45151 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-18 07:02:08 +00:00
Duncan Sands
fd7b326bea Make invokes of inline asm legal. Teach codegen
how to lower them (with no attempt made to be
efficient, since they should only occur for
unoptimized code).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45108 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-17 18:08:19 +00:00
Christopher Lamb
43ad6b3e0d Change the PointerType api for creating pointer types. The old functionality of PointerType::get() has become PointerType::getUnqual(), which returns a pointer in the generic address space. The new prototype of PointerType::get() requires both a type and an address space.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45082 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-17 01:12:55 +00:00
Owen Anderson
87a702be1a Break local interferences in StrongPHIElimination. One step closer...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45070 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-16 05:44:27 +00:00
Owen Anderson
965b467767 A few more comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45069 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-16 04:07:23 +00:00
Dan Gohman
ded2b0d0fb Add explicit keywords, and fix a minor typo that they uncovered.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45034 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-14 15:41:34 +00:00
Evan Cheng
7c07aebd19 Bug fix. Must also match ResNo when matching an operand with a user.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45028 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-14 08:25:15 +00:00
Owen Anderson
62d67dd3a3 Add register pairs to the list to check for local interferences.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44987 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-13 05:53:03 +00:00