Skip to content
This repository was archived by the owner on Sep 2, 2018. It is now read-only.

Commit 112102c

Browse files
committed
AArch64: disallow "fmov sD, #-0.0" during assembly.
We weren't checking the sign of the floating point immediate before translating it to "fmov sD, wzr". Similarly for D-regs. Technically "movi vD.2s, #0x80, lsl #24" would work most of the time, but it's not a blessed alias (and I don't think it should be since people expect writing sD to zero out the high lanes, and there's no dD equivalent). So an error it is. rdar://20455398 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234372 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 13c7f90 commit 112102c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,15 +2090,16 @@ AArch64AsmParser::tryParseFPImm(OperandVector &Operands) {
20902090
const AsmToken &Tok = Parser.getTok();
20912091
if (Tok.is(AsmToken::Real)) {
20922092
APFloat RealVal(APFloat::IEEEdouble, Tok.getString());
2093+
if (isNegative)
2094+
RealVal.changeSign();
2095+
20932096
uint64_t IntVal = RealVal.bitcastToAPInt().getZExtValue();
2094-
// If we had a '-' in front, toggle the sign bit.
2095-
IntVal ^= (uint64_t)isNegative << 63;
20962097
int Val = AArch64_AM::getFP64Imm(APInt(64, IntVal));
20972098
Parser.Lex(); // Eat the token.
20982099
// Check for out of range values. As an exception, we let Zero through,
20992100
// as we handle that special case in post-processing before matching in
21002101
// order to use the zero register for it.
2101-
if (Val == -1 && !RealVal.isZero()) {
2102+
if (Val == -1 && !RealVal.isPosZero()) {
21022103
TokError("expected compatible register or floating-point constant");
21032104
return MatchOperand_ParseFail;
21042105
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; RUN: not llvm-mc -triple arm64-apple-ios8.0 %s -o /dev/null 2>&1 | FileCheck %s
2+
3+
fmov s0, #-0.0
4+
; CHECK: error: expected compatible register or floating-point constant
5+
6+
fmov d0, #-0.0
7+
; CHECK: error: expected compatible register or floating-point constant
8+

0 commit comments

Comments
 (0)