diff options
author | Erick Tryzelaar <idadesub@users.sourceforge.net> | 2009-08-16 23:36:46 +0000 |
---|---|---|
committer | Erick Tryzelaar <idadesub@users.sourceforge.net> | 2009-08-16 23:36:46 +0000 |
commit | dd99135721f0dffa69b1aa4afaaaf6318f076379 (patch) | |
tree | 2a4f1a81469b1cac65571552397f90af1a0d383a /llvm/lib/VMCore/Core.cpp | |
parent | fc2280d874bed6c40c30489bd534ffe684f49047 (diff) | |
download | bcm5719-llvm-dd99135721f0dffa69b1aa4afaaaf6318f076379.tar.gz bcm5719-llvm-dd99135721f0dffa69b1aa4afaaaf6318f076379.zip |
Expose creating constant ints and floats from strings in llvm-c.
llvm-svn: 79213
Diffstat (limited to 'llvm/lib/VMCore/Core.cpp')
-rw-r--r-- | llvm/lib/VMCore/Core.cpp | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/llvm/lib/VMCore/Core.cpp b/llvm/lib/VMCore/Core.cpp index 1144e53a4d6..b2aa9f45370 100644 --- a/llvm/lib/VMCore/Core.cpp +++ b/llvm/lib/VMCore/Core.cpp @@ -440,32 +440,29 @@ LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), N, SignExtend != 0)); } -static const fltSemantics &SemanticsForType(Type *Ty) { - assert(Ty->isFloatingPoint() && "Type is not floating point!"); - if (Ty == Type::getFloatTy(Ty->getContext())) - return APFloat::IEEEsingle; - if (Ty == Type::getDoubleTy(Ty->getContext())) - return APFloat::IEEEdouble; - if (Ty == Type::getX86_FP80Ty(Ty->getContext())) - return APFloat::x87DoubleExtended; - if (Ty == Type::getFP128Ty(Ty->getContext())) - return APFloat::IEEEquad; - if (Ty == Type::getPPC_FP128Ty(Ty->getContext())) - return APFloat::PPCDoubleDouble; - return APFloat::Bogus; +LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char Str[], + uint8_t Radix) { + return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str), + Radix)); +} + +LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char Str[], + unsigned SLen, uint8_t Radix) { + return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str, SLen), + Radix)); } LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N) { - APFloat APN(N); - bool ignored; - APN.convert(SemanticsForType(unwrap(RealTy)), APFloat::rmNearestTiesToEven, - &ignored); - return wrap(ConstantFP::get(getGlobalContext(), APN)); + return wrap(ConstantFP::get(unwrap(RealTy), N)); } LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text) { - return wrap(ConstantFP::get(getGlobalContext(), - APFloat(SemanticsForType(unwrap(RealTy)), Text))); + return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Text))); +} + +LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char Str[], + unsigned SLen) { + return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Str, SLen))); } /*--.. Operations on composite constants ...................................--*/ |