Skip to content

Commit 624b310

Browse files
committed
Create a 128 bit floating point constant from 2 64 bit values
1 parent 9a74abc commit 624b310

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

llvm/include/llvm-c/Core.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,13 @@ LLVM_C_ABI LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy,
23392339
const char *Text,
23402340
unsigned SLen);
23412341

2342+
/**
2343+
* Obtain a constant for a floating point FP128 value from 2 64 bit values.
2344+
* (112 bit mantissa)
2345+
*/
2346+
2347+
LLVMValueRef LLVMConstFP128(LLVMContextRef C, const uint64_t N[2]);
2348+
23422349
/**
23432350
* Obtain the zero extended value for an integer constant value.
23442351
*

llvm/lib/IR/Core.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,13 @@ LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char Str[],
15731573
return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Str, SLen)));
15741574
}
15751575

1576+
LLVMValueRef LLVMConstFP128(LLVMContextRef C, const uint64_t N[2]) {
1577+
Type *Ty = Type::getFP128Ty(*unwrap(C));
1578+
APInt AI(128, ArrayRef<uint64_t>(N, 2));
1579+
APFloat Quad(APFloat::IEEEquad(), AI);
1580+
return wrap(ConstantFP::get(Ty, Quad));
1581+
}
1582+
15761583
unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal) {
15771584
return unwrap<ConstantInt>(ConstantVal)->getZExtValue();
15781585
}

0 commit comments

Comments
 (0)