[llvm] r208862 - [ARM64] Add/Fixup diagnostics for floating point immediates
Bradley Smith
bradley.smith at arm.com
Thu May 15 04:07:28 PDT 2014
Author: brasmi01
Date: Thu May 15 06:07:28 2014
New Revision: 208862
URL: http://llvm.org/viewvc/llvm-project?rev=208862&view=rev
Log:
[ARM64] Add/Fixup diagnostics for floating point immediates
Modified:
llvm/trunk/lib/Target/ARM64/ARM64InstrFormats.td
llvm/trunk/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp
llvm/trunk/test/MC/AArch64/neon-diagnostics.s
Modified: llvm/trunk/lib/Target/ARM64/ARM64InstrFormats.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM64/ARM64InstrFormats.td?rev=208862&r1=208861&r2=208862&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM64/ARM64InstrFormats.td (original)
+++ llvm/trunk/lib/Target/ARM64/ARM64InstrFormats.td Thu May 15 06:07:28 2014
@@ -165,6 +165,7 @@ def ExtendOperandLSL64 : AsmOperandClass
def FPImmOperand : AsmOperandClass {
let Name = "FPImm";
let ParserMethod = "tryParseFPImm";
+ let DiagnosticType = "InvalidFPImm";
}
def CondCode : AsmOperandClass {
Modified: llvm/trunk/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp?rev=208862&r1=208861&r2=208862&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp Thu May 15 06:07:28 2014
@@ -2314,7 +2314,7 @@ ARM64AsmParser::tryParseFPImm(OperandVec
// as we handle that special case in post-processing before matching in
// order to use the zero register for it.
if (Val == -1 && !RealVal.isZero()) {
- TokError("floating point value out of range");
+ TokError("expected compatible register or floating-point constant");
return MatchOperand_ParseFail;
}
Operands.push_back(ARM64Operand::CreateFPImm(Val, S, getContext()));
@@ -3378,6 +3378,16 @@ bool ARM64AsmParser::parseOperand(Operan
if (getLexer().is(AsmToken::Hash))
Parser.Lex();
+ // Parse a negative sign
+ bool isNegative = false;
+ if (Parser.getTok().is(AsmToken::Minus)) {
+ isNegative = true;
+ // We need to consume this token only when we have a Real, otherwise
+ // we let parseSymbolicImmVal take care of it
+ if (Parser.getLexer().peekTok().is(AsmToken::Real))
+ Parser.Lex();
+ }
+
// The only Real that should come through here is a literal #0.0 for
// the fcmp[e] r, #0.0 instructions. They expect raw token operands,
// so convert the value.
@@ -3389,8 +3399,8 @@ bool ARM64AsmParser::parseOperand(Operan
Mnemonic != "fcmge" && Mnemonic != "fcmgt" && Mnemonic != "fcmle" &&
Mnemonic != "fcmlt")
return TokError("unexpected floating point literal");
- else if (IntVal != 0)
- return TokError("only valid floating-point immediate is #0.0");
+ else if (IntVal != 0 || isNegative)
+ return TokError("expected floating-point constant #0.0");
Parser.Lex(); // Eat the token.
Operands.push_back(
@@ -3729,6 +3739,9 @@ bool ARM64AsmParser::showMatchError(SMLo
case Match_AddSubRegShift64:
return Error(Loc,
"expected 'lsl', 'lsr' or 'asr' with optional integer in range [0, 63]");
+ case Match_InvalidFPImm:
+ return Error(Loc,
+ "expected compatible register or floating-point constant");
case Match_InvalidMemoryIndexedSImm9:
return Error(Loc, "index must be an integer in range [-256, 255].");
case Match_InvalidMemoryIndexed32SImm7:
@@ -4187,6 +4200,7 @@ bool ARM64AsmParser::MatchAndEmitInstruc
case Match_AddSubRegShift64:
case Match_InvalidMovImm32Shift:
case Match_InvalidMovImm64Shift:
+ case Match_InvalidFPImm:
case Match_InvalidMemoryIndexed8:
case Match_InvalidMemoryIndexed16:
case Match_InvalidMemoryIndexed32SImm7:
Modified: llvm/trunk/test/MC/AArch64/neon-diagnostics.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/neon-diagnostics.s?rev=208862&r1=208861&r2=208862&view=diff
==============================================================================
--- llvm/trunk/test/MC/AArch64/neon-diagnostics.s (original)
+++ llvm/trunk/test/MC/AArch64/neon-diagnostics.s Thu May 15 06:07:28 2014
@@ -698,7 +698,7 @@
// CHECK-AARCH64-ERROR: fcmeq v0.8b, v1.4h, #1
// CHECK-AARCH64-ERROR: ^
-// CHECK-ARM64-ERROR: error: only valid floating-point immediate is #0.0
+// CHECK-ARM64-ERROR: error: expected floating-point constant #0.0
// CHECK-ARM64-ERROR: fcmeq v0.8b, v1.4h, #1.0
// CHECK-ARM64-ERROR: ^
// CHECK-ARM64-ERROR: error: invalid operand for instruction
@@ -729,7 +729,7 @@
// CHECK-AARCH64-ERROR: fcmle v17.8h, v15.2d, #2
// CHECK-AARCH64-ERROR: ^
-// CHECK-ARM64-ERROR: error: invalid operand for instruction
+// CHECK-ARM64-ERROR: error: expected floating-point constant #0.0
// CHECK-ARM64-ERROR: fcmle v17.8h, v15.2d, #-1.0
// CHECK-ARM64-ERROR: ^
// CHECK-ARM64-ERROR: error: invalid operand for instruction
@@ -759,7 +759,7 @@
// CHECK-AARCH64-ERROR: fcmlt v29.2d, v5.2d, #255
// CHECK-AARCH64-ERROR: ^
-// CHECK-ARM64-ERROR: error: only valid floating-point immediate is #0.0
+// CHECK-ARM64-ERROR: error: expected floating-point constant #0.0
// CHECK-ARM64-ERROR: fcmlt v29.2d, v5.2d, #255.0
// CHECK-ARM64-ERROR: ^
// CHECK-ARM64-ERROR: error: invalid operand for instruction
@@ -789,7 +789,7 @@
// CHECK-AARCH64-ERROR: fcmle v17.2d, v15.2d, #15
// CHECK-AARCH64-ERROR: ^
-// CHECK-ARM64-ERROR: error: only valid floating-point immediate is #0.0
+// CHECK-ARM64-ERROR: error: expected floating-point constant #0.0
// CHECK-ARM64-ERROR: fcmle v17.2d, v15.2d, #15.0
// CHECK-ARM64-ERROR: ^
// CHECK-ARM64-ERROR: error: invalid operand for instruction
@@ -819,7 +819,7 @@
// CHECK-AARCH64-ERROR: fcmlt v29.2d, v5.2d, #2
// CHECK-AARCH64-ERROR: ^
-// CHECK-ARM64-ERROR: error: only valid floating-point immediate is #0.0
+// CHECK-ARM64-ERROR: error: expected floating-point constant #0.0
// CHECK-ARM64-ERROR: fcmlt v29.2d, v5.2d, #16.0
// CHECK-ARM64-ERROR: ^
// CHECK-ARM64-ERROR: error: invalid operand for instruction
More information about the llvm-commits
mailing list