[llvm] r245743 - MIRParser: Split the 'parseIRConstant' method into two methods. NFC.
Alex Lorenz via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 21 14:48:22 PDT 2015
Author: arphaman
Date: Fri Aug 21 16:48:22 2015
New Revision: 245743
URL: http://llvm.org/viewvc/llvm-project?rev=245743&view=rev
Log:
MIRParser: Split the 'parseIRConstant' method into two methods. NFC.
One variant of this method can be reused when parsing the quoted IR pointer
expressions in 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=245743&r1=245742&r2=245743&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Fri Aug 21 16:48:22 2015
@@ -122,6 +122,8 @@ public:
bool parseRegisterOperand(MachineOperand &Dest,
Optional<unsigned> &TiedDefIdx, bool IsDef = false);
bool parseImmediateOperand(MachineOperand &Dest);
+ bool parseIRConstant(StringRef::iterator Loc, StringRef Source,
+ const Constant *&C);
bool parseIRConstant(StringRef::iterator Loc, const Constant *&C);
bool parseTypedImmediateOperand(MachineOperand &Dest);
bool parseFPImmediateOperand(MachineOperand &Dest);
@@ -976,9 +978,9 @@ bool MIParser::parseImmediateOperand(Mac
return false;
}
-bool MIParser::parseIRConstant(StringRef::iterator Loc, const Constant *&C) {
- auto Source = StringRef(Loc, Token.range().end() - Loc).str();
- lex();
+bool MIParser::parseIRConstant(StringRef::iterator Loc, StringRef StringValue,
+ const Constant *&C) {
+ auto Source = StringValue.str(); // The source has to be null terminated.
SMDiagnostic Err;
C = parseConstantValue(Source.c_str(), Err, *MF.getFunction()->getParent());
if (!C)
@@ -986,6 +988,13 @@ bool MIParser::parseIRConstant(StringRef
return false;
}
+bool MIParser::parseIRConstant(StringRef::iterator Loc, const Constant *&C) {
+ if (parseIRConstant(Loc, StringRef(Loc, Token.range().end() - Loc), C))
+ return true;
+ lex();
+ return false;
+}
+
bool MIParser::parseTypedImmediateOperand(MachineOperand &Dest) {
assert(Token.is(MIToken::IntegerType));
auto Loc = Token.location();
More information about the llvm-commits
mailing list