summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT
Commit message (Collapse)AuthorAgeFilesLines
...
* [APInt] Fix bugs in isShiftedMask to match behavior of the similar function ↵Craig Topper2017-03-311-8/+8
| | | | | | | | | | in MathExtras.h This removes a parameter from the routine that was responsible for a lot of the issue. It was a bit count that had to be set to the BitWidth of the APInt and would get passed to getLowBitsSet. This guaranteed the call to getLowBitsSet would create an all ones value. This was then compared to (V | (V-1)). So the only shifted masks we detected had to have the MSB set. The one in tree user is a transform in InstCombine that never fires due to earlier transforms covering the case better. I've submitted a patch to remove it completely, but for now I've just adapted it to the new interface for isShiftedMask. llvm-svn: 299273
* Fix 80-column violation in previous commit.Stephen Canon2017-03-311-1/+2
| | | | llvm-svn: 299257
* Fix APFloat mod (committing for simonbyrne)Stephen Canon2017-03-311-2/+65
| | | | | | | | The previous version was prone to intermediate rounding or overflow. Differential Revision: https://reviews.llvm.org/D29346 llvm-svn: 299256
* [APInt] Rewrite getLoBits in a way that will do one less memory allocation ↵Craig Topper2017-03-311-0/+18
| | | | | | in the multiword case. Rewrite getHiBits to use the class method version of lshr instead of the one in APIntOps. NFCI llvm-svn: 299243
* Spelling mistakes in comments. NFCI.Simon Pilgrim2017-03-311-1/+1
| | | | llvm-svn: 299197
* [APInt] Add unittests that demonstrate how very broken ↵Craig Topper2017-03-311-0/+25
| | | | | | | | | | APIntOps::isShiftedMask is. Did you know that 0 is a shifted mask? But 0x0000ff00 and 0x000000ff aren't? At least we get 0xff000000 right. I only see one usage of this function in the code base today and its in InstCombine. I think its protected against 0 being misreported as a mask. I guess we just don't have tests for the missed cases. llvm-svn: 299187
* [APInt] Use memset in setAllBits.Craig Topper2017-03-271-0/+38
| | | | llvm-svn: 298867
* ADT: Add range helpers for pointer_ and pointee_iteratorJustin Bogner2017-03-271-0/+16
| | | | llvm-svn: 298841
* Resubmit "Improve StringMap iterator support."Zachary Turner2017-03-211-0/+29
| | | | | | | The issue was trying to advance past the end of the iterator when computing the end() iterator. llvm-svn: 298461
* Revert "Improve StringMap iterator support."Zachary Turner2017-03-211-29/+0
| | | | | | | This is causing crashes in clang, so reverting until the problem is figured out. llvm-svn: 298440
* Improve StringMap iterator support.Zachary Turner2017-03-211-0/+29
| | | | | | | | | | | | | | | | | | StringMap's iterators did not support LLVM's iterator_facade_base, which made it unusable in various STL algorithms or with some of our range adapters. This patch makes both StringMapConstIterator as well as StringMapIterator support iterator_facade_base. With this in place, it is easy to make an iterator adapter that iterates over only keys, and whose value_type is StringRef. So I add StringMapKeyIterator as well, and provide the method StringMap::keys() that returns a range that can be iterated. Differential Revision: https://reviews.llvm.org/D31171 llvm-svn: 298436
* [ADT] Add a version of llvm::join() that takes a range.Zachary Turner2017-03-211-0/+2
| | | | llvm-svn: 298427
* Fix sign compare warning in unit test by using an explicit unsigned literal ↵David Blaikie2017-03-131-1/+1
| | | | | | suffix llvm-svn: 297674
* [ADT] Improve the genericity of llvm::enumerate().Zachary Turner2017-03-131-7/+17
| | | | | | | | | | | | | | There were some issues in the implementation of enumerate() preventing it from being used in various contexts. These were all related to the fact that it did not supporter llvm's iterator_facade_base class. So this patch adds support for that and additionally exposes a new helper method to_vector() that will evaluate an entire range and store the results in a vector. Differential Revision: https://reviews.llvm.org/D30853 llvm-svn: 297633
* Fix signed/unsigned comparison warningsSimon Pilgrim2017-03-101-11/+11
| | | | llvm-svn: 297460
* [APInt] Add APInt::insertBits() method to insert an APInt into a larger APIntSimon Pilgrim2017-03-101-0/+53
| | | | | | | | | | | | We currently have to insert bits via a temporary variable of the same size as the target with various shift/mask stages, resulting in further temporary variables, all of which require the allocation of memory for large APInts (MaskSizeInBits > 64). This is another of the compile time issues identified in PR32037 (see also D30265). This patch adds the APInt::insertBits() helper method which avoids the temporary memory allocation and masks/inserts the raw bits directly into the target. Differential Revision: https://reviews.llvm.org/D30780 llvm-svn: 297458
* Add support for DenseMap/DenseSet count and find using const pointersDaniel Berlin2017-03-102-0/+27
| | | | | | | | | | | | | | Summary: Similar to SmallPtrSet, this makes find and count work with both const referneces and const pointers. Reviewers: dblaikie Subscribers: llvm-commits, mzolotukhin Differential Revision: https://reviews.llvm.org/D30713 llvm-svn: 297424
* [Unittests] Fix a build failure with clang 3.8. NFCI.Davide Italiano2017-03-091-1/+1
| | | | llvm-svn: 297423
* ADT: Fix SmallPtrSet iterators in reverse modeDuncan P. N. Exon Smith2017-03-071-7/+25
| | | | | | | | | | | | | | | | | | | | | | | | Fix SmallPtrSet::iterator behaviour and creation ReverseIterate is true. - Any function that creates an iterator now uses SmallPtrSet::makeIterator, which creates an iterator that dereferences to the given pointer. - In reverse-iterate mode, initialze iterator::End with "CurArray" instead of EndPointer. - In reverse-iterate mode, the current node is iterator::Buffer[-1]. iterator::operator* and SmallPtrSet::makeIterator are the only ones that need to know. - Fix the assertions for reverse-iterate mode. This fixes the tests Danny B added in r297182, and adds a couple of others to confirm that dereferencing does the right thing, regardless of how the iterator was found, and that iteration works correctly from each return from find. llvm-svn: 297234
* Strip trailing whitespace.Simon Pilgrim2017-03-071-4/+1
| | | | llvm-svn: 297225
* Add unit tests for changes to SmallPtrSet and PointerLikeTypeTraitsDaniel Berlin2017-03-071-0/+33
| | | | llvm-svn: 297182
* [APInt] Add rvalue reference support to and, or, xor operations to allow ↵Craig Topper2017-03-071-0/+120
| | | | | | | | | | | | | | | | their memory allocation to be reused when possible This extends an earlier change that did similar for add and sub operations. With this first patch we lose the fastpath for the single word case as operator&= and friends don't support it. This can be added there if we think that's important. I had to change some functions in the APInt class since the operator overloads were moved out of the class and can't be used inside the class now. The getBitsSet change collides with another outstanding patch to implement it with setBits. But I didn't want to make this patch dependent on that series. I've also removed the Or, And, Xor functions which were rarely or never used. I already commited two changes to remove the only uses of Or that existed. Differential Revision: https://reviews.llvm.org/D30612 llvm-svn: 297121
* [APInt] Fix test names in unittest to match functions being tested. NFCCraig Topper2017-03-071-2/+2
| | | | llvm-svn: 297115
* [APInt] Add getBitsSetFrom and setBitsFrom to set upper bits starting at a bitCraig Topper2017-03-071-0/+21
| | | | | | | | | | | | We currently have methods to set a specified number of low bits, a specified number of high bits, or a range of bits. But looking at some existing code it seems sometimes we want to set the high bits starting from a certain bit. Currently we do this with something like getHighBits(BitWidth, BitWidth - StartBit). Or once we start switching to setHighBits, setHighBits(BitWidth - StartBit) or setHighBits(getBitWidth() - StartBit). Particularly for the latter case it would be better to have a convenience method like setBitsFrom(StartBit) so we don't need to mention the bit width that's already known to the APInt object. I considered just making setBits have a default value of UINT_MAX for the hiBit argument and we would internally MIN it with the bit width. So if it wasn't specified it would be treated as bit width. This would require removing the assertion we currently have on the value of hiBit and may not be as readable. Differential Revision: https://reviews.llvm.org/D30602 llvm-svn: 297114
* [APInt] Implement getLowBitsSet/getHighBitsSet/getBitsSet using ↵Craig Topper2017-03-071-0/+18
| | | | | | | | | | | | setLowBits/setHighBits/setBits This patch implements getLowBitsSet/getHighBitsSet/getBitsSet in terms of the new setLowBits/setHighBits/setBits methods by making an all 0s APInt and then calling the appropriate set method. This also adds support to setBits to allow loBits/hiBits to be in the other order to match with getBitsSet behavior. Differential Revision: https://reviews.llvm.org/D30563 llvm-svn: 297112
* [APInt] Add setLowBits/setHighBits methods to APInt.Craig Topper2017-03-071-0/+121
| | | | | | | | | | | | | | | | | | | | | Summary: There are quite a few places in the code base that do something like the following to set the high or low bits in an APInt. KnownZero |= APInt::getHighBitsSet(BitWidth, BitWidth - 1); For BitWidths larger than 64 this creates a short lived APInt with malloced storage. I think it might even call malloc twice. Its better to just provide methods that can set the necessary bits without the temporary APInt. I'll update usages that benefit in a separate patch. Reviewers: majnemer, MatzeB, davide, RKSimon, hans Reviewed By: hans Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D30525 llvm-svn: 297111
* [APInt] Move operator~ out of line to make it better able to reused memory ↵Craig Topper2017-03-061-0/+24
| | | | | | | | | | | | | | | | | | | allocation from temporary objects Summary: This makes operator~ take the APInt by value so if it came from a temporary APInt the move constructor will get invoked and it will be able to reuse the memory allocation from the temporary. This is similar to what was already done for 2s complement negation. Reviewers: hans, davide, RKSimon Reviewed By: davide Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D30614 llvm-svn: 296997
* Set default CPU for OpenBSD/arm to Cortex-A8Brad Smith2017-02-281-0/+4
| | | | llvm-svn: 296493
* [APInt] Use UINT64_MAX instead of ~0ULL. NFCCraig Topper2017-02-261-0/+10
| | | | llvm-svn: 296300
* [APInt] Remove unnecessary early out from getLowBitsSet. The same case is ↵Craig Topper2017-02-261-0/+10
| | | | | | handled equally well by the next check. llvm-svn: 296299
* [APInt] Add APInt::extractBits() method to extract APInt subrange (reapplied)Simon Pilgrim2017-02-251-0/+16
| | | | | | | | | | | | | | | | The current pattern for extract bits in range is typically: Mask.lshr(BitOffset).trunc(SubSizeInBits); Which can be particularly slow for large APInts (MaskSizeInBits > 64) as they require the allocation of memory for the temporary variable. This is another of the compile time issues identified in PR32037 (see also D30265). This patch adds the APInt::extractBits() helper method which avoids the temporary memory allocation. Differential Revision: https://reviews.llvm.org/D30336 llvm-svn: 296272
* Revert: r296141 [APInt] Add APInt::extractBits() method to extract APInt ↵Simon Pilgrim2017-02-241-12/+0
| | | | | | | | | | | | | | | | | | subrange The current pattern for extract bits in range is typically: Mask.lshr(BitOffset).trunc(SubSizeInBits); Which can be particularly slow for large APInts (MaskSizeInBits > 64) as they require the allocation of memory for the temporary variable. This is another of the compile time issues identified in PR32037 (see also D30265). This patch adds the APInt::extractBits() helper method which avoids the temporary memory allocation. Differential Revision: https://reviews.llvm.org/D30336 llvm-svn: 296147
* [APInt] Add APInt::extractBits() method to extract APInt subrangeSimon Pilgrim2017-02-241-0/+12
| | | | | | | | | | | | | | | | The current pattern for extract bits in range is typically: Mask.lshr(BitOffset).trunc(SubSizeInBits); Which can be particularly slow for large APInts (MaskSizeInBits > 64) as they require the allocation of memory for the temporary variable. This is another of the compile time issues identified in PR32037 (see also D30265). This patch adds the APInt::extractBits() helper method which avoids the temporary memory allocation. Differential Revision: https://reviews.llvm.org/D30336 llvm-svn: 296141
* Fix signed/unsigned comparison warningsSimon Pilgrim2017-02-241-4/+4
| | | | llvm-svn: 296109
* [APInt] Add APInt::setBits() method to set all bits in rangeSimon Pilgrim2017-02-241-0/+94
| | | | | | | | | | | | | | | | | | The current pattern for setting bits in range is typically: Mask |= APInt::getBitsSet(MaskSizeInBits, LoPos, HiPos); Which can be particularly slow for large APInts (MaskSizeInBits > 64) as they require the allocation memory for the temporary variable. This is one of the key compile time issues identified in PR32037. This patch adds the APInt::setBits() helper method which avoids the temporary memory allocation completely, this first implementation uses setBit() internally instead but already significantly reduces the regression in PR32037 (~10% drop). Additional optimization may be possible. I investigated whether there is need for APInt::clearBits() and APInt::flipBits() equivalents but haven't seen these patterns to be particularly common, but reusing the code would be trivial. Differential Revision: https://reviews.llvm.org/D30265 llvm-svn: 296102
* [ADT] Fix zip iterator interface.Bryant Wong2017-02-231-4/+53
| | | | | | | | | | | | This commit provides `zip_{first,shortest}` with the standard member types and methods expected of iterators (e.g., `difference_type`), in order for zip to be used with other adaptors, such as `make_filter_range`. Support for reverse iteration has also been added. Differential Revision: https://reviews.llvm.org/D30246 llvm-svn: 296036
* Remove uses of deprecated std::random_shuffle in the LLVM code base. ↵Marshall Clow2017-02-161-8/+2
| | | | | | Reviewed as https://reviews.llvm.org/D29780. llvm-svn: 295325
* [Support] Add StringRef::getAsDouble.Zachary Turner2017-02-141-0/+21
| | | | | | Differential Revision: https://reviews.llvm.org/D29918 llvm-svn: 295089
* Fix some missing negations in the traits checking from r294349David Blaikie2017-02-071-4/+4
| | | | llvm-svn: 294357
* ADT: Add explicit conversions for reverse ilist iteratorsDuncan P. N. Exon Smith2017-02-071-0/+40
| | | | | | | | | | | | | | | Add explicit conversions between forward and reverse ilist iterators. These follow the conversion conventions of std::reverse_iterator, which are off-by-one: the newly-constructed "reverse" iterator dereferences to the previous node of the one sent in. This has the benefit of converting reverse ranges in place: - If [I, E) is a valid range, - then [reverse(E), reverse(I)) gives the same range in reverse order. ilist_iterator::getReverse() is unchanged: it returns a reverse iterator to the *same* node. llvm-svn: 294349
* [APInt] Fix rotl/rotr when the shift amount is greater than the total bit width.Joey Gouly2017-02-071-2/+52
| | | | | Review: https://reviews.llvm.org/D27749 llvm-svn: 294295
* TripleTest.FileFormat: check non-default valueAlex Denisov2017-02-041-0/+3
| | | | | | | Triple::objectFormat defaults to an Elf format. Changing objectFormat to Elf doesn't make any difference. llvm-svn: 294104
* TripleTest.BitWidthArchVariants: add missing arch types (thumb, arm, le, ...)Alex Denisov2017-02-041-0/+48
| | | | llvm-svn: 294096
* TripleTest.EndianArchVariants: add missing arch types (tce, le)Alex Denisov2017-02-041-0/+16
| | | | llvm-svn: 294095
* [APInt] Add integer API bor bitwise operations.Amaury Sechet2017-02-031-0/+52
| | | | | | | | | | | | Summary: As per title. I ran into that limitation of the API doing some other work, so I though that'd be a nice addition. Reviewers: jroelofs, compnerd, majnemer Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29503 llvm-svn: 294063
* DAGCombiner: Allow negating ConstantFP after legalizeMatt Arsenault2017-01-251-0/+22
| | | | llvm-svn: 293019
* Add test for default construction coverage of DenseSet iterators.Dean Michael Berris2017-01-241-1/+8
| | | | | | This is a follow-up to D28999. llvm-svn: 292885
* Allow DenseSet::iterators to be conveted to and compared with const_iteratorDean Michael Berris2017-01-241-0/+9
| | | | | | | | | | | | | | | | | | | | | | Summary: This seemed to be an oversight seeing as DenseMap has these conversions. This patch does the following: - Adds a default constructor to the iterators. - Allows DenseSet::ConstIterators to be copy constructed from DenseSet::Iterators - Allows mutual comparison between Iterators and ConstIterators. All of these are available in the DenseMap implementation, so the implementation here is trivial. Reviewers: dblaikie, dberris Reviewed By: dberris Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D28999 llvm-svn: 292879
* [APInt] Remove calls to clearUnusedBits from XorSlowCase and operator^=Craig Topper2017-01-241-0/+30
| | | | | | | | | | | | | | | | | Summary: There's a comment in XorSlowCase that says "0^0==1" which isn't true. 0 xored with 0 is still 0. So I don't think we need to clear any unused bits here. Now there is no difference between XorSlowCase and AndSlowCase/OrSlowCase other than the operation being performed Reviewers: majnemer, MatzeB, chandlerc, bkramer Reviewed By: MatzeB Subscribers: chfast, llvm-commits Differential Revision: https://reviews.llvm.org/D28986 llvm-svn: 292873
* [APFloat] Add PPCDoubleDouble multiplicationTim Shen2017-01-241-34/+173
| | | | | | | | | | Reviewers: echristo, hfinkel, kbarton, iteratee Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D28382 llvm-svn: 292860
OpenPOWER on IntegriCloud