summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT
Commit message (Collapse)AuthorAgeFilesLines
...
* [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
* [APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to ↵Tim Shen2017-01-231-17/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (IEEEdouble, IEEEdouble) Summary: This patch changes the layout of DoubleAPFloat, and adjust all operations to do either: 1) (IEEEdouble, IEEEdouble) -> (uint64_t, uint64_t) -> PPCDoubleDoubleImpl, then run the old algorithm. 2) Do the right thing directly. 1) includes multiply, divide, remainder, mod, fusedMultiplyAdd, roundToIntegral, convertFromString, next, convertToInteger, convertFromAPInt, convertFromSignExtendedInteger, convertFromZeroExtendedInteger, convertToHexString, toString, getExactInverse. 2) includes makeZero, makeLargest, makeSmallest, makeSmallestNormalized, compare, bitwiseIsEqual, bitcastToAPInt, isDenormal, isSmallest, isLargest, isInteger, ilogb, scalbn, frexp, hash_value, Profile. I could split this into two patches, e.g. use 1) for all operatoins first, then incrementally change some of them to 2). I didn't do that, because 1) involves code that converts data between PPCDoubleDoubleImpl and (IEEEdouble, IEEEdouble) back and forth, and may pessimize the compiler. Instead, I find easy functions and use approach 2) for them directly. Next step is to implement move multiply and divide from 1) to 2). I don't have plans for other functions in 1). Differential Revision: https://reviews.llvm.org/D27872 llvm-svn: 292839
* Add unittests for empty bitvectors.Matthias Braun2017-01-231-0/+37
| | | | | | Addendum to r292575 llvm-svn: 292817
* [ADT] Add SparseBitVector::find_last().Zachary Turner2017-01-171-0/+39
| | | | | | Differential Revision: https://reviews.llvm.org/D28817 llvm-svn: 292288
* [WebAssembly] Add triple support for the new wasm object formatDan Gohman2017-01-171-0/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D26701 llvm-svn: 292252
* [APFloatTest] Add tests for various operationsTim Shen2017-01-051-4/+271
| | | | | | Differential Revision: https://reviews.llvm.org/D27833 llvm-svn: 291189
* [ADT] Attempt to fix GCC warning in IntrusiveRefCntPtrTest.Justin Lebar2017-01-041-1/+3
| | | | | | | Our copy constructor doesn't explicitly invoke the base class's constructor, and GCC is (rightly) concerned. llvm-svn: 291023
* [ADT] Speculative attempt to fix build bot issues with r290952.Chandler Carruth2017-01-041-0/+8
| | | | | | | | | | | | This just removes the usage of llvm::reverse and llvm::seq. That makes it harder to handle the empty case correctly and so I've also added a test there. This is just a shot in the dark at what might be behind the buildbot failures. I can't reproduce any issues locally including with ASan... I feel like I'm missing something... llvm-svn: 290954
* [ADT] Enhance the PriorityWorklist to support bulk insertion.Chandler Carruth2017-01-041-0/+39
| | | | | | | | | | | This is both convenient and more efficient as we can skip any intermediate reallocation of the vector. This usage pattern came up in a subsequent patch on the pass manager, but it seems generically useful so I factored it out and added unittests here. llvm-svn: 290952
* [ADT] Fix for compilation error when operator++(int) (post-increment ↵Abhilash Bhandari2016-12-301-0/+13
| | | | | | | | | | | | | | function) of SmallPtrSetIterator is used. The bug was introduced in r289619. Reviewers: Mehdi Amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D28134 llvm-svn: 290749
* [ADT] Delete RefCountedBaseVPTR.Justin Lebar2016-12-291-19/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This class is unnecessary. Its comment indicated that it was a compile error to allocate an instance of a class that inherits from RefCountedBaseVPTR on the stack. This may have been true at one point, but it's not today. Moreover you really do not want to allocate *any* refcounted object on the stack, vptrs or not, so if we did have a way to prevent these objects from being stack-allocated, we'd want to apply it to regular RefCountedBase too, obviating the need for a separate RefCountedBaseVPTR class. It seems that the main way RefCountedBaseVPTR provides safety is by making its subclass's destructor virtual. This may have been helpful at one point, but these days clang will emit an error if you define a class with virtual functions that inherits from RefCountedBase but doesn't have a virtual destructor. Reviewers: compnerd, dblaikie Subscribers: cfe-commits, klimek, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D28162 llvm-svn: 290717
* [ADT] Add an llvm::erase_if utility to make the standard erase+remove_ifChandler Carruth2016-12-261-0/+11
| | | | | | | | pattern easier to write. Differential Revision: https://reviews.llvm.org/D28120 llvm-svn: 290555
* [ADT] Add a boring std::partition wrapper similar to our std::remove_ifChandler Carruth2016-12-261-0/+21
| | | | | | wrapper. llvm-svn: 290553
* [ADT] Add a generic concatenating iterator and range (take 2).Chandler Carruth2016-12-251-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | This recommits r290512 that was reverted when MSVC failed to compile it. Since then I've played with various approaches using rextester.com (where I was able to reproduce the failure) and think that I have a solution thanks in part to the help of Dave Blaikie! It seems MSVC just has a defective `decltype` in this version. Manually writing out the type seems to do the trick, even though it is .... quite complicated. Original commit message: This allows both defining convenience iterator/range accessors on types which walk across N different independent ranges within the object, and more direct and simple usages with range based for loops such as shown in the unittest. The same facilities are used for both. They end up quite small and simple as it happens. I've also switched an iterator on `Module` to use this. I would like to add another convenience iterator that includes even more sequences as part of it and seeing this one already present motivated me to actually abstract it away and introduce a general utility. Differential Revision: https://reviews.llvm.org/D28093 llvm-svn: 290528
* Revert r290512: [ADT] Add a generic concatenating iterator and range.Chandler Carruth2016-12-251-23/+0
| | | | | | | | This code doesn't work on MSVC for reasons that elude me and I've not yet covinced a workaround to compile cleanly so reverting for now while I play with it. llvm-svn: 290513
* [ADT] Add a generic concatenating iterator and range.Chandler Carruth2016-12-251-0/+23
| | | | | | | | | | | | | | | | | This allows both defining convenience iterator/range accessors on types which walk across N different independent ranges within the object, and more direct and simple usages with range based for loops such as shown in the unittest. The same facilities are used for both. They end up quite small and simple as it happens. I've also switched an iterator on `Module` to use this. I would like to add another convenience iterator that includes even more sequences as part of it and seeing this one already present motivated me to actually abstract it away and introduce a general utility. Differential Revision: https://reviews.llvm.org/D28093 llvm-svn: 290512
* Fix compilation.Evgeniy Stepanov2016-12-171-1/+1
| | | | | | | unittests/ADT/TwineTest.cpp:106:38: error: field 'Count' will be initialized after base 'llvm::FormatAdapter<int>' [-Werror,-Wreorder] explicit formatter(int &Count) : Count(Count), FormatAdapter(0) {} llvm-svn: 290029
* Add support for formatv to llvm::Twine.Zachary Turner2016-12-171-1/+27
| | | | | | Differential Revision: https://reviews.llvm.org/D27835 llvm-svn: 290020
* [APFloatTest] Log when test fails. NFCTim Shen2016-12-161-7/+21
| | | | | | | | | | Reviewers: iteratee Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D27828 llvm-svn: 289904
* Adapt to recent APFloat changeStephan Bergmann2016-12-141-6/+6
| | | | llvm-svn: 289649
* Replace APFloatBase static fltSemantics data members with getter functionsStephan Bergmann2016-12-141-820/+820
| | | | | | | | | | | | | At least the plugin used by the LibreOffice build (<https://wiki.documentfoundation.org/Development/Clang_plugins>) indirectly uses those members (through inline functions in LLVM/Clang include files in turn using them), but they are not exported by utils/extract_symbols.py on Windows, and accessing data across DLL/EXE boundaries on Windows is generally problematic. Differential Revision: https://reviews.llvm.org/D26671 llvm-svn: 289647
* [llvm] Iterate SmallPtrSet in reverse order to uncover non-determinism in ↵Mandeep Singh Grang2016-12-142-0/+40
| | | | | | | | | | | | | | | | | | codegen Summary: Given a flag (-mllvm -reverse-iterate) this patch will enable iteration of SmallPtrSet in reverse order. The idea is to compile the same source with and without this flag and expect the code to not change. If there is a difference in codegen then it would mean that the codegen is sensitive to the iteration order of SmallPtrSet. This is enabled only with LLVM_ENABLE_ABI_BREAKING_CHECKS. Reviewers: chandlerc, dexonsmith, mehdi_amini Subscribers: mgorny, emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D26718 llvm-svn: 289619
* [ADT] Add llvm::StringLiteral.Zachary Turner2016-12-131-0/+6
| | | | | | | | | | | StringLiteral is a wrapper around a string literal useful for replacing global tables of char arrays with global tables of StringRefs that can initialized in a constexpr context, avoiding the invocation of a global constructor. Differential Revision: https://reviews.llvm.org/D27686 llvm-svn: 289551
* [APFloatTest] Use std::make_tuple to make GCC 4.8 happyTim Shen2016-12-121-35/+38
| | | | | | Differential Revision: https://reviews.llvm.org/D26817 llvm-svn: 289474
* [APFloat] Implement PPCDoubleDouble add and subtract.Tim Shen2016-12-121-16/+119
| | | | | | | | | | | | Summary: I looked at libgcc's implementation (which is based on the paper, Software for Doubled-Precision Floating-Point Computations", by Seppo Linnainmaa, ACM TOMS vol 7 no 3, September 1981, pages 272-283.) and made it generic to arbitrary IEEE floats. Differential Revision: https://reviews.llvm.org/D26817 llvm-svn: 289472
* [stl-extras] Provide an adaptor of std::count for ranges.Michael Gottesman2016-12-041-0/+17
| | | | llvm-svn: 288619
* Add some searching functions for ArrayRef<T>.Zachary Turner2016-11-221-0/+44
| | | | | | Differential Revision: https://reviews.llvm.org/D26999 llvm-svn: 287722
* [ADT] Add initializer list support to SmallPtrSet so that sets can beChandler Carruth2016-11-221-4/+10
| | | | | | easily initialized with some initial values. llvm-svn: 287610
* [Support] Add StringRef::find_lower and contains_lower.Zachary Turner2016-11-121-15/+61
| | | | | | Differential Revision: https://reviews.llvm.org/D25299 llvm-svn: 286724
* Add tests for r286139.Jordan Rose2016-11-071-0/+36
| | | | llvm-svn: 286141
* [APFloat] Make functions that produce APFloaat objects use correct semantics.Tim Shen2016-11-061-0/+28
| | | | | | | | | | | | | | | | | Summary: Fixes PR30869. In D25977 I meant to change all functions that care about lifetime. I changed constructors, factory functions, but I missed member/free functions that return new instances. This patch changes them. Reviewers: hfinkel, kbarton, echristo, joerg Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D26269 llvm-svn: 286060
* [ADT] IntervalMap: fix setStart and setStopMichael LeMay2016-11-031-0/+47
| | | | | | | | | | | | | | | | Summary: These functions currently require that the new closed interval has a length of at least 2. They also currently permit empty half-open intervals. This patch defines nonEmpty in each traits structure and uses it to correct the implementations of setStart and setStop. Reviewers: stoklund, chandlerc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D26064 llvm-svn: 285957
* [ilist_node] Add a getReverseIterator() method and a unittest for it.Michael Gottesman2016-11-021-0/+17
| | | | | | This is the reverse_iterator analogue of getIterator(). llvm-svn: 285780
OpenPOWER on IntegriCloud