diff options
Diffstat (limited to 'lib/CodeGen/MIRParser/MILexer.cpp')
| -rw-r--r-- | lib/CodeGen/MIRParser/MILexer.cpp | 57 | 
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/CodeGen/MIRParser/MILexer.cpp b/lib/CodeGen/MIRParser/MILexer.cpp index da05c9a227856..265877c2f5b42 100644 --- a/lib/CodeGen/MIRParser/MILexer.cpp +++ b/lib/CodeGen/MIRParser/MILexer.cpp @@ -202,6 +202,9 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {        .Case("contract", MIToken::kw_contract)        .Case("afn", MIToken::kw_afn)        .Case("reassoc", MIToken::kw_reassoc) +      .Case("nuw" , MIToken::kw_nuw) +      .Case("nsw" , MIToken::kw_nsw) +      .Case("exact" , MIToken::kw_exact)        .Case("debug-location", MIToken::kw_debug_location)        .Case("same_value", MIToken::kw_cfi_same_value)        .Case("offset", MIToken::kw_cfi_offset) @@ -217,6 +220,7 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {        .Case("undefined", MIToken::kw_cfi_undefined)        .Case("register", MIToken::kw_cfi_register)        .Case("window_save", MIToken::kw_cfi_window_save) +      .Case("negate_ra_sign_state", MIToken::kw_cfi_aarch64_negate_ra_sign_state)        .Case("blockaddress", MIToken::kw_blockaddress)        .Case("intrinsic", MIToken::kw_intrinsic)        .Case("target-index", MIToken::kw_target_index) @@ -245,6 +249,9 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {        .Case("successors", MIToken::kw_successors)        .Case("floatpred", MIToken::kw_floatpred)        .Case("intpred", MIToken::kw_intpred) +      .Case("pre-instr-symbol", MIToken::kw_pre_instr_symbol) +      .Case("post-instr-symbol", MIToken::kw_post_instr_symbol) +      .Case("unknown-size", MIToken::kw_unknown_size)        .Default(MIToken::Identifier);  } @@ -460,6 +467,53 @@ static Cursor maybeLexExternalSymbol(Cursor C, MIToken &Token,                   ErrorCallback);  } +static Cursor maybeLexMCSymbol(Cursor C, MIToken &Token, +                               ErrorCallbackType ErrorCallback) { +  const StringRef Rule = "<mcsymbol "; +  if (!C.remaining().startswith(Rule)) +    return None; +  auto Start = C; +  C.advance(Rule.size()); + +  // Try a simple unquoted name. +  if (C.peek() != '"') { +    while (isIdentifierChar(C.peek())) +      C.advance(); +    StringRef String = Start.upto(C).drop_front(Rule.size()); +    if (C.peek() != '>') { +      ErrorCallback(C.location(), +                    "expected the '<mcsymbol ...' to be closed by a '>'"); +      Token.reset(MIToken::Error, Start.remaining()); +      return Start; +    } +    C.advance(); + +    Token.reset(MIToken::MCSymbol, Start.upto(C)).setStringValue(String); +    return C; +  } + +  // Otherwise lex out a quoted name. +  Cursor R = lexStringConstant(C, ErrorCallback); +  if (!R) { +    ErrorCallback(C.location(), +                  "unable to parse quoted string from opening quote"); +    Token.reset(MIToken::Error, Start.remaining()); +    return Start; +  } +  StringRef String = Start.upto(R).drop_front(Rule.size()); +  if (R.peek() != '>') { +    ErrorCallback(R.location(), +                  "expected the '<mcsymbol ...' to be closed by a '>'"); +    Token.reset(MIToken::Error, Start.remaining()); +    return Start; +  } +  R.advance(); + +  Token.reset(MIToken::MCSymbol, Start.upto(R)) +      .setOwnedStringValue(unescapeQuotedString(String)); +  return R; +} +  static bool isValidHexFloatingPointPrefix(char C) {    return C == 'H' || C == 'K' || C == 'L' || C == 'M';  } @@ -523,6 +577,7 @@ static MIToken::TokenKind getMetadataKeywordKind(StringRef Identifier) {        .Case("!noalias", MIToken::md_noalias)        .Case("!range", MIToken::md_range)        .Case("!DIExpression", MIToken::md_diexpr) +      .Case("!DILocation", MIToken::md_dilocation)        .Default(MIToken::Error);  } @@ -657,6 +712,8 @@ StringRef llvm::lexMIToken(StringRef Source, MIToken &Token,      return R.remaining();    if (Cursor R = maybeLexExternalSymbol(C, Token, ErrorCallback))      return R.remaining(); +  if (Cursor R = maybeLexMCSymbol(C, Token, ErrorCallback)) +    return R.remaining();    if (Cursor R = maybeLexHexadecimalLiteral(C, Token))      return R.remaining();    if (Cursor R = maybeLexNumericalLiteral(C, Token))  | 
