/// object.
Constant *ConstantDataArray::getFP(LLVMContext &Context,
ArrayRef<uint16_t> Elts) {
- Type *Ty = VectorType::get(Type::getHalfTy(Context), Elts.size());
+ Type *Ty = ArrayType::get(Type::getHalfTy(Context), Elts.size());
const char *Data = reinterpret_cast<const char *>(Elts.data());
return getImpl(StringRef(const_cast<char *>(Data), Elts.size() * 2), Ty);
}
; CHECK: @test-float-Nan
; CHECK: ret i32 2139171423
}
+
+define i16 @test-half-Nan() {
+ %A = bitcast i16 32256 to half
+ %B = insertvalue [1 x half] undef, half %A, 0
+ %C = extractvalue [1 x half] %B, 0
+ %D = bitcast half %C to i16
+ ret i16 %D
+; CHECK: @test-half-Nan
+; CHECK: ret i16 32256
+}
return S;
}
+TEST(ConstantsTest, BuildConstantDataArrays) {
+ LLVMContext Context;
+ std::unique_ptr<Module> M(new Module("MyModule", Context));
+
+ for (Type *T : {Type::getInt8Ty(Context), Type::getInt16Ty(Context),
+ Type::getInt32Ty(Context), Type::getInt64Ty(Context)}) {
+ ArrayType *ArrayTy = ArrayType::get(T, 2);
+ Constant *Vals[] = {ConstantInt::get(T, 0), ConstantInt::get(T, 1)};
+ Constant *CDV = ConstantArray::get(ArrayTy, Vals);
+ ASSERT_TRUE(dyn_cast<ConstantDataArray>(CDV) != nullptr)
+ << " T = " << getNameOfType(T);
+ }
+
+ for (Type *T : {Type::getHalfTy(Context), Type::getFloatTy(Context),
+ Type::getDoubleTy(Context)}) {
+ ArrayType *ArrayTy = ArrayType::get(T, 2);
+ Constant *Vals[] = {ConstantFP::get(T, 0), ConstantFP::get(T, 1)};
+ Constant *CDV = ConstantArray::get(ArrayTy, Vals);
+ ASSERT_TRUE(dyn_cast<ConstantDataArray>(CDV) != nullptr)
+ << " T = " << getNameOfType(T);
+ }
+}
+
TEST(ConstantsTest, BuildConstantDataVectors) {
LLVMContext Context;
std::unique_ptr<Module> M(new Module("MyModule", Context));