MIR Parser: Extract the method 'parseGlobalValue'. NFC.
[oota-llvm.git] / lib / CodeGen / MIRParser / MILexer.h
index ef471d250c269c949727e374d688572b3b1ac323..06fa1f256ddb6e98c9b1556ae0bf739deaa140e1 100644 (file)
@@ -35,6 +35,8 @@ struct MIToken {
     comma,
     equal,
     underscore,
+    colon,
+    exclaim,
 
     // Keywords
     kw_implicit,
@@ -42,16 +44,30 @@ struct MIToken {
     kw_dead,
     kw_killed,
     kw_undef,
+    kw_frame_setup,
+    kw_debug_location,
+    kw_cfi_offset,
+    kw_cfi_def_cfa_register,
+    kw_cfi_def_cfa_offset,
 
     // Identifier tokens
     Identifier,
     NamedRegister,
     MachineBasicBlock,
+    StackObject,
+    FixedStackObject,
     NamedGlobalValue,
+    QuotedNamedGlobalValue,
     GlobalValue,
+    ExternalSymbol,
+    QuotedExternalSymbol,
 
     // Other tokens
-    IntegerLiteral
+    IntegerLiteral,
+    VirtualRegister,
+    ConstantPoolItem,
+    JumpTableIndex,
+    IRBlock,
   };
 
 private:
@@ -73,7 +89,8 @@ public:
   bool isError() const { return Kind == Error; }
 
   bool isRegister() const {
-    return Kind == NamedRegister || Kind == underscore;
+    return Kind == NamedRegister || Kind == underscore ||
+           Kind == VirtualRegister;
   }
 
   bool isRegisterFlag() const {
@@ -87,13 +104,37 @@ public:
 
   StringRef::iterator location() const { return Range.begin(); }
 
-  StringRef stringValue() const { return Range.drop_front(StringOffset); }
+  bool isStringValueQuoted() const {
+    return Kind == QuotedNamedGlobalValue || Kind == QuotedExternalSymbol;
+  }
+
+  /// Return the token's raw string value.
+  ///
+  /// If the string value is quoted, this method returns that quoted string as
+  /// it is, without unescaping the string value.
+  StringRef rawStringValue() const { return Range.drop_front(StringOffset); }
+
+  /// Return token's string value.
+  ///
+  /// Expects the string value to be unquoted.
+  StringRef stringValue() const {
+    assert(!isStringValueQuoted() && "String value is quoted");
+    return Range.drop_front(StringOffset);
+  }
+
+  /// Unescapes the token's string value.
+  ///
+  /// Expects the string value to be quoted.
+  void unescapeQuotedStringValue(std::string &Str) const;
 
   const APSInt &integerValue() const { return IntVal; }
 
   bool hasIntegerValue() const {
     return Kind == IntegerLiteral || Kind == MachineBasicBlock ||
-           Kind == GlobalValue;
+           Kind == StackObject || Kind == FixedStackObject ||
+           Kind == GlobalValue || Kind == VirtualRegister ||
+           Kind == ConstantPoolItem || Kind == JumpTableIndex ||
+           Kind == IRBlock;
   }
 };