From 837f15187b8499e2326cf2e403bffc97669c6c2e Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Thu, 24 Mar 2016 13:26:59 +0000 Subject: [mips] Range check simm10 Summary: Reviewers: vkalintiris Subscribers: llvm-commits, dsanders Differential Revision: http://reviews.llvm.org/D18148 llvm-svn: 264279 --- llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp | 3 +++ llvm/lib/Target/Mips/Mips64InstrInfo.td | 3 --- llvm/lib/Target/Mips/MipsInstrInfo.td | 11 ++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index 1a1682d2a12..42a0c96b876 100644 --- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -3781,6 +3781,9 @@ bool MipsAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode, 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), diff --git a/llvm/lib/Target/Mips/Mips64InstrInfo.td b/llvm/lib/Target/Mips/Mips64InstrInfo.td index 44dc8be156b..fc4d76b518a 100644 --- a/llvm/lib/Target/Mips/Mips64InstrInfo.td +++ b/llvm/lib/Target/Mips/Mips64InstrInfo.td @@ -15,9 +15,6 @@ // Mips Operand, Complex Patterns and Transformations Definitions. //===----------------------------------------------------------------------===// -// Signed Operand -def simm10_64 : Operand; - // Transformation Function - get Imm - 32. def Subtract32 : SDNodeXFormgetZExtValue() - 32); diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.td b/llvm/lib/Target/Mips/MipsInstrInfo.td index 67145c145f0..cb1f705e2f8 100644 --- a/llvm/lib/Target/Mips/MipsInstrInfo.td +++ b/llvm/lib/Target/Mips/MipsInstrInfo.td @@ -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 @@ -746,6 +748,13 @@ foreach I = {4, 5, 6} in !cast("ConstantSImm" # I # "AsmOperandClass"); } +foreach I = {10} in + def simm # I # _64 : Operand { + let DecoderMethod = "DecodeSImmWithOffsetAndScale<" # I # ">"; + let ParserMatchClass = + !cast("ConstantSImm" # I # "AsmOperandClass"); + } + def simm7_lsl2 : Operand { let EncoderMethod = "getSImm7Lsl2Encoding"; let DecoderMethod = "DecodeSImmWithOffsetAndScale<" # I # ", 0, 4>"; -- cgit v1.2.3