summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Instructions.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fixes following the CR by Chris and Duncan:Nadav Rotem2011-08-291-8/+11
| | | | | | | Optimize chained bitcasts of the form A->B->A. Undo r138722 and change isEliminableCastPair to allow this case. llvm-svn: 138756
* Initial commit of the 'landingpad' instruction.Bill Wendling2011-08-121-0/+89
| | | | | | | | | | | | This implements the 'landingpad' instruction. It's used to indicate that a basic block is a landing pad. There are several restrictions on its use (see LangRef.html for more detail). These restrictions allow the exception handling code to gather the information it needs in a much more sane way. This patch has the definition, implementation, C interface, parsing, and bitcode support in it. llvm-svn: 137501
* Whitespace.Eli Friedman2011-08-101-1/+1
| | | | llvm-svn: 137226
* Representation of 'atomic load' and 'atomic store' in IR.Eli Friedman2011-08-091-12/+88
| | | | llvm-svn: 137170
* Add the 'resume' instruction for the new EH rewrite.Bill Wendling2011-07-311-0/+39
| | | | | | | | | This adds the 'resume' instruction class, IR parsing, and bitcode reading and writing. The 'resume' instruction resumes propagation of an existing (in-flight) exception whose unwinding was interrupted with a 'landingpad' instruction (to be added later). llvm-svn: 136589
* Revert r136253, r136263, r136269, r136313, r136325, r136326, r136329, r136338,Bill Wendling2011-07-301-120/+2
| | | | | | | r136339, r136341, r136369, r136387, r136392, r136396, r136429, r136430, r136444, r136445, r136446, r136253 pending review. llvm-svn: 136556
* LangRef and basic memory-representation/reading/writing for 'cmpxchg' andEli Friedman2011-07-281-0/+111
| | | | | | | | | | | | | | | | | | | | | 'atomicrmw' instructions, which allow representing all the current atomic rmw intrinsics. The allowed operands for these instructions are heavily restricted at the moment; we can probably loosen it a bit, but supporting general first-class types (where it makes sense) might get a bit complicated, given how SelectionDAG works. As an initial cut, these operations do not support specifying an alignment, but it would be possible to add if we think it's useful. Specifying an alignment lower than the natural alignment would be essentially impossible to support on anything other than x86, but specifying a greater alignment would be possible. I can't think of any useful optimizations which would use that information, but maybe someone else has ideas. Optimizer/codegen support coming soon. llvm-svn: 136404
* The personality function should be a Function* and not just a Value*.Bill Wendling2011-07-281-2/+2
| | | | llvm-svn: 136392
* Don't add in the asked for size so that we don't copy too much from the old ↵Bill Wendling2011-07-281-3/+3
| | | | | | to new vectors. llvm-svn: 136338
* Make sure that the landingpad instruction takes a Constant* as the clause's ↵Bill Wendling2011-07-281-2/+2
| | | | | | value. llvm-svn: 136326
* Add a couple of convenience functions:Bill Wendling2011-07-281-0/+17
| | | | | | | * InvokeInst: Get the landingpad instruction associated with this invoke. * LandingPadInst: A method to reserve extra space for clauses. llvm-svn: 136325
* Merge the contents from exception-handling-rewrite to the mainline.Bill Wendling2011-07-271-2/+103
| | | | | | This adds the new instructions 'landingpad' and 'resume'. llvm-svn: 136253
* Initial implementation of 'fence' instruction, the new C++0x-style ↵Eli Friedman2011-07-251-0/+24
| | | | | | | | replacement for llvm.memory.barrier. This is just a LangRef entry and reading/writing/memory representation; optimizer+codegen support coming soon. llvm-svn: 136009
* Convert GetElementPtrInst to use ArrayRef.Jay Foad2011-07-251-73/+16
| | | | llvm-svn: 135904
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-181-90/+90
| | | | llvm-svn: 135375
* Convert CallInst and InvokeInst APIs to use ArrayRef.Jay Foad2011-07-151-89/+30
| | | | llvm-svn: 135265
* Convert InsertValueInst and ExtractValueInst APIs to use ArrayRef.Jay Foad2011-07-131-53/+17
| | | | llvm-svn: 135040
* Land the long talked about "type system rewrite" patch. ThisChris Lattner2011-07-091-42/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | patch brings numerous advantages to LLVM. One way to look at it is through diffstat: 109 files changed, 3005 insertions(+), 5906 deletions(-) Removing almost 3K lines of code is a good thing. Other advantages include: 1. Value::getType() is a simple load that can be CSE'd, not a mutating union-find operation. 2. Types a uniqued and never move once created, defining away PATypeHolder. 3. Structs can be "named" now, and their name is part of the identity that uniques them. This means that the compiler doesn't merge them structurally which makes the IR much less confusing. 4. Now that there is no way to get a cycle in a type graph without a named struct type, "upreferences" go away. 5. Type refinement is completely gone, which should make LTO much MUCH faster in some common cases with C++ code. 6. Types are now generally immutable, so we can use "Type *" instead "const Type *" everywhere. Downsides of this patch are that it removes some functions from the C API, so people using those will have to upgrade to (not yet added) new API. "LLVM 3.0" is the right time to do this. There are still some cleanups pending after this, this patch is large enough as-is. llvm-svn: 134829
* Reinstate r133513 (reverted in r133700) with an additional fix for aJay Foad2011-06-231-25/+31
| | | | | | -Wshorten-64-to-32 warning in Instructions.h. llvm-svn: 133708
* Revert r133513:Eric Christopher2011-06-231-31/+25
| | | | | | | | | "Reinstate r133435 and r133449 (reverted in r133499) now that the clang self-hosted build failure has been fixed (r133512)." Due to some additional warnings. llvm-svn: 133700
* Reinstate r133435 and r133449 (reverted in r133499) now that the clangJay Foad2011-06-211-25/+31
| | | | | | self-hosted build failure has been fixed (r133512). llvm-svn: 133513
* Revert r133435 and r133449 to appease buildbots.Chad Rosier2011-06-211-31/+25
| | | | llvm-svn: 133499
* Fix a check for PHINodes with two incoming values.Jay Foad2011-06-201-1/+1
| | | | llvm-svn: 133449
* Change how PHINodes store their operands.Jay Foad2011-06-201-24/+30
| | | | | | | | | | | | | | | | | | | Change PHINodes to store simple pointers to their incoming basic blocks, instead of full-blown Uses. Note that this loses an optimization in SplitCriticalEdge(), because we can no longer walk the use list of a BasicBlock to find phi nodes. See the comment I removed starting "However, the foreach loop is slow for blocks with lots of predecessors". Extend replaceAllUsesWith() on a BasicBlock to also update any phi nodes in the block's successors. This mimics what would have happened when PHINodes were proper Users of their incoming blocks. (Note that this only works if OldBB->replaceAllUsesWith(NewBB) is called when OldBB still has a terminator instruction, so it still has some successors.) llvm-svn: 133435
* Now that SrcBits and DestBits always represent the primitive size, ratherDuncan Sands2011-05-181-55/+29
| | | | | | | | | than either the primitive size or the element primitive size (in the case of vectors), simplify the vector logic. No functionality change. There is some distracting churn in the patch because I lined up comments better while there - sorry about that. llvm-svn: 131533
* Tighten up checking of the validity of casts. (1) The IR parser wouldDuncan Sands2011-05-181-32/+28
| | | | | | | | | | | | | | happily accept things like "sext <2 x i32> to <999 x i64>". It would also accept "sext <2 x i32> to i64", though the verifier would catch that later. Fixed by having castIsValid check that vector lengths match except when doing a bitcast. (2) When creating a cast instruction, check that the cast is valid (this was already done when creating constexpr casts). While there, replace getScalarSizeInBits (used to allow more vector casts) with getPrimitiveSizeInBits in getCastOpcode and isCastable since vector to vector casts are now handled explicitly by passing to the element types; i.e. this bit should result in no functional change. llvm-svn: 131532
* Teach getCastOpcode about element-by-element vector casts. For example, "trunc"Duncan Sands2011-05-181-4/+25
| | | | | | | | | | | | | can be used to turn a <4 x i64> into a <4 x i32> but getCastOpcode would assert if you passed these types to it. Note that this strictly extends the previous functionality: if getCastOpcode previously accepted two vector types (i.e. didn't assert) then it still will and returns the same opcode (BitCast). That's because before it would only accept vectors with the same bitwidth, and the new code only touches vectors with the same length. However if two vectors have both the same bitwidth and the same length then their element types have the same bitwidth, so the new logic will return BitCast as before. llvm-svn: 131530
* Phi nodes always use an even number of operands, so don't ever allocateJay Foad2011-04-111-1/+2
| | | | | | an odd number. llvm-svn: 129270
* Various Instructions' resizeOperands() methods are only used to grow theJay Foad2011-04-011-54/+16
| | | | | | list of operands. Simplify and rename them accordingly. llvm-svn: 128708
* While testing dragonegg I noticed that isCastable and getCastOpcodeDuncan Sands2011-04-011-4/+12
| | | | | | | | had gotten out of sync: isCastable didn't think it was possible to cast the x86_mmx type to anything, while it did think it possible to cast an i64 to x86_mmx. llvm-svn: 128705
* enhance vmcore to know that udiv's can be exact, and add a trivialChris Lattner2011-02-061-2/+2
| | | | | | | | instcombine xform to exercise this. Nothing forms exact udivs yet though. This is progress on PR8862 llvm-svn: 124992
* Make SwitchInst::removeCase() more efficient.Jay Foad2011-02-011-8/+4
| | | | llvm-svn: 124659
* Simplify the construction and destruction of Uses. SimplifyJay Foad2011-01-161-8/+7
| | | | | | User::dropHungOffUses(). llvm-svn: 123580
* Remove casts between Value** and Constant**, which won't work if aJay Foad2011-01-141-0/+6
| | | | | | | static_cast from Constant* to Value* has to adjust the "this" pointer. This is groundwork for PR889. llvm-svn: 123435
* Simplify the allocation and freeing of Users' operand lists, now thatJay Foad2011-01-071-27/+1
| | | | | | every BranchInst has a fixed number of operands. llvm-svn: 123027
* These methods should be "const"; make them so.Duncan Sands2011-01-041-4/+4
| | | | llvm-svn: 122809
* Change all self assignments X=X to (void)X, so that we can turn on aJeffrey Yasskin2010-12-231-6/+6
| | | | | | | new gcc warning that complains on self-assignments and self-initializations. llvm-svn: 122458
* Fix PR 4170 by having ExtractValueInst::getIndexedType() reject ↵Frits van Bommel2010-12-051-7/+24
| | | | | | | | out-of-bounds indexing. Also add asserts that the indices are valid in InsertValueInst::init(). ExtractValueInst already asserts when constructed with invalid indices. llvm-svn: 120956
* fix PR8613 - Copy constructor of SwitchInst does not call SwitchInst::initChris Lattner2010-11-171-8/+9
| | | | llvm-svn: 119463
* Fix a layering violation: hasConstantValue, which is part of the PHINodeDuncan Sands2010-11-171-56/+7
| | | | | | | | | | | | | | class, uses DominatorTree which is an analysis. This change moves all of the tricky hasConstantValue logic to SimplifyInstruction, and replaces it with a very simple literal implementation. I already taught users of hasConstantValue that need tricky stuff to use SimplifyInstruction instead. I didn't update InlineFunction because the IR looks like it might be in a funky state at the point it calls hasConstantValue, which makes calling SimplifyInstruction dangerous since it can in theory do a lot of tricky reasoning. This may be a pessimization, for example in the case where all phi node operands are either undef or a fixed constant. llvm-svn: 119459
* If dom tree information is available, make it possible to passDuncan Sands2010-11-141-1/+1
| | | | | | it to get better phi node simplification. llvm-svn: 119055
* Cleanup. Get rid of extraneous variable.Bill Wendling2010-10-031-3/+2
| | | | llvm-svn: 115453
* Attempt to outwit overly smart compiler.Dale Johannesen2010-10-011-0/+1
| | | | llvm-svn: 115251
* Massive rewrite of MMX: Dale Johannesen2010-09-301-0/+14
| | | | | | | | | | | | | | | | | | | The x86_mmx type is used for MMX intrinsics, parameters and return values where these use MMX registers, and is also supported in load, store, and bitcast. Only the above operations generate MMX instructions, and optimizations do not operate on or produce MMX intrinsics. MMX-sized vectors <2 x i32> etc. are lowered to XMM or split into smaller pieces. Optimizations may occur on these forms and the result casted back to x86_mmx, provided the result feeds into a previous existing x86_mmx operation. The point of all this is prevent optimizations from introducing MMX operations, which is unsafe due to the EMMS problem. llvm-svn: 115243
* Make this code 65-bit clean.Dan Gohman2010-09-271-1/+1
| | | | llvm-svn: 114828
* Move some code from Verifier into SVI::isValidOperands. This allows us to ↵Nate Begeman2010-08-131-2/+17
| | | | | | catch bad shufflevector operations when they are created, rather than waiting for someone to notice later on. llvm-svn: 110986
* remove the private hack from CallInst, it was not supposed to hit the branch ↵Gabor Greif2010-08-051-1/+1
| | | | | | | | | anyway as a positive consequence the CallSite::getCallee() methods now can be rewritten to be a bit more efficient llvm-svn: 110380
* Define a maximum supported alignment value for load, store, andDan Gohman2010-07-281-0/+8
| | | | | | | | | alloca instructions (constrained by their internal encoding), and add error checking for it. Fix an instcombine bug which generated huge alignment values (null is infinitely aligned). This fixes undefined behavior noticed by John Regehr. llvm-svn: 109643
* eliminate CallInst::ArgOffsetGabor Greif2010-07-161-12/+10
| | | | llvm-svn: 108522
* Convert some tab stops into spaces.Duncan Sands2010-07-121-1/+1
| | | | llvm-svn: 108130
OpenPOWER on IntegriCloud