summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT
Commit message (Collapse)AuthorAgeFilesLines
* Add support for Ananas platformEd Schouten2017-06-251-0/+6
| | | | | | | | | | | | | | | | | Ananas is a home-brew operating system, mainly for amd64 machines. After using GCC for quite some time, it has switched to clang and never looked back - yet, having to manually patch things is annoying, so it'd be much nicer if this was in the official tree. More information: https://github.com/zhmu/ananas/ https://rink.nu/projects/ananas.html Submitted by: Rink Springer Differential Revision: https://reviews.llvm.org/D32937 llvm-svn: 306237
* Fix double->float truncation warning on MSVCSimon Pilgrim2017-06-231-2/+2
| | | | llvm-svn: 306101
* [ADT] Add llvm::to_floatPavel Labath2017-06-231-1/+19
| | | | | | | | | | | | | | | | | | Summary: The function matches the interface of llvm::to_integer, but as we are calling out to a C library function, I let it take a Twine argument, so we can avoid a string copy at least in some cases. I add a test and replace a couple of existing uses of strtod with this function. Reviewers: zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34518 llvm-svn: 306096
* Revert r305642Ismail Donmez2017-06-181-1/+1
| | | | llvm-svn: 305643
* Test to correct triple for SUSE on ARMv7Ismail Donmez2017-06-181-1/+1
| | | | llvm-svn: 305642
* Added braces to work around gcc warning in googletest: suggest explicit ↵Galina Kistanova2017-06-152-3/+6
| | | | | | braces to avoid ambiguous 'else'. NFC. llvm-svn: 305506
* [ADT] Don't use __used__ attribute on struct members in unit testFrancis Ricci2017-06-121-10/+10
| | | | | | | On some compilers, __used__ can only be applied to variables or functions. llvm-svn: 305188
* [ADT] Use LLVM_ATTRIBUTE_USED instead of __attribute__ for unit testFrancis Ricci2017-06-111-5/+5
| | | | llvm-svn: 305168
* [ADT] Suppress unused attribute warning in unit testFrancis Ricci2017-06-111-5/+5
| | | | llvm-svn: 305166
* [SmallVector] Reinstate the typedefs.Davide Italiano2017-06-101-0/+3
| | | | | | | | | They're unused with recent versions of libstdc++ but older ones (e.g. libstdc++ 4.9 still requires them). Maybe we should bump the requirements on the minimum version to make GCC 7 happy, but in the meanwhile we need to live with the warning. llvm-svn: 305158
* [SmallVector] Remove unused typedefs, spotted by GCC 7. NFCI.Davide Italiano2017-06-101-3/+0
| | | | llvm-svn: 305157
* [ADT] Make iterable SmallVector template overrides more specificFrancis Ricci2017-06-091-0/+61
| | | | | | | | | | | | | | | | Summary: This prevents the iterator overrides from being selected in the case where non-iterator types are used as arguments, which is of particular importance in cases where other overrides with identical types exist. Reviewers: dblaikie, bkramer, rafael Subscribers: llvm-commits, efriedma Differential Revision: https://reviews.llvm.org/D33919 llvm-svn: 305105
* Re-sort #include lines for unittests. This uses a slightly modifiedChandler Carruth2017-06-0624-26/+26
| | | | | | | | | | | | | | | clang-format (https://reviews.llvm.org/D33932) to keep primary headers at the top and handle new utility headers like 'gmock' consistently with other utility headers. No other change was made. I did no manual edits, all of this is clang-format. This should allow other changes to have more clear and focused diffs, and is especially motivated by moving some headers into more focused libraries. llvm-svn: 304786
* ADT: handle special case of ARM environment for SUSESaleem Abdulrasool2017-06-031-0/+5
| | | | | | | SUSE treats "gnueabi" as "gnueabihf" so make sure that we normalise the environment. llvm-svn: 304670
* Tidy up a bit of r304516, use SmallVector::assign rather than for loopDavid Blaikie2017-06-021-0/+10
| | | | | | | | | | | | | | | | This might give a few better opportunities to optimize these to memcpy rather than loops - also a few minor cleanups (StringRef-izing, templating (to avoid std::function indirection), etc). The SmallVector::assign(iter, iter) could be improved with the use of SFINAE, but the (iter, iter) ctor and append(iter, iter) need it to and don't have it - so, workaround it for now rather than bothering with the added complexity. (also, as noted in the added FIXME, these assign ops could potentially be optimized better at least for non-trivially-copyable types) llvm-svn: 304566
* Avoid a UB pointer overflow in the ArrayRef unit testVedant Kumar2017-05-311-15/+15
| | | | | | | | | | | | The intent of the test is to check that array lengths greater than UINT_MAX work properly. Change the test to stress that scenario, without triggering pointer overflow UB. Caught by a WIP pointer overflow checker in clang. Differential Revision: https://reviews.llvm.org/D33149 llvm-svn: 304353
* [APInt] Add support for dividing or remainder by a uint64_t or int64_t.Craig Topper2017-05-191-0/+58
| | | | | | | | | | | | | | | | | | | Summary: This patch adds udiv/sdiv/urem/srem/udivrem/sdivrem methods that can divide by a uint64_t. This makes division consistent with all the other arithmetic operations. This modifies the interface of the divide helper method to work on raw arrays instead of APInts. This way we can pass the uint64_t in for the RHS without wrapping it in an APInt. This required moving all the Quotient and Remainder allocation handling up to the callers. For udiv/urem this was as simple as just creating the Quotient/Remainder with the right size when they were declared. For udivrem we have to rely on reallocate not changing the contents of the variable LHS or RHS is aliased with the Quotient or Remainder APInts. We also have to zero the upper bits of Remainder and Quotient that divide doesn't write to if lhsWords/rhsWords is smaller than the width. I've update the toString method to use the new udivrem. Reviewers: hans, dblaikie, RKSimon Reviewed By: RKSimon Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33310 llvm-svn: 303431
* [BitVector] Add find_[first,last]_[set,unset]_in.Zachary Turner2017-05-171-4/+151
| | | | | | | | | | | | | A lot of code is duplicated between the first_last and the next / prev methods. All of this code can be shared if they are implemented in terms of find_first_in(Begin, End) etc, in which case find_first = find_first_in(0, Size) and find_next is find_first_in(Prev+1, Size), with similar reductions for the other methods. Differential Revision: https://reviews.llvm.org/D33104 llvm-svn: 303269
* BitVector: add iterators for set bitsFrancis Visoiu Mistrih2017-05-171-0/+29
| | | | | | Differential revision: https://reviews.llvm.org/D32060 llvm-svn: 303227
* [APInt] Add support for multiplying by a uint64_t.Craig Topper2017-05-081-0/+19
| | | | | | This makes multiply similar to add, sub, xor, and, and or. llvm-svn: 302402
* [ADT] Add BitVector::find_prev.Zachary Turner2017-05-051-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | This almost completes the matrix of all possible find functions. *EXISTING* ---------- find_first find_first_unset find_next find_next_unset find_last find_last_unset *NEW* ---- find_prev *STILL MISSING* --------------- find_prev_unset Differential Revision: https://reviews.llvm.org/D32885 llvm-svn: 302254
* [ADT] A few minor improvements to BitVectorZachary Turner2017-05-051-0/+19
| | | | | | | Fixes some spelling mistakes, uses a helper function, and adds an additional test case. llvm-svn: 302208
* [APInt] Remove support for wrapping from APInt::setBits.Craig Topper2017-04-301-15/+15
| | | | | | | | This features isn't used anywhere in tree. It's existence seems to be preventing selfhost builds from inlining any of the setBits methods including setLowBits, setHighBits, and setBitsFrom. This is because the code makes the method recursive. If anyone needs this feature in the future we could consider adding a setBitsWithWrap method. This way only the calls that need it would pay for it. llvm-svn: 301769
* [StringExtras] Add a fromHex to complement toHex.Zachary Turner2017-04-251-0/+16
| | | | | | | | | | We already have a function toHex that will convert a string like "\xFF\xFF" to the string "FFFF", but we do not have one that goes the other way - i.e. to convert a textual string representing a sequence of hexadecimal characters into the corresponding actual bytes. This patch adds such a function. llvm-svn: 301356
* [APInt] Add ashrInPlace method and rewrite ashr to make a copy and then call ↵Craig Topper2017-04-241-0/+36
| | | | | | | | | | | | ashrInPlace. This patch adds an in place version of ashr to match lshr and shl which were recently added. I've tried to make this similar to the lshr code with additions to handle the sign extension. I've also tried to do this with less if checks than the current ashr code by sign extending the original result to a word boundary before doing any of the shifting. This removes a lot of the complexity of determining where to fill in sign bits after the shifting. Differential Revision: https://reviews.llvm.org/D32415 llvm-svn: 301198
* Add SUSE vendorIsmail Donmez2017-04-241-0/+6
| | | | | | | | | | | | | | Summary: SUSE's ARM triples end with -gnueabi even though they are hard-float. This requires special handling of SUSE ARM triples. Hence we need a way to differentiate the SUSE as vendor. This CL adds that. Reviewers: chandlerc, compnerd, echristo, rengolin Reviewed By: rengolin Subscribers: aemerson, rengolin, llvm-commits Differential Revision: https://reviews.llvm.org/D32426 llvm-svn: 301174
* [APInt] Make behavior of ashr by BitWidth consistent between single and ↵Craig Topper2017-04-241-1/+1
| | | | | | | | multi word. Previously single word would always return 0 regardless of the original sign. Multi word would return all 0s or all 1s based on the original sign. Now single word takes into account the sign as well. llvm-svn: 301159
* [APInt] In sext single word case, use SignExtend64 and let the APInt ↵Craig Topper2017-04-231-0/+20
| | | | | | | | constructor mask off any excess bits. The current code is trying to be clever with shifts to avoid needing to clear unused bits. But it looks like the compiler is unable to optimize out the unused bit handling in the APInt constructor. Given this its better to just use SignExtend64 and have more readable code. llvm-svn: 301133
* Revert "[APInt] Add ashrInPlace method and implement ashr using it. Also fix ↵Renato Golin2017-04-231-19/+1
| | | | | | | | | | a bug in the shift by BitWidth handling." This reverts commit r301094, as it broke all ARM self-hosting bots. PR32754. llvm-svn: 301110
* [APInt] Add ashrInPlace method and implement ashr using it. Also fix a bug ↵Craig Topper2017-04-221-1/+19
| | | | | | | | in the shift by BitWidth handling. For single word, shift by BitWidth was always returning 0, but for multiword it was based on original sign. Now single word matches multi word. llvm-svn: 301094
* [BitVector] Add find_last() and find_last_unset().Zachary Turner2017-04-211-0/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D32302 llvm-svn: 301014
* [AsmWriter/APFloat] FP constant printing: Avoid usage of locale dependent ↵Serguei Katkov2017-04-211-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | snprinf This should fix the bug https://bugs.llvm.org/show_bug.cgi?id=12906 To print the FP constant AsmWriter does the following: 1) convert FP value to String (actually using snprintf function which is locale dependent). 2) Convert String back to FP Value 3) Compare original and got FP values. If they are not equal just dump as hex. The problem happens on the 2nd step when APFloat does not expect group delimiter or fraction delimiter other than period symbol and so on, which can be produced on the first step if LLVM library is used in an environment with corresponding locale set. To fix this issue the locale independent APFloat:toString function is used. However it prints FP values slightly differently than snprintf does. Specifically it suppress trailing zeros in significant, use capital E and so on. It results in 117 test failures during make check. To avoid this I've also updated APFloat.toString a bit to pass make check at least. Reviewers: sberg, bogner, majnemer, sanjoy, timshen, rnk Reviewed By: timshen, rnk Subscribers: rnk, llvm-commits Differential Revision: https://reviews.llvm.org/D32276 llvm-svn: 300943
* Resubmit "[BitVector] Add operator<<= and operator>>=."Zachary Turner2017-04-201-0/+122
| | | | | | | | | This was failing due to the use of assigning a Mask to an unsigned, rather than to a BitWord. But most systems do not have sizeof(unsigned) == sizeof(unsigned long), so the mask was getting truncated. llvm-svn: 300857
* Revert "[BitVector] Add operator<<= and operator>>=."Zachary Turner2017-04-201-122/+0
| | | | | | | This is causing test failures on Linux / BSD systems. Reverting while I investigate. llvm-svn: 300852
* [APInt] Add isSubsetOf method that can check if one APInt is a subset of ↵Craig Topper2017-04-201-0/+29
| | | | | | | | | | | | | | another without creating temporary APInts This question comes up in many places in SimplifyDemandedBits. This makes it easy to ask without allocating additional temporary APInts. The BitVector class provides a similar functionality through its (IMHO badly named) test(const BitVector&) method. Though its output polarity is reversed. I've provided one example use case in this patch. I plan to do more as a follow up. Differential Revision: https://reviews.llvm.org/D32258 llvm-svn: 300851
* [BitVector] Add operator<<= and operator>>=.Zachary Turner2017-04-201-0/+122
| | | | | | Differential Revision: https://reviews.llvm.org/D32244 llvm-svn: 300848
* Recommit "[APInt] Add back the asserts that check that the APInt shift ↵Craig Topper2017-04-201-2/+2
| | | | | | | | methods aren't called with values larger than BitWidth." This includes a fix to clamp a right shift of larger than BitWidth in DAG combining. llvm-svn: 300816
* Revert r300811 "[APInt] Add back the asserts that check that the APInt shift ↵Craig Topper2017-04-201-2/+2
| | | | | | | | methods aren't called with values larger than BitWidth." This is failing a self host debug build. llvm-svn: 300813
* [APInt] Add back the asserts that check that the APInt shift methods aren't ↵Craig Topper2017-04-201-2/+2
| | | | | | | | called with values larger than BitWidth. The underlying tcShiftRight/tcShiftLeft functions support the larger bit widths but the APInt interface shouldn't rely on that. llvm-svn: 300811
* [APInt] Make operator<<= shift in place. Improve the implementation of ↵Craig Topper2017-04-181-0/+33
| | | | | | tcShiftLeft and use it to implement operator<<=. llvm-svn: 300526
* [APInt] Merge the multiword code from lshrInPlace and tcShiftRight into a ↵Craig Topper2017-04-171-5/+33
| | | | | | | | | | | | single implementation This merges the two different multiword shift right implementations into a single version located in tcShiftRight. lshrInPlace now calls tcShiftRight for the multiword case. I retained the memmove fast path from lshrInPlace and used a memset for the zeroing. The for loop is basically tcShiftRight's implementation with the zeroing and the intra-shift of 0 removed. Differential Revision: https://reviews.llvm.org/D32114 llvm-svn: 300503
* [APInt] Remove self move check from move assignment operatorCraig Topper2017-04-171-30/+2
| | | | | | | | | | | | This was added to work around a bug in MSVC 2013's implementation of stable_sort. That bug has been fixed as of MSVC 2015 so we shouldn't need this anymore. Technically the current implementation has undefined behavior because we only protect the deleting of the pVal array with the self move check. There is still a memcpy of that.VAL to VAL that isn't protected. In the case of self move those are the same local and memcpy is undefined for src and dst overlapping. This reduces the size of the opt binary on my local x86-64 build by about 4k. Differential Revision: https://reviews.llvm.org/D32116 llvm-svn: 300477
* [APInt] Fix a bug in lshr by a value more than 64 bits above the bit width.Craig Topper2017-04-161-0/+5
| | | | | | This was throwing an assert because we determined the intra-word shift amount by subtracting the size of the full word shift from the total shift amount. But we failed to account for the fact that we clipped the full word shifts by total words first. To fix this just calculate the intra-word shift as the remainder of dividing by bits per word. llvm-svn: 300405
* Add more test cases for StringRef::edit_distanceAlex Denisov2017-04-141-2/+16
| | | | | | Example strings taken from here: http://www.let.rug.nl/~kleiweg/lev/ llvm-svn: 300312
* Remove all allocation and divisions from GreatestCommonDivisorRichard Smith2017-04-131-0/+43
| | | | | | | | | | | Switch from Euclid's algorithm to Stein's algorithm for computing GCD. This avoids the (expensive) APInt division operation in favour of bit operations. Remove all memory allocation from within the GCD loop by tweaking our `lshr` implementation so it can operate in-place. Differential Revision: https://reviews.llvm.org/D31968 llvm-svn: 300252
* Fix signed / unsigned comparison warnings.Zachary Turner2017-04-101-2/+2
| | | | llvm-svn: 299873
* [Support] Add support for finding unset bits in a BitVector.Zachary Turner2017-04-101-0/+39
| | | | | | | | | | | | BitVector had methods for searching for the first and next set bits, but it did not have analagous methods for finding the first and next unset bits. This is useful when your ones and zeros are grouped together and you want to iterate over ranges of ones and zeros. Differential Revision: https://reviews.llvm.org/D31802 llvm-svn: 299857
* [ADT] Add a generic breadth-first-search graph iterator.Davide Italiano2017-04-062-0/+75
| | | | | | | | This will be used in LCSSA to speed up the canonicalization. Differential Revision: https://reviews.llvm.org/D31694 llvm-svn: 299660
* [APInt] Move isMask and isShiftedMask out of APIntOps and into the APInt ↵Craig Topper2017-04-031-14/+15
| | | | | | | | | | class. Implement them without memory allocation for multiword This moves the isMask and isShiftedMask functions to be class methods. They now use the MathExtras.h function for single word size and leading/trailing zeros/ones or countPopulation for the multiword size. The previous implementation made multiple temorary memory allocations to do the bitwise arithmetic operations to match the MathExtras.h implementation. Differential Revision: https://reviews.llvm.org/D31565 llvm-svn: 299362
* [APInt] Add a public typedef for the internal type of APInt use it instead ↵Craig Topper2017-04-021-37/+37
| | | | | | | | | | | | | | | | of integerPart. Make APINT_BITS_PER_WORD and APINT_WORD_SIZE public. This patch is one step to attempt to unify the main APInt interface and the tc functions used by APFloat. This patch adds a WordType to APInt and uses that in all the tc functions. I've added temporary typedefs to APFloat to alias it to integerPart to keep the patch size down. I'll work on removing that in a future patch. In future patches I hope to reuse the tc functions to implement some of the main APInt functionality. I may remove APINT_ from BITS_PER_WORD and WORD_SIZE constants so that we don't have the repetitive APInt::APINT_ externally. Differential Revision: https://reviews.llvm.org/D31523 llvm-svn: 299341
OpenPOWER on IntegriCloud