llvm.org GIT mirror llvm / 6079465
While testing dragonegg I noticed that isCastable and getCastOpcode had gotten out of sync: isCastable didn't think it was possible to cast the x86_mmx type to anything, while it did think it possible to cast an i64 to x86_mmx. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128705 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan Sands 9 years ago
2 changed file(s) with 25 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
22962296 if (const VectorType *SrcPTy = dyn_cast(SrcTy)) {
22972297 // Casting from vector
22982298 return DestPTy->getBitWidth() == SrcPTy->getBitWidth();
2299 } else { // Casting from something else
2300 return DestPTy->getBitWidth() == SrcBits;
2299 } else if (DestPTy->getBitWidth() == SrcBits) {
2300 return true; // float/int -> vector
2301 } else if (SrcTy->isX86_MMXTy()) {
2302 return DestPTy->getBitWidth() == 64; // MMX to 64-bit vector
2303 } else {
2304 return false;
23012305 }
23022306 } else if (DestTy->isPointerTy()) { // Casting to pointer
23032307 if (SrcTy->isPointerTy()) { // Casting from pointer
23072311 } else { // Casting from something else
23082312 return false;
23092313 }
2310 } else if (DestTy->isX86_MMXTy()) {
2311 return SrcBits == 64;
2314 } else if (DestTy->isX86_MMXTy()) {
2315 if (const VectorType *SrcPTy = dyn_cast(SrcTy)) {
2316 return SrcPTy->getBitWidth() == 64; // 64-bit vector to MMX
2317 } else {
2318 return false;
2319 }
23122320 } else { // Casting to something else
23132321 return false;
23142322 }
106106 delete bb1;
107107 }
108108
109 TEST(InstructionsTest, CastInst) {
110 LLVMContext &C(getGlobalContext());
111
112 const Type* Int8Ty = Type::getInt8Ty(C);
113 const Type* Int64Ty = Type::getInt64Ty(C);
114 const Type* V8x8Ty = VectorType::get(Int8Ty, 8);
115 const Type* X86MMXTy = Type::getX86_MMXTy(C);
116
117 EXPECT_TRUE(CastInst::isCastable(V8x8Ty, X86MMXTy));
118 EXPECT_TRUE(CastInst::isCastable(X86MMXTy, V8x8Ty));
119 EXPECT_FALSE(CastInst::isCastable(Int64Ty, X86MMXTy));
120 }
121
109122 } // end anonymous namespace
110123 } // end namespace llvm