[Tablegen][PredicateExpander] Fix a bug in `expandCheckImmOperand`.

Function `expandCheckImmOperand` should always check if the input machine
instruction is passed by reference before calling method `getOperand()` on it.

Found while working on a patch that relies on `expandCheckImmOperand` to expand
a scheduling predicate.

llvm-svn: 337294
diff --git a/llvm/utils/TableGen/PredicateExpander.cpp b/llvm/utils/TableGen/PredicateExpander.cpp
index 62a01dc..56ffa77 100644
--- a/llvm/utils/TableGen/PredicateExpander.cpp
+++ b/llvm/utils/TableGen/PredicateExpander.cpp
@@ -22,14 +22,14 @@
 
 void PredicateExpander::expandCheckImmOperand(formatted_raw_ostream &OS,
                                               int OpIndex, int ImmVal) {
-  OS << "MI.getOperand(" << OpIndex << ").getImm() "
-     << (shouldNegate() ? "!= " : "== ") << ImmVal;
+  OS << "MI" << (isByRef() ? "." : "->") << "getOperand(" << OpIndex
+     << ").getImm() " << (shouldNegate() ? "!= " : "== ") << ImmVal;
 }
 
 void PredicateExpander::expandCheckImmOperand(formatted_raw_ostream &OS,
                                               int OpIndex, StringRef ImmVal) {
-  OS << "MI.getOperand(" << OpIndex << ").getImm() "
-     << (shouldNegate() ? "!= " : "== ") << ImmVal;
+  OS << "MI" << (isByRef() ? "." : "->") << "getOperand(" << OpIndex
+     << ").getImm() " << (shouldNegate() ? "!= " : "== ") << ImmVal;
 }
 
 void PredicateExpander::expandCheckRegOperand(formatted_raw_ostream &OS,