[PATCH] D14015: [mips][ias] Range check uimm2 operands and fix a bug this revealed.

Vasileios Kalintiris via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 26 08:49:58 PDT 2015


vkalintiris accepted this revision.
vkalintiris added a comment.
This revision is now accepted and ready to land.

LGTM, but make sure that you really want the 2nd assert in getUImmWithOffsetEncoding().


================
Comment at: lib/Target/Mips/AsmParser/MipsAsmParser.cpp:3297-3300
@@ -3292,2 +3296,6 @@
     return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected '0'");
+  case Match_UImm2_0:
+    return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 2-bit unsigned immediate");
+  case Match_UImm2_1:
+    return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected immediate in range 1 .. 4");
   }
----------------
Split the `Error()` lines as they are too big.

================
Comment at: lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp:880
@@ +879,3 @@
+  Value -= Offset;
+  assert(isUInt<2>(Value));
+  return Value;
----------------
Do we really need this assert in this place?

================
Comment at: lib/Target/Mips/MipsInstrInfo.td:475
@@ +474,3 @@
+// Unsigned Operands
+foreach I = {2} in
+  def uimm # I : Operand<i32> {
----------------
Did you intend to use foreach over a single element list?


http://reviews.llvm.org/D14015





More information about the llvm-commits mailing list