Commit Graph

25332 Commits

Author SHA1 Message Date
Dan Gohman c835458da9 When the coalescer is doing rematerializing, have it remove
the copy instruction from the instruction list before asking the
target to create the new instruction. This gets the old instruction
out of the way so that it doesn't interfere with the target's
rematerialization code. In the case of x86, this helps it find
more cases where EFLAGS is not live.

Also, in the X86InstrInfo.cpp, teach isSafeToClobberEFLAGS to check
to see if it reached the end of the block after scanning each
instruction, instead of just before. This lets it notice when the
end of the block is only two instructions away, without doing any
additional scanning.

These changes allow rematerialization to clobber EFLAGS in more
cases, for example using xor instead of mov to set the return value
to zero in the included testcase.

llvm-svn: 57872
2008-10-21 03:24:31 +00:00
Dan Gohman 97d3f6cfe3 Make the NaN test come second, heuristically assuming
that NaNs are less common.

llvm-svn: 57871
2008-10-21 03:12:54 +00:00
Dan Gohman 72e66eedb8 Use Function::getEntryBlock() instead of Function::front(), for clarity.
llvm-svn: 57870
2008-10-21 03:10:28 +00:00
Oscar Fuentes 0e12e5b12c CMake: updated lib/CodeGen/CMakeLists.txt
llvm-svn: 57869
2008-10-21 02:37:50 +00:00
Dan Gohman fa29b67aee Fix a bug that prevented llvm-extract -delete from working.
llvm-svn: 57864
2008-10-21 01:08:07 +00:00
Chris Lattner 4396e0d2c3 Fix gcc.c-torture/compile/920520-1.c by inserting bitconverts
for strange asm conditions earlier.  In this case, we have a
double being passed in an integer reg class.  Convert to like
sized integer register so that we allocate the right number 
for the class (two i32's for the f64 in this case).

llvm-svn: 57862
2008-10-21 00:45:36 +00:00
Evan Cheng 7e721ecd21 Add skeleton for the pre-register allocation live interval splitting pass.
llvm-svn: 57847
2008-10-20 21:44:59 +00:00
Jim Grosbach 9396051e3d Update the stub and callback code to handle lazy compilation. The stub
is re-written by the callback to branch directly to the compiled code
in future invocations.

Added back in range-based memory permission functions for the updating of
the stub on Darwin.

llvm-svn: 57846
2008-10-20 21:39:23 +00:00
Dan Gohman 1a59b3b9b8 Fast-isel no longer an experiment.
llvm-svn: 57845
2008-10-20 21:30:12 +00:00
Evan Cheng bc623edaba Add a register class -> virtual registers map.
llvm-svn: 57844
2008-10-20 20:03:28 +00:00
Duncan Sands aac74a9055 Support operations like fp_to_uint with a vector
result type when the result type is legal but
not the operand type.  Add additional support
for EXTRACT_SUBVECTOR and CONCAT_VECTORS,
needed to handle such cases.

llvm-svn: 57840
2008-10-20 16:31:21 +00:00
Duncan Sands e0fb87acf6 LegalizeTypes support for atomic operation promotion.
llvm-svn: 57838
2008-10-20 16:17:42 +00:00
Duncan Sands 840143fc6f Use DAG.getIntPtrConstant rather than DAG.getConstant
with TLI.getPointerTy for a small simplification.

llvm-svn: 57837
2008-10-20 16:14:43 +00:00
Duncan Sands 5805334d5b Always use either MVT::i1 or getSetCCResultType for
the condition of a SELECT node.  Make sure that the
correct extension type (any-, sign- or zero-extend)
is used.

llvm-svn: 57836
2008-10-20 16:13:04 +00:00
Duncan Sands fe9b5550de Formatting - no functional change.
llvm-svn: 57834
2008-10-20 16:06:47 +00:00
Duncan Sands 3ed8b29ace Don't use a random type for the select condition,
use an MVT::i1 and simplify the code while there.

llvm-svn: 57833
2008-10-20 16:04:57 +00:00
Duncan Sands 1d20ab5784 Have X86 custom lowering for LegalizeTypes use
LowerOperation if it doesn't know what else to do.
This methods should probably be factorized some,
but this is good enough for the moment.  Have
LowerATOMIC_BINARY_64 use EXTRACT_ELEMENT rather
than assuming the operand is a BUILD_PAIR (if it
is then getNode will automagically simplify the
EXTRACT_ELEMENT).  This way LowerATOMIC_BINARY_64
usable from LegalizeTypes.

llvm-svn: 57831
2008-10-20 15:56:33 +00:00
Bill Wendling 8ec2a4a96c Set N->OperandList to 0 after deletion. Otherwise, it's possible that it will
be either deleted or referenced afterwards.

llvm-svn: 57786
2008-10-19 20:51:12 +00:00
Bill Wendling 6c87bfc6fd Fix comment. Other formatting changes. No functionality changes.
llvm-svn: 57785
2008-10-19 20:34:04 +00:00
Duncan Sands 8d11adca4c Vector shuffle mask elements may be "undef". Handle
this everywhere in LegalizeTypes.

llvm-svn: 57783
2008-10-19 15:00:25 +00:00
Duncan Sands c6d12bd665 Use a legal integer type for vector shuffle mask
elements.  Otherwise LegalizeTypes will, reasonably
enough, legalize the mask, which may result in it
no longer being a BUILD_VECTOR node (LegalizeDAG
simply ignores the legality or not of vector masks).

llvm-svn: 57782
2008-10-19 14:58:05 +00:00
Chris Lattner 160e8abd77 Reapply r57699 with a fix to not crash on asms with multiple results. Unlike
the previous patch this one actually passes make check.

"Fix PR2356 on PowerPC: if we have an input and output that are tied together
that have different sizes (e.g. i32 and i64) make sure to reserve registers for
the bigger operand."

llvm-svn: 57771
2008-10-18 18:49:30 +00:00
Dan Gohman 727a94063c Don't truncate GlobalAddress offsets to int in debug output.
llvm-svn: 57770
2008-10-18 18:22:42 +00:00
Evan Cheng 2dadd3bbc6 By min, I mean max.
llvm-svn: 57766
2008-10-18 05:21:37 +00:00
Evan Cheng ac4e70d946 When creating intervals, leave min(1, numdefs) holes after each instruction.
llvm-svn: 57765
2008-10-18 05:18:55 +00:00
Dan Gohman 2fe6bee5b6 Teach DAGCombine to fold constant offsets into GlobalAddress nodes,
and add a TargetLowering hook for it to use to determine when this
is legal (i.e. not in PIC mode, etc.)

This allows instruction selection to emit folded constant offsets
in more cases, such as the included testcase, eliminating the need
for explicit arithmetic instructions.

This eliminates the need for the C++ code in X86ISelDAGToDAG.cpp
that attempted to achieve the same effect, but wasn't as effective.

Also, fix handling of offsets in GlobalAddressSDNodes in several
places, including changing GlobalAddressSDNode's offset from
int to int64_t.

The Mips, Alpha, Sparc, and CellSPU targets appear to be
unaware of GlobalAddress offsets currently, so set the hook to
false on those targets.

llvm-svn: 57748
2008-10-18 02:06:02 +00:00
Dan Gohman 6de2556205 Revert r57699. It's causing regressions in
test/CodeGen/X86/2008-09-17-inline-asm-1.ll
and a few others, and it breaks the llvm-gcc build.

llvm-svn: 57747
2008-10-18 01:03:45 +00:00
Dan Gohman 209fc26462 This is now partly done.
llvm-svn: 57734
2008-10-17 21:39:27 +00:00
Dan Gohman b1d8d6ecff This is done.
llvm-svn: 57733
2008-10-17 21:38:40 +00:00
Dan Gohman d01ddb51ee Factor out the code for mapping LLVM IR condition opcodes to
ISD condition opcodes into helper functions.

llvm-svn: 57726
2008-10-17 21:16:08 +00:00
Evan Cheng 0fcc89b596 Add implicit defs of XMM8 to XMM15 on 32-bit call instructions. While this is not technically true, it tells tblgen that these instructions "clobber" the entire XMM register file.
llvm-svn: 57723
2008-10-17 21:02:22 +00:00
Evan Cheng 94169f1021 Fix PR2898. Spiller delete a store for reuse before it knows for sure the reuse happened.
Patch by Lang Hames!

llvm-svn: 57720
2008-10-17 20:56:41 +00:00
Chris Lattner aadf7414b2 add support for 128 bit aggregates.
llvm-svn: 57715
2008-10-17 19:59:51 +00:00
Bill Wendling fe9e2c587d The Dwarf writer was comparing mangled and unmangled names for C++ code when we
have an unreachable block in a function. This was triggering the assert. This is
a horrid hack to cover this up.

Oh! for a good debug info architecture!

llvm-svn: 57714
2008-10-17 18:48:57 +00:00
Mon P Wang 85f48ade9c Added MemIntrinsicNode which is useful to represent target intrinsics that
touches memory and need an associated MemOperand

llvm-svn: 57712
2008-10-17 18:22:58 +00:00
Dan Gohman 293abcc91d Factor out the code for mapping LLVM IR condition opcodes to
ISD condition opcodes into helper functions.

llvm-svn: 57710
2008-10-17 18:18:45 +00:00
Chris Lattner 8e2ef196ae add support for 128 bit inputs on both x86-64 and x86-32.
llvm-svn: 57709
2008-10-17 18:15:05 +00:00
Chris Lattner c7e65f4377 Fix a bug where the x86 backend would reject 64-bit r constraints when
in 32-bit mode instead of assigning a register pair.  This has nothing to
do with PR2356, but I happened to notice it while working on it.

llvm-svn: 57704
2008-10-17 17:59:52 +00:00
Chris Lattner 052092bf9c Fix PR2356 on PowerPC: if we have an input and output that are tied together
that have different sizes (e.g. i32 and i64) make sure to reserve registers for
the bigger operand.

llvm-svn: 57699
2008-10-17 17:52:49 +00:00
Evan Cheng 27c3702267 Fix lfence and mfence encoding. These look like MRM5r and MRM6r instructions except they do not have any operands. The RegModRM byte is encoded with register number 0.
llvm-svn: 57692
2008-10-17 17:14:20 +00:00
Evan Cheng 9e23d746bf getX86RegNum has long been moved to X86RegisterInfo.
llvm-svn: 57691
2008-10-17 17:12:18 +00:00
Chris Lattner 3b1833c9b4 refactor some code into a helper method, no functionality change.
llvm-svn: 57690
2008-10-17 17:05:25 +00:00
Chris Lattner 860df6e84c Keep track of *which* input constraint matches an output
constraint.  Reject asms where an output has multiple
input constraints tied to it.

llvm-svn: 57687
2008-10-17 16:47:46 +00:00
Chris Lattner ef8901722e add an assert so that PR2356 explodes instead of running off an
array.  Improve some minor comments, refactor some helpers in
AsmOperandInfo.  No functionality change for valid code.

llvm-svn: 57686
2008-10-17 16:21:11 +00:00
Evan Cheng 08acb24225 Fix a very subtle spiller bug: UpdateKills should not forget to track defs of aliases.
llvm-svn: 57673
2008-10-17 06:16:07 +00:00
Chris Lattner 7e9e3b3d4b add some simple hacky long double support for the CBE. This
should work for intel long double, but ppc long double aborts
in convert.

llvm-svn: 57672
2008-10-17 06:11:48 +00:00
Dan Gohman ca0546facc Fun x86 encoding tricks: when adding an immediate value of 128,
use a SUB instruction instead of an ADD, because -128 can be
encoded in an 8-bit signed immediate field, while +128 can't be.
This avoids the need for a 32-bit immediate field in this case.

A similar optimization applies to 64-bit adds with 0x80000000,
with the 32-bit signed immediate field.

To support this, teach tablegen how to handle 64-bit constants.

llvm-svn: 57663
2008-10-17 01:33:43 +00:00
Dan Gohman a39b0a1f05 Define patterns for shld and shrd that match immediate
shift counts, and patterns that match dynamic shift counts
when the subtract is obscured by a truncate node.

Add DAGCombiner support for recognizing rotate patterns
when the shift counts are defined by truncate nodes.

Fix and simplify the code for commuting shld and shrd
instructions to work even when the given instruction doesn't
have a parent, and when the caller needs a new instruction.

These changes allow LLVM to use the shld, shrd, rol, and ror
instructions on x86 to replace equivalent code using two
shifts and an or in many more cases.

llvm-svn: 57662
2008-10-17 01:23:35 +00:00
Dan Gohman 215742a966 Use 0 instead of false to return a null pointer.
llvm-svn: 57660
2008-10-17 00:56:52 +00:00
Dan Gohman e33afda4fa Trim #includes.
llvm-svn: 57649
2008-10-16 20:18:31 +00:00
Chris Lattner ba88d86a65 fix typo noticed by sdt
llvm-svn: 57644
2008-10-16 17:02:50 +00:00
Gabor Greif 0bd120e817 Introduce a typing refinenement on tagged data
using the 'volatile' qualifier. This should not have any operational consequences
on code, because tags should always be stripped off (giving a non-volatile pointer)
before dereferencing. The new qualification is there to catch some attempts to use
tagged pointers in a context where an untagged pointer is appropriate.

Notably this approach does not catch dereferencing of tagged pointers, but helps
in separating the two concepts a bit.

llvm-svn: 57641
2008-10-16 15:33:02 +00:00
Duncan Sands dc84511146 Fix warnings about mb/me being potentially used
uninitialized in these functions with gcc-4.3.

llvm-svn: 57635
2008-10-16 13:02:33 +00:00
Duncan Sands 1c7f8901c6 Fix "large integer implicitly truncated to unsigned type"
warning on x86-64 with gcc-4.3.

llvm-svn: 57634
2008-10-16 09:14:58 +00:00
Chris Lattner 305fb0a7ba add some notes
llvm-svn: 57631
2008-10-16 07:04:06 +00:00
Chris Lattner 29628cc5da add some notes and a file to collect unimplemented features in the
x86 backend.  These will all be answered with "patches welcome", so
a PR doesn't help drive them along.

llvm-svn: 57630
2008-10-16 06:46:12 +00:00
Chris Lattner 122c9b1b22 mark some targets as experimental. Andrew, if you think that Alpha is
basically working, feel free to remove the tag.  The other targets have
really basic things that break them.

llvm-svn: 57628
2008-10-16 06:16:50 +00:00
Chris Lattner 229f765dbe Verify prefetch arguments, PR2576.
llvm-svn: 57626
2008-10-16 06:00:36 +00:00
Chris Lattner 1baace07c4 apply Eli's patch for PR2165 and provide a testcase.
llvm-svn: 57625
2008-10-16 05:26:51 +00:00
Dan Gohman 33332bce17 Const-ify several TargetInstrInfo methods.
llvm-svn: 57622
2008-10-16 01:49:15 +00:00
Dan Gohman 4a87660127 Remove an unused variable.
llvm-svn: 57621
2008-10-16 01:47:47 +00:00
Dan Gohman fc27e25a6e Fix Instruction::isIdenticalTo and isSameOperationAs to recognize
additional information in Loads, Stores, Calls, Invokes,
InsertValueInsts, and ExtractValueInsts.

llvm-svn: 57620
2008-10-16 01:24:45 +00:00
Dan Gohman 0b3bcee284 Rename AliasSet to SubRegs, to reflect changes in the surrounding code.
llvm-svn: 57618
2008-10-16 01:06:18 +00:00
Dan Gohman 6613991eae Move the include of MachineLocation.h into MachineModuleInfo.h
because it declares a std::vector<MachineMove>, and strict
concept checking requires the definition of MachineMove to be
available.

llvm-svn: 57617
2008-10-16 00:20:14 +00:00
Dan Gohman bf293c48db Fix a subtle bug in DeadMachineInstructionElim's liveness
computation. A def of a register doesn't necessarily kill
live super-registers.

llvm-svn: 57614
2008-10-16 00:11:23 +00:00
Dan Gohman 6bae5268a7 Fix the predicate for memop64 to be a regular load, not just
an unindexed load.

llvm-svn: 57612
2008-10-16 00:03:00 +00:00
Dan Gohman bc0278400c Teach instcombine's visitLoad to scan back several instructions
to find opportunities for store-to-load forwarding or load CSE,
in the same way that visitStore scans back to do DSE. Also, define
a new helper function for testing whether the addresses of two
memory accesses are known to have the same value, and use it in
both visitStore and visitLoad.

These two changes allow instcombine to eliminate loads in code
produced by front-ends that frequently emit obviously redundant
addressing for memory references.

llvm-svn: 57608
2008-10-15 23:19:35 +00:00
Dan Gohman 7847142f26 Correct the name of isTrapping in comments.
llvm-svn: 57606
2008-10-15 22:56:21 +00:00
Anton Korobeynikov 006659f08d Also properly handle linking of strong alias and weak global
llvm-svn: 57595
2008-10-15 20:10:50 +00:00
Anton Korobeynikov 82dd61114d Properly handle linking of strong alias with weak function, this fixes PR2883
llvm-svn: 57594
2008-10-15 20:10:08 +00:00
Dan Gohman c7e00ba60f Fix a missing space after the return type in invoke statements.
This fixes PR2894.

llvm-svn: 57589
2008-10-15 18:02:08 +00:00
Chris Lattner 9b83197b76 move PR1941 here.
llvm-svn: 57586
2008-10-15 16:33:52 +00:00
Chris Lattner 6d275fd6e1 move PR1604 here.
llvm-svn: 57582
2008-10-15 16:06:03 +00:00
Chris Lattner 843dacc937 move PR1488 into this file.
llvm-svn: 57579
2008-10-15 16:02:15 +00:00
Nuno Lopes 6cbd4430cc regenerate
llvm-svn: 57577
2008-10-15 12:05:02 +00:00
Nuno Lopes 99f3dc6798 fix memleak in GetForwardRefForGlobal()
llvm-svn: 57576
2008-10-15 12:04:36 +00:00
Nuno Lopes 6f6e4e94be regenerate
llvm-svn: 57575
2008-10-15 11:20:21 +00:00
Nuno Lopes a4a546cb40 fix memleak in getTypeVal()
llvm-svn: 57574
2008-10-15 11:19:34 +00:00
Nuno Lopes bb683f953e regenerate
llvm-svn: 57573
2008-10-15 11:11:12 +00:00
Nuno Lopes 48e9028000 fix memleak in ResolveTypeTo()
llvm-svn: 57572
2008-10-15 11:10:21 +00:00
Dan Gohman 29ad439782 Now that predicates can be composed, simplify several of
the predicates by extending simple predicates to create
more complex predicates instead of duplicating the logic
for the simple predicates.

This doesn't reduce much redundancy in DAGISelEmitter.cpp's
generated source yet; that will require improvements to
DAGISelEmitter.cpp's instruction sorting, to make it more
effectively group nodes with similar predicates together.

llvm-svn: 57565
2008-10-15 06:50:19 +00:00
Chris Lattner 3f399451cd regenerate
llvm-svn: 57561
2008-10-15 06:16:57 +00:00
Chris Lattner 25f74dc574 Fix the .ll grammar rules to allow any type before an 'i32', not just an
integer type.  Invalid things like 'float 42' are now rejected by the
semantic analysis in the productions not the parser.  This fixes PR2733.

llvm-svn: 57560
2008-10-15 06:16:45 +00:00
Chris Lattner 9535c94015 regenerate
llvm-svn: 57559
2008-10-15 06:03:48 +00:00
Chris Lattner d253878724 Eliminate the "IntType ::= INTTYPE" production, just use
INTTYPE everywhere.

llvm-svn: 57558
2008-10-15 06:03:37 +00:00
Chris Lattner 117792afec add a note
llvm-svn: 57557
2008-10-15 05:53:25 +00:00
Chris Lattner ddb17ce4be add support for folding immediates into stores when they
are due to argument passing in calls.  This is significant because
it hits all immediate arguments to calls on x86-32.

llvm-svn: 57556
2008-10-15 05:38:32 +00:00
Chris Lattner 3ba293564a fold immediates into stores in simple cases, this produces diffs like
this:

-	movl	$0, %eax
-	movl	%eax, _yy_n_chars
+	movl	$0, _yy_n_chars

llvm-svn: 57555
2008-10-15 05:30:52 +00:00
Chris Lattner e388725aef fold compare of null pointer into compare with 0.
llvm-svn: 57553
2008-10-15 05:18:04 +00:00
Chris Lattner a0f9d4972f Some minor cleanups:
1. Compute action in X86SelectSelect based on MVT instead of type.
2. Use TLI.getValueType(..) instead of MVT::getVT(..) because the former
   handles pointers and the later doesn't.
3. Don't pass TLI into isTypeLegal, since it already has access to it as 
   an ivar.

#2 gives fast isel some minor new functionality: handling load/stores of
pointers.

llvm-svn: 57552
2008-10-15 05:07:36 +00:00
Chris Lattner 74e012839d Use switch on VT instead of Type* comparisons.
llvm-svn: 57551
2008-10-15 04:32:45 +00:00
Chris Lattner dc1c380f23 Use X86FastEmitCompare for FCMP_OEQ and FCMP_UNE: it doesn't
change the generated code, but makes the code simpler.

llvm-svn: 57550
2008-10-15 04:29:23 +00:00
Chris Lattner d46b9510b6 refactor compare emission out into a new X86FastEmitCompare method,
which makes it easy to share the compare/imm folding logic with 'setcc'.
This shaves a bunch of instructions off the common select case, which
happens a lot in llvm-gcc.

llvm-svn: 57549
2008-10-15 04:26:38 +00:00
Chris Lattner 88f4754f8f Fold immediates into compares when possible, producing "cmp $4, %eax" instead of
loading 4 into a register and then doing the compare.

llvm-svn: 57548
2008-10-15 04:13:29 +00:00
Chris Lattner 47bef25c01 more minor refactoring of X86SelectBranch, no functionality change.
llvm-svn: 57547
2008-10-15 04:02:26 +00:00
Chris Lattner 0ce717ac6b factor buildmi calls in X86SelectBranch
llvm-svn: 57546
2008-10-15 03:58:05 +00:00
Chris Lattner f32ce221e4 factor some more BuildMI's in X86SelectCmp
llvm-svn: 57545
2008-10-15 03:52:54 +00:00
Chris Lattner a3596db462 factor some BuildMI calls, no functionality change.
llvm-svn: 57544
2008-10-15 03:47:17 +00:00
Dan Gohman 4459c4250d Adjust whitespace in debug messages to be more consistent
with other debug messages.

llvm-svn: 57543
2008-10-15 02:57:38 +00:00
Evan Cheng 3b0f5e4d61 - Add target lowering hooks that specify which setcc conditions are illegal,
i.e. conditions that cannot be checked with a single instruction. For example,
SETONE and SETUEQ on x86.
- Teach legalizer to implement *illegal* setcc as a and / or of a number of
legal setcc nodes. For now, only implement FP conditions. e.g. SETONE is
implemented as SETO & SETNE, SETUEQ is SETUO | SETEQ.
- Move x86 target over.

llvm-svn: 57542
2008-10-15 02:05:31 +00:00