Commit Graph

7 Commits

Author SHA1 Message Date
Tobias Grosser 21a059af09 Adjust formatting to commit r292110 [NFC]
llvm-svn: 292123
2017-01-16 14:08:10 +00:00
Michael Kruse 209b463240 Add unittests for foreach(Elt|Piece). NFC.
llvm-svn: 288925
2016-12-07 17:48:02 +00:00
Tobias Grosser 9d61e4a980 Avoid the use of large unsigned values in isl unit test
isl_val_int_from_ui takes an 'unsigned long' which has on 32-bit and LLP64
windows systems only 32 bit. Hence, make sure we do not use it with constants
that are larger than 32 bit.

Reported-by: Michael Kruse <llvm@meinersbur.de>
llvm-svn: 279824
2016-08-26 15:42:38 +00:00
Tobias Grosser aa6eb5cd80 unittests: Make the expected value the first argument in EXPECT_EQ [NFC]
This improves the readability of failing test results, as gtest prints always
the first argument as the 'expected value'.

In the previous commit we already changed the tests for isl_valFromAPInt. In
this commit, the tests for IslValToAPInt follow.

Suggested-by: Michael Kruse <llvm@meinersbur.de>
llvm-svn: 279817
2016-08-26 12:25:08 +00:00
Tobias Grosser 437200089d Improve documentation and testing for isl_valFromAPInt
The recent unit tests we gained made clear that the semantics of
isl_valFromAPInt are not clear, due to missing documentation. In this change we
document both the calling interface as well as the implementation of
isl_valFromAPInt.

We also make the implementation easier to read by removing integer wrappig in
abs() when passing in the minimal integer value for a given bitwidth. Even
though wrapping and subsequently interpreting the result as unsigned value gives
the correct result, this is far from obvious.  Instead, we explicitly add one
more bit to the input type to ensure that abs will never wrap. This change did
not uncover a bug in the old implementation, but was introduced to increase
readability.

We update the tests to add a test case for this special case and use this
opportunity to also test a number larger than 64 bit. Finally, we order the
arguments of the test cases to make sure the expected output is first. This
helps readability in case of failing test cases as gtest assumes the first value
to be the exected value.

Reviewed-by: Michael Kruse <llvm@meinersbur.de>
Differential Revision: https://reviews.llvm.org/D23917

llvm-svn: 279815
2016-08-26 12:01:07 +00:00
Tobias Grosser 76f8279e44 Improve documentation and testing of APIntFromVal
The recent unit tests we gained made clear that the semantics of APIntFromVal
are not clear, due to missing documentation. In this change we document both
the calling interface as well as the implementation of APIntFromVal. We also
make the implementation easier to read by removing the use of magic numbers.
Finally, we add tests to check the bitwidth of the created values as well as
the correct modeling of very large numbers.

Reviewed-by: Michael Kruse <llvm@meinersbur.de>
Differential Revision: https://reviews.llvm.org/D23910

llvm-svn: 279813
2016-08-26 10:43:28 +00:00
Michael Kruse 05cf9c22f1 Introduce unittests.
Add the infrastructure for unittests to Polly and two simple tests for
conversion between isl_val and APInt. In addition, a build target
check-polly-unittests is added to run only the unittests but not the regression
tests.

Clang's unittest mechanism served as as a blueprint which then was adapted to
Polly.

Differential Revision: https://reviews.llvm.org/D23833

llvm-svn: 279734
2016-08-25 12:36:15 +00:00