aboutsummaryrefslogtreecommitdiff
path: root/unittests/IR
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-01-16 14:41:46 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-01-16 14:41:46 +0000
commit655578f8b5275e7c59b87d4709b0d56b2621caac (patch)
tree3d23eacb88bd52a9d3f42a81acf37e081b406795 /unittests/IR
parent4802b9d6dc7443985066f0381c0a2468f72f9b81 (diff)
Allow vectors in CreatePointerCast of constants.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172615 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/IR')
-rw-r--r--unittests/IR/ConstantsTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/unittests/IR/ConstantsTest.cpp b/unittests/IR/ConstantsTest.cpp
index be34c1e2a1..db783f72d4 100644
--- a/unittests/IR/ConstantsTest.cpp
+++ b/unittests/IR/ConstantsTest.cpp
@@ -121,6 +121,36 @@ TEST(ConstantsTest, FP128Test) {
EXPECT_TRUE(isa<ConstantFP>(X));
}
+TEST(ConstantsTest, PointerCast) {
+ LLVMContext &C(getGlobalContext());
+ Type *Int8PtrTy = Type::getInt8PtrTy(C);
+ Type *Int32PtrTy = Type::getInt32PtrTy(C);
+ Type *Int64Ty = Type::getInt64Ty(C);
+ VectorType *Int8PtrVecTy = VectorType::get(Int8PtrTy, 4);
+ VectorType *Int32PtrVecTy = VectorType::get(Int32PtrTy, 4);
+ VectorType *Int64VecTy = VectorType::get(Int64Ty, 4);
+
+ // ptrtoint i8* to i64
+ EXPECT_EQ(Constant::getNullValue(Int64Ty),
+ ConstantExpr::getPointerCast(
+ Constant::getNullValue(Int8PtrTy), Int64Ty));
+
+ // bitcast i8* to i32*
+ EXPECT_EQ(Constant::getNullValue(Int32PtrTy),
+ ConstantExpr::getPointerCast(
+ Constant::getNullValue(Int8PtrTy), Int32PtrTy));
+
+ // ptrtoint <4 x i8*> to <4 x i64>
+ EXPECT_EQ(Constant::getNullValue(Int64VecTy),
+ ConstantExpr::getPointerCast(
+ Constant::getNullValue(Int8PtrVecTy), Int64VecTy));
+
+ // bitcast <4 x i8*> to <4 x i32*>
+ EXPECT_EQ(Constant::getNullValue(Int32PtrVecTy),
+ ConstantExpr::getPointerCast(
+ Constant::getNullValue(Int8PtrVecTy), Int32PtrVecTy));
+}
+
#define CHECK(x, y) { \
std::string __s; \
raw_string_ostream __o(__s); \