[llvm] r242934 - MIR Parser: Extract the MDNode parsing code into a separate method. NFC.

Alex Lorenz arphaman at gmail.com
Wed Jul 22 14:07:04 PDT 2015


Author: arphaman
Date: Wed Jul 22 16:07:04 2015
New Revision: 242934

URL: http://llvm.org/viewvc/llvm-project?rev=242934&view=rev
Log:
MIR Parser: Extract the MDNode parsing code into a separate method. NFC.

This change would allow the machine instruction parser to reuse this method when
parsing the metadata node for the machine instruction's debug location property.

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=242934&r1=242933&r2=242934&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Wed Jul 22 16:07:04 2015
@@ -112,6 +112,7 @@ public:
   bool parseConstantPoolIndexOperand(MachineOperand &Dest);
   bool parseJumpTableIndexOperand(MachineOperand &Dest);
   bool parseExternalSymbolOperand(MachineOperand &Dest);
+  bool parseMDNode(MDNode *&Node);
   bool parseMetadataOperand(MachineOperand &Dest);
   bool parseCFIOffset(int &Offset);
   bool parseCFIOperand(MachineOperand &Dest);
@@ -576,7 +577,7 @@ bool MIParser::parseExternalSymbolOperan
   return false;
 }
 
-bool MIParser::parseMetadataOperand(MachineOperand &Dest) {
+bool MIParser::parseMDNode(MDNode *&Node) {
   assert(Token.is(MIToken::exclaim));
   auto Loc = Token.location();
   lex();
@@ -589,7 +590,15 @@ bool MIParser::parseMetadataOperand(Mach
   if (NodeInfo == IRSlots.MetadataNodes.end())
     return error(Loc, "use of undefined metadata '!" + Twine(ID) + "'");
   lex();
-  Dest = MachineOperand::CreateMetadata(NodeInfo->second.get());
+  Node = NodeInfo->second.get();
+  return false;
+}
+
+bool MIParser::parseMetadataOperand(MachineOperand &Dest) {
+  MDNode *Node = nullptr;
+  if (parseMDNode(Node))
+    return true;
+  Dest = MachineOperand::CreateMetadata(Node);
   return false;
 }
 





More information about the llvm-commits mailing list