From 522a2eaf62e7c14c3ed6dde5ff60bc098fbd4255 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Fri, 7 Aug 2015 20:21:00 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244355 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MIRParser/MIParser.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/MIRParser/MIParser.cpp b/lib/CodeGen/MIRParser/MIParser.cpp index c71cdbb6d6f..af599a5cc3b 100644 --- a/lib/CodeGen/MIRParser/MIParser.cpp +++ b/lib/CodeGen/MIRParser/MIParser.cpp @@ -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::parseMachineOperandAndTargetFlags(MachineOperand &Dest) { 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(MachineOperand &Op) { 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; } -- 2.34.1