[llvm] r244355 - MIR Parser: Extract the parsing of the operand's offset into a new method. NFC.

Alex Lorenz via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 13:21:00 PDT 2015


Author: arphaman
Date: Fri Aug  7 15:21:00 2015
New Revision: 244355

URL: http://llvm.org/viewvc/llvm-project?rev=244355&view=rev
Log:
MIR Parser: Extract the parsing of the operand's offset into a new method. NFC.

This commit extract the code that parses the 64-bit offset from the method
'parseOperandsOffset' to a new method 'parseOffset' so that we can reuse it
when parsing the offset for the machine memory operands.

Modified:
    llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp

Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=244355&r1=244354&r2=244355&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Fri Aug  7 15:21:00 2015
@@ -123,6 +123,7 @@ public:
   bool parseTargetIndexOperand(MachineOperand &Dest);
   bool parseMachineOperand(MachineOperand &Dest);
   bool parseMachineOperandAndTargetFlags(MachineOperand &Dest);
+  bool parseOffset(int64_t &Offset);
   bool parseOperandsOffset(MachineOperand &Op);
   bool parseIRValue(Value *&V);
   bool parseMemoryOperandFlag(unsigned &Flags);
@@ -1014,7 +1015,7 @@ bool MIParser::parseMachineOperandAndTar
   return false;
 }
 
-bool MIParser::parseOperandsOffset(MachineOperand &Op) {
+bool MIParser::parseOffset(int64_t &Offset) {
   if (Token.isNot(MIToken::plus) && Token.isNot(MIToken::minus))
     return false;
   StringRef Sign = Token.range();
@@ -1024,10 +1025,17 @@ bool MIParser::parseOperandsOffset(Machi
     return error("expected an integer literal after '" + Sign + "'");
   if (Token.integerValue().getMinSignedBits() > 64)
     return error("expected 64-bit integer (too large)");
-  int64_t Offset = Token.integerValue().getExtValue();
+  Offset = Token.integerValue().getExtValue();
   if (IsNegative)
     Offset = -Offset;
   lex();
+  return false;
+}
+
+bool MIParser::parseOperandsOffset(MachineOperand &Op) {
+  int64_t Offset = 0;
+  if (parseOffset(Offset))
+    return true;
   Op.setOffset(Offset);
   return false;
 }




More information about the llvm-commits mailing list