summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Instructions.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove dead code. Improve llvm_unreachable text. Simplify some control flow.Ahmed Charles2012-02-191-13/+4
| | | | llvm-svn: 150918
* [unwind removal] Remove all of the code for the dead 'unwind' instruction. ThereBill Wendling2012-02-061-33/+2
| | | | | | | were no 'unwind' instructions being generated before this, so this is in effect a no-op. llvm-svn: 149906
* Convert assert(0) to llvm_unreachableCraig Topper2012-02-051-21/+13
| | | | llvm-svn: 149849
* SwitchInst refactoring.Stepan Dyatkovskiy2012-02-011-11/+9
| | | | | | | | | | | | | | | | | The purpose of refactoring is to hide operand roles from SwitchInst user (programmer). If you want to play with operands directly, probably you will need lower level methods than SwitchInst ones (TerminatorInst or may be User). After this patch we can reorganize SwitchInst operands and successors as we want. What was done: 1. Changed semantics of index inside the getCaseValue method: getCaseValue(0) means "get first case", not a condition. Use getCondition() if you want to resolve the condition. I propose don't mix SwitchInst case indexing with low level indexing (TI successors indexing, User's operands indexing), since it may be dangerous. 2. By the same reason findCaseValue(ConstantInt*) returns actual number of case value. 0 means first case, not default. If there is no case with given value, ErrorIndex will returned. 3. Added getCaseSuccessor method. I propose to avoid usage of TerminatorInst::getSuccessor if you want to resolve case successor BB. Use getCaseSuccessor instead, since internal SwitchInst organization of operands/successors is hidden and may be changed in any moment. 4. Added resolveSuccessorIndex and resolveCaseIndex. The main purpose of these methods is to see how case successors are really mapped in TerminatorInst. 4.1 "resolveSuccessorIndex" was created if you need to level down from SwitchInst to TerminatorInst. It returns TerminatorInst's successor index for given case successor. 4.2 "resolveCaseIndex" converts low level successors index to case index that curresponds to the given successor. Note: There are also related compatability fix patches for dragonegg, klee, llvm-gcc-4.0, llvm-gcc-4.2, safecode, clang. llvm-svn: 149481
* continue making the world safe for ConstantDataVector. At this point,Chris Lattner2012-01-271-4/+2
| | | | | | | we should (theoretically optimize and codegen ConstantDataVector as well as ConstantVector. llvm-svn: 149116
* eliminate the Constant::getVectorElements method. There are better (andChris Lattner2012-01-261-8/+8
| | | | | | | more robust) ways to do what it was doing now. Also, add static methods for decoding a ShuffleVector mask. llvm-svn: 149028
* fix pasto in the new (and still unused) ShuffleVectorInst::getShuffleMask ↵Chris Lattner2012-01-261-1/+1
| | | | | | method. llvm-svn: 149005
* add some helper methods to ShuffleVectorInst and enhance itsChris Lattner2012-01-251-28/+55
| | | | | | | "isValidOperands" and "getMaskValue" methods to allow ConstantDataSequential. llvm-svn: 148998
* use ConstantVector::getSplat in a few places.Chris Lattner2012-01-251-23/+4
| | | | llvm-svn: 148929
* Remove the Type::getNumElements() method, which is only called in 4 places,Chris Lattner2012-01-251-2/+8
| | | | | | | did something extremely surprising, and shadowed actually useful implementations that had completely different behavior. llvm-svn: 148898
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-7/+2
| | | | llvm-svn: 148578
* Add support for vectors of pointers.Nadav Rotem2011-12-051-3/+31
| | | | llvm-svn: 145801
* Add some missing anchors.David Blaikie2011-12-011-0/+2
| | | | llvm-svn: 145578
* The bitcode reader can create an shuffle with a place holder mask which it willMon P Wang2011-10-261-3/+10
| | | | | | | fix up later. For this special case, allow such a mask to be considered valid. <rdar://problem/8622574> llvm-svn: 142992
* Add a routine to swap branch instruction operands, and update anyChandler Carruth2011-10-171-0/+21
| | | | | | | | | | | | profile metadata at the same time. Use it to preserve metadata attached to a branch when re-writing it in InstCombine. Add metadata to the canonicalize_branch InstCombine test, and check that it is tranformed correctly. Reviewed by Nick Lewycky! llvm-svn: 142168
* Change:Richard Trieu2011-09-211-12/+12
| | | | | | | | | | | | assert(!"error message"); To: assert(0 && "error message"); which is more consistant across the code base. llvm-svn: 140234
* 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
OpenPOWER on IntegriCloud