diff options
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r-- | llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp | 4 |
2 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 4fb409f020d..bd48e5d846a 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -1221,8 +1221,9 @@ public: // Calculate its FP value. APFloat RealVal(APFloat::IEEEdouble()); - if (RealVal.convertFromString(Desc->Repr, APFloat::rmTowardZero) != - APFloat::opOK) + auto StatusOrErr = + RealVal.convertFromString(Desc->Repr, APFloat::rmTowardZero); + if (!StatusOrErr || *StatusOrErr != APFloat::opOK) llvm_unreachable("FP immediate is not exact"); if (getFPImm().bitwiseIsEqual(RealVal)) @@ -2577,8 +2578,13 @@ AArch64AsmParser::tryParseFPImm(OperandVector &Operands) { } else { // Parse FP representation. APFloat RealVal(APFloat::IEEEdouble()); - auto Status = + auto StatusOrErr = RealVal.convertFromString(Tok.getString(), APFloat::rmTowardZero); + if (!StatusOrErr) { + TokError("invalid floating point representation"); + return MatchOperand_ParseFail; + } + if (isNegative) RealVal.changeSign(); @@ -2589,7 +2595,7 @@ AArch64AsmParser::tryParseFPImm(OperandVector &Operands) { AArch64Operand::CreateToken(".0", false, S, getContext())); } else Operands.push_back(AArch64Operand::CreateFPImm( - RealVal, Status == APFloat::opOK, S, getContext())); + RealVal, *StatusOrErr == APFloat::opOK, S, getContext())); } Parser.Lex(); // Eat the token. diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp index 1f0f9f238fb..326df6bc8fb 100644 --- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -45,7 +45,7 @@ #include "llvm/Support/AMDHSAKernelDescriptor.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" -#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/Error.h" #include "llvm/Support/MachineValueType.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/SMLoc.h" @@ -2363,7 +2363,7 @@ AMDGPUAsmParser::parseImm(OperandVector &Operands, bool HasSP3AbsModifier) { APFloat RealVal(APFloat::IEEEdouble()); auto roundMode = APFloat::rmNearestTiesToEven; - if (RealVal.convertFromString(Num, roundMode) == APFloat::opInvalidOp) { + if (!RealVal.convertFromString(Num, roundMode)) { return MatchOperand_ParseFail; } if (Negate) |