mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-27 14:24:40 +00:00
[C API] PR19859: Add LLVMGetFCmpPredicate and LLVMConstRealGetDouble.
Patch by Gabriel Radanne <drupyog@zoho.com>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220814 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -774,6 +774,27 @@ long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal) {
|
||||
return unwrap<ConstantInt>(ConstantVal)->getSExtValue();
|
||||
}
|
||||
|
||||
double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo) {
|
||||
ConstantFP *cFP = unwrap<ConstantFP>(ConstantVal) ;
|
||||
Type *Ty = cFP->getType();
|
||||
|
||||
if (Ty->isFloatTy()) {
|
||||
*LosesInfo = false;
|
||||
return cFP->getValueAPF().convertToFloat();
|
||||
}
|
||||
|
||||
if (Ty->isDoubleTy()) {
|
||||
*LosesInfo = false;
|
||||
return cFP->getValueAPF().convertToDouble();
|
||||
}
|
||||
|
||||
bool APFLosesInfo;
|
||||
APFloat APF = cFP->getValueAPF();
|
||||
APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &APFLosesInfo);
|
||||
*LosesInfo = APFLosesInfo;
|
||||
return APF.convertToDouble();
|
||||
}
|
||||
|
||||
/*--.. Operations on composite constants ...................................--*/
|
||||
|
||||
LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
|
||||
@ -1882,6 +1903,15 @@ LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst) {
|
||||
return (LLVMIntPredicate)0;
|
||||
}
|
||||
|
||||
LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst) {
|
||||
if (FCmpInst *I = dyn_cast<FCmpInst>(unwrap(Inst)))
|
||||
return (LLVMRealPredicate)I->getPredicate();
|
||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(unwrap(Inst)))
|
||||
if (CE->getOpcode() == Instruction::FCmp)
|
||||
return (LLVMRealPredicate)CE->getPredicate();
|
||||
return (LLVMRealPredicate)0;
|
||||
}
|
||||
|
||||
LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst) {
|
||||
if (Instruction *C = dyn_cast<Instruction>(unwrap(Inst)))
|
||||
return map_to_llvmopcode(C->getOpcode());
|
||||
@ -2342,7 +2372,7 @@ static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) {
|
||||
case LLVMAtomicOrderingSequentiallyConsistent:
|
||||
return SequentiallyConsistent;
|
||||
}
|
||||
|
||||
|
||||
llvm_unreachable("Invalid LLVMAtomicOrdering value!");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user