[llvm] r264279 - [mips] Range check simm10
Daniel Sanders via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 24 06:27:00 PDT 2016
Author: dsanders
Date: Thu Mar 24 08:26:59 2016
New Revision: 264279
URL: http://llvm.org/viewvc/llvm-project?rev=264279&view=rev
Log:
[mips] Range check simm10
Summary:
Reviewers: vkalintiris
Subscribers: llvm-commits, dsanders
Differential Revision: http://reviews.llvm.org/D18148
Modified:
llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td
llvm/trunk/lib/Target/Mips/MipsInstrInfo.td
llvm/trunk/test/MC/Mips/cnmips/invalid.s
Modified: llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp?rev=264279&r1=264278&r2=264279&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Thu Mar 24 08:26:59 2016
@@ -3781,6 +3781,9 @@ bool MipsAsmParser::MatchAndEmitInstruct
case Match_UImm10_0:
return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
"expected 10-bit unsigned immediate");
+ case Match_SImm10_0:
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
+ "expected 10-bit signed immediate");
case Match_UImm16:
case Match_UImm16_Relaxed:
return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
Modified: llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td?rev=264279&r1=264278&r2=264279&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td (original)
+++ llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td Thu Mar 24 08:26:59 2016
@@ -15,9 +15,6 @@
// Mips Operand, Complex Patterns and Transformations Definitions.
//===----------------------------------------------------------------------===//
-// Signed Operand
-def simm10_64 : Operand<i64>;
-
// Transformation Function - get Imm - 32.
def Subtract32 : SDNodeXForm<imm, [{
return getImm(N, (unsigned)N->getZExtValue() - 32);
Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.td?rev=264279&r1=264278&r2=264279&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsInstrInfo.td (original)
+++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Thu Mar 24 08:26:59 2016
@@ -465,11 +465,13 @@ def UImm16AsmOperandClass
: UImmAsmOperandClass<16, [UImm16RelaxedAsmOperandClass]>;
def ConstantUImm10AsmOperandClass
: ConstantUImmAsmOperandClass<10, [UImm16AsmOperandClass]>;
+def ConstantSImm10AsmOperandClass
+ : ConstantSImmAsmOperandClass<10, [ConstantUImm10AsmOperandClass]>;
def ConstantSImm7Lsl2AsmOperandClass : AsmOperandClass {
let Name = "SImm7Lsl2";
let RenderMethod = "addImmOperands";
let PredicateMethod = "isScaledSImm<7, 2>";
- let SuperClasses = [ConstantUImm10AsmOperandClass];
+ let SuperClasses = [ConstantSImm10AsmOperandClass];
let DiagnosticType = "SImm7_Lsl2";
}
def ConstantUImm8AsmOperandClass
@@ -744,6 +746,13 @@ foreach I = {4, 5, 6} in
let DecoderMethod = "DecodeSImmWithOffsetAndScale<" # I # ">";
let ParserMatchClass =
!cast<AsmOperandClass>("ConstantSImm" # I # "AsmOperandClass");
+ }
+
+foreach I = {10} in
+ def simm # I # _64 : Operand<i64> {
+ let DecoderMethod = "DecodeSImmWithOffsetAndScale<" # I # ">";
+ let ParserMatchClass =
+ !cast<AsmOperandClass>("ConstantSImm" # I # "AsmOperandClass");
}
def simm7_lsl2 : Operand<OtherVT> {
Modified: llvm/trunk/test/MC/Mips/cnmips/invalid.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/cnmips/invalid.s?rev=264279&r1=264278&r2=264279&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/cnmips/invalid.s (original)
+++ llvm/trunk/test/MC/Mips/cnmips/invalid.s Thu Mar 24 08:26:59 2016
@@ -17,3 +17,7 @@ foo:
ins $2, $3, 32, 1 # CHECK: :[[@LINE]]:17: error: expected 5-bit unsigned immediate
ins $2, $3, 0, -1 # CHECK: :[[@LINE]]:20: error: expected immediate in range 1 .. 32
ins $2, $3, 0, 33 # CHECK: :[[@LINE]]:20: error: expected immediate in range 1 .. 32
+ seqi $2, $3, -1025 # CHECK: :[[@LINE]]:18: error: expected 10-bit signed immediate
+ seqi $2, $3, 1024 # CHECK: :[[@LINE]]:18: error: expected 10-bit signed immediate
+ snei $2, $3, -1025 # CHECK: :[[@LINE]]:18: error: expected 10-bit signed immediate
+ snei $2, $3, 1024 # CHECK: :[[@LINE]]:18: error: expected 10-bit signed immediate
More information about the llvm-commits
mailing list