1 //===- MILexer.cpp - Machine instructions lexer implementation ------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements the lexing of machine instructions.
11 //===----------------------------------------------------------------------===//
14 #include "llvm/ADT/APSInt.h"
15 #include "llvm/ADT/None.h"
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/ADT/StringExtras.h"
18 #include "llvm/ADT/StringSwitch.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/ADT/Twine.h"
30 using ErrorCallbackType
=
31 function_ref
<void(StringRef::iterator Loc
, const Twine
&)>;
33 /// This class provides a way to iterate and get characters from the source
36 const char *Ptr
= nullptr;
37 const char *End
= nullptr;
42 explicit Cursor(StringRef Str
) {
44 End
= Ptr
+ Str
.size();
47 bool isEOF() const { return Ptr
== End
; }
49 char peek(int I
= 0) const { return End
- Ptr
<= I
? 0 : Ptr
[I
]; }
51 void advance(unsigned I
= 1) { Ptr
+= I
; }
53 StringRef
remaining() const { return StringRef(Ptr
, End
- Ptr
); }
55 StringRef
upto(Cursor C
) const {
56 assert(C
.Ptr
>= Ptr
&& C
.Ptr
<= End
);
57 return StringRef(Ptr
, C
.Ptr
- Ptr
);
60 StringRef::iterator
location() const { return Ptr
; }
62 operator bool() const { return Ptr
!= nullptr; }
65 } // end anonymous namespace
67 MIToken
&MIToken::reset(TokenKind Kind
, StringRef Range
) {
73 MIToken
&MIToken::setStringValue(StringRef StrVal
) {
78 MIToken
&MIToken::setOwnedStringValue(std::string StrVal
) {
79 StringValueStorage
= std::move(StrVal
);
80 StringValue
= StringValueStorage
;
84 MIToken
&MIToken::setIntegerValue(APSInt IntVal
) {
85 this->IntVal
= std::move(IntVal
);
89 /// Skip the leading whitespace characters and return the updated cursor.
90 static Cursor
skipWhitespace(Cursor C
) {
91 while (isblank(C
.peek()))
96 static bool isNewlineChar(char C
) { return C
== '\n' || C
== '\r'; }
98 /// Skip a line comment and return the updated cursor.
99 static Cursor
skipComment(Cursor C
) {
102 while (!isNewlineChar(C
.peek()) && !C
.isEOF())
107 /// Return true if the given character satisfies the following regular
108 /// expression: [-a-zA-Z$._0-9]
109 static bool isIdentifierChar(char C
) {
110 return isalpha(C
) || isdigit(C
) || C
== '_' || C
== '-' || C
== '.' ||
114 /// Unescapes the given string value.
116 /// Expects the string value to be quoted.
117 static std::string
unescapeQuotedString(StringRef Value
) {
118 assert(Value
.front() == '"' && Value
.back() == '"');
119 Cursor C
= Cursor(Value
.substr(1, Value
.size() - 2));
122 Str
.reserve(C
.remaining().size());
124 char Char
= C
.peek();
126 if (C
.peek(1) == '\\') {
127 // Two '\' become one
132 if (isxdigit(C
.peek(1)) && isxdigit(C
.peek(2))) {
133 Str
+= hexDigitValue(C
.peek(1)) * 16 + hexDigitValue(C
.peek(2));
144 /// Lex a string constant using the following regular expression: \"[^\"]*\"
145 static Cursor
lexStringConstant(Cursor C
, ErrorCallbackType ErrorCallback
) {
146 assert(C
.peek() == '"');
147 for (C
.advance(); C
.peek() != '"'; C
.advance()) {
148 if (C
.isEOF() || isNewlineChar(C
.peek())) {
151 "end of machine instruction reached before the closing '\"'");
159 static Cursor
lexName(Cursor C
, MIToken
&Token
, MIToken::TokenKind Type
,
160 unsigned PrefixLength
, ErrorCallbackType ErrorCallback
) {
162 C
.advance(PrefixLength
);
163 if (C
.peek() == '"') {
164 if (Cursor R
= lexStringConstant(C
, ErrorCallback
)) {
165 StringRef String
= Range
.upto(R
);
166 Token
.reset(Type
, String
)
167 .setOwnedStringValue(
168 unescapeQuotedString(String
.drop_front(PrefixLength
)));
171 Token
.reset(MIToken::Error
, Range
.remaining());
174 while (isIdentifierChar(C
.peek()))
176 Token
.reset(Type
, Range
.upto(C
))
177 .setStringValue(Range
.upto(C
).drop_front(PrefixLength
));
181 static MIToken::TokenKind
getIdentifierKind(StringRef Identifier
) {
182 return StringSwitch
<MIToken::TokenKind
>(Identifier
)
183 .Case("_", MIToken::underscore
)
184 .Case("implicit", MIToken::kw_implicit
)
185 .Case("implicit-def", MIToken::kw_implicit_define
)
186 .Case("def", MIToken::kw_def
)
187 .Case("dead", MIToken::kw_dead
)
188 .Case("killed", MIToken::kw_killed
)
189 .Case("undef", MIToken::kw_undef
)
190 .Case("internal", MIToken::kw_internal
)
191 .Case("early-clobber", MIToken::kw_early_clobber
)
192 .Case("debug-use", MIToken::kw_debug_use
)
193 .Case("renamable", MIToken::kw_renamable
)
194 .Case("tied-def", MIToken::kw_tied_def
)
195 .Case("frame-setup", MIToken::kw_frame_setup
)
196 .Case("frame-destroy", MIToken::kw_frame_destroy
)
197 .Case("nnan", MIToken::kw_nnan
)
198 .Case("ninf", MIToken::kw_ninf
)
199 .Case("nsz", MIToken::kw_nsz
)
200 .Case("arcp", MIToken::kw_arcp
)
201 .Case("contract", MIToken::kw_contract
)
202 .Case("afn", MIToken::kw_afn
)
203 .Case("reassoc", MIToken::kw_reassoc
)
204 .Case("nuw" , MIToken::kw_nuw
)
205 .Case("nsw" , MIToken::kw_nsw
)
206 .Case("exact" , MIToken::kw_exact
)
207 .Case("fpexcept", MIToken::kw_fpexcept
)
208 .Case("debug-location", MIToken::kw_debug_location
)
209 .Case("same_value", MIToken::kw_cfi_same_value
)
210 .Case("offset", MIToken::kw_cfi_offset
)
211 .Case("rel_offset", MIToken::kw_cfi_rel_offset
)
212 .Case("def_cfa_register", MIToken::kw_cfi_def_cfa_register
)
213 .Case("def_cfa_offset", MIToken::kw_cfi_def_cfa_offset
)
214 .Case("adjust_cfa_offset", MIToken::kw_cfi_adjust_cfa_offset
)
215 .Case("escape", MIToken::kw_cfi_escape
)
216 .Case("def_cfa", MIToken::kw_cfi_def_cfa
)
217 .Case("remember_state", MIToken::kw_cfi_remember_state
)
218 .Case("restore", MIToken::kw_cfi_restore
)
219 .Case("restore_state", MIToken::kw_cfi_restore_state
)
220 .Case("undefined", MIToken::kw_cfi_undefined
)
221 .Case("register", MIToken::kw_cfi_register
)
222 .Case("window_save", MIToken::kw_cfi_window_save
)
223 .Case("negate_ra_sign_state", MIToken::kw_cfi_aarch64_negate_ra_sign_state
)
224 .Case("blockaddress", MIToken::kw_blockaddress
)
225 .Case("intrinsic", MIToken::kw_intrinsic
)
226 .Case("target-index", MIToken::kw_target_index
)
227 .Case("half", MIToken::kw_half
)
228 .Case("float", MIToken::kw_float
)
229 .Case("double", MIToken::kw_double
)
230 .Case("x86_fp80", MIToken::kw_x86_fp80
)
231 .Case("fp128", MIToken::kw_fp128
)
232 .Case("ppc_fp128", MIToken::kw_ppc_fp128
)
233 .Case("target-flags", MIToken::kw_target_flags
)
234 .Case("volatile", MIToken::kw_volatile
)
235 .Case("non-temporal", MIToken::kw_non_temporal
)
236 .Case("dereferenceable", MIToken::kw_dereferenceable
)
237 .Case("invariant", MIToken::kw_invariant
)
238 .Case("align", MIToken::kw_align
)
239 .Case("addrspace", MIToken::kw_addrspace
)
240 .Case("stack", MIToken::kw_stack
)
241 .Case("got", MIToken::kw_got
)
242 .Case("jump-table", MIToken::kw_jump_table
)
243 .Case("constant-pool", MIToken::kw_constant_pool
)
244 .Case("call-entry", MIToken::kw_call_entry
)
245 .Case("liveout", MIToken::kw_liveout
)
246 .Case("address-taken", MIToken::kw_address_taken
)
247 .Case("landing-pad", MIToken::kw_landing_pad
)
248 .Case("liveins", MIToken::kw_liveins
)
249 .Case("successors", MIToken::kw_successors
)
250 .Case("floatpred", MIToken::kw_floatpred
)
251 .Case("intpred", MIToken::kw_intpred
)
252 .Case("shufflemask", MIToken::kw_shufflemask
)
253 .Case("pre-instr-symbol", MIToken::kw_pre_instr_symbol
)
254 .Case("post-instr-symbol", MIToken::kw_post_instr_symbol
)
255 .Case("unknown-size", MIToken::kw_unknown_size
)
256 .Default(MIToken::Identifier
);
259 static Cursor
maybeLexIdentifier(Cursor C
, MIToken
&Token
) {
260 if (!isalpha(C
.peek()) && C
.peek() != '_')
263 while (isIdentifierChar(C
.peek()))
265 auto Identifier
= Range
.upto(C
);
266 Token
.reset(getIdentifierKind(Identifier
), Identifier
)
267 .setStringValue(Identifier
);
271 static Cursor
maybeLexMachineBasicBlock(Cursor C
, MIToken
&Token
,
272 ErrorCallbackType ErrorCallback
) {
273 bool IsReference
= C
.remaining().startswith("%bb.");
274 if (!IsReference
&& !C
.remaining().startswith("bb."))
277 unsigned PrefixLength
= IsReference
? 4 : 3;
278 C
.advance(PrefixLength
); // Skip '%bb.' or 'bb.'
279 if (!isdigit(C
.peek())) {
280 Token
.reset(MIToken::Error
, C
.remaining());
281 ErrorCallback(C
.location(), "expected a number after '%bb.'");
284 auto NumberRange
= C
;
285 while (isdigit(C
.peek()))
287 StringRef Number
= NumberRange
.upto(C
);
288 unsigned StringOffset
= PrefixLength
+ Number
.size(); // Drop '%bb.<id>'
289 // TODO: The format bb.<id>.<irname> is supported only when it's not a
290 // reference. Once we deprecate the format where the irname shows up, we
291 // should only lex forward if it is a reference.
292 if (C
.peek() == '.') {
293 C
.advance(); // Skip '.'
295 while (isIdentifierChar(C
.peek()))
298 Token
.reset(IsReference
? MIToken::MachineBasicBlock
299 : MIToken::MachineBasicBlockLabel
,
301 .setIntegerValue(APSInt(Number
))
302 .setStringValue(Range
.upto(C
).drop_front(StringOffset
));
306 static Cursor
maybeLexIndex(Cursor C
, MIToken
&Token
, StringRef Rule
,
307 MIToken::TokenKind Kind
) {
308 if (!C
.remaining().startswith(Rule
) || !isdigit(C
.peek(Rule
.size())))
311 C
.advance(Rule
.size());
312 auto NumberRange
= C
;
313 while (isdigit(C
.peek()))
315 Token
.reset(Kind
, Range
.upto(C
)).setIntegerValue(APSInt(NumberRange
.upto(C
)));
319 static Cursor
maybeLexIndexAndName(Cursor C
, MIToken
&Token
, StringRef Rule
,
320 MIToken::TokenKind Kind
) {
321 if (!C
.remaining().startswith(Rule
) || !isdigit(C
.peek(Rule
.size())))
324 C
.advance(Rule
.size());
325 auto NumberRange
= C
;
326 while (isdigit(C
.peek()))
328 StringRef Number
= NumberRange
.upto(C
);
329 unsigned StringOffset
= Rule
.size() + Number
.size();
330 if (C
.peek() == '.') {
333 while (isIdentifierChar(C
.peek()))
336 Token
.reset(Kind
, Range
.upto(C
))
337 .setIntegerValue(APSInt(Number
))
338 .setStringValue(Range
.upto(C
).drop_front(StringOffset
));
342 static Cursor
maybeLexJumpTableIndex(Cursor C
, MIToken
&Token
) {
343 return maybeLexIndex(C
, Token
, "%jump-table.", MIToken::JumpTableIndex
);
346 static Cursor
maybeLexStackObject(Cursor C
, MIToken
&Token
) {
347 return maybeLexIndexAndName(C
, Token
, "%stack.", MIToken::StackObject
);
350 static Cursor
maybeLexFixedStackObject(Cursor C
, MIToken
&Token
) {
351 return maybeLexIndex(C
, Token
, "%fixed-stack.", MIToken::FixedStackObject
);
354 static Cursor
maybeLexConstantPoolItem(Cursor C
, MIToken
&Token
) {
355 return maybeLexIndex(C
, Token
, "%const.", MIToken::ConstantPoolItem
);
358 static Cursor
maybeLexSubRegisterIndex(Cursor C
, MIToken
&Token
,
359 ErrorCallbackType ErrorCallback
) {
360 const StringRef Rule
= "%subreg.";
361 if (!C
.remaining().startswith(Rule
))
363 return lexName(C
, Token
, MIToken::SubRegisterIndex
, Rule
.size(),
367 static Cursor
maybeLexIRBlock(Cursor C
, MIToken
&Token
,
368 ErrorCallbackType ErrorCallback
) {
369 const StringRef Rule
= "%ir-block.";
370 if (!C
.remaining().startswith(Rule
))
372 if (isdigit(C
.peek(Rule
.size())))
373 return maybeLexIndex(C
, Token
, Rule
, MIToken::IRBlock
);
374 return lexName(C
, Token
, MIToken::NamedIRBlock
, Rule
.size(), ErrorCallback
);
377 static Cursor
maybeLexIRValue(Cursor C
, MIToken
&Token
,
378 ErrorCallbackType ErrorCallback
) {
379 const StringRef Rule
= "%ir.";
380 if (!C
.remaining().startswith(Rule
))
382 if (isdigit(C
.peek(Rule
.size())))
383 return maybeLexIndex(C
, Token
, Rule
, MIToken::IRValue
);
384 return lexName(C
, Token
, MIToken::NamedIRValue
, Rule
.size(), ErrorCallback
);
387 static Cursor
maybeLexStringConstant(Cursor C
, MIToken
&Token
,
388 ErrorCallbackType ErrorCallback
) {
391 return lexName(C
, Token
, MIToken::StringConstant
, /*PrefixLength=*/0,
395 static Cursor
lexVirtualRegister(Cursor C
, MIToken
&Token
) {
397 C
.advance(); // Skip '%'
398 auto NumberRange
= C
;
399 while (isdigit(C
.peek()))
401 Token
.reset(MIToken::VirtualRegister
, Range
.upto(C
))
402 .setIntegerValue(APSInt(NumberRange
.upto(C
)));
406 /// Returns true for a character allowed in a register name.
407 static bool isRegisterChar(char C
) {
408 return isIdentifierChar(C
) && C
!= '.';
411 static Cursor
lexNamedVirtualRegister(Cursor C
, MIToken
&Token
) {
413 C
.advance(); // Skip '%'
414 while (isRegisterChar(C
.peek()))
416 Token
.reset(MIToken::NamedVirtualRegister
, Range
.upto(C
))
417 .setStringValue(Range
.upto(C
).drop_front(1)); // Drop the '%'
421 static Cursor
maybeLexRegister(Cursor C
, MIToken
&Token
,
422 ErrorCallbackType ErrorCallback
) {
423 if (C
.peek() != '%' && C
.peek() != '$')
426 if (C
.peek() == '%') {
427 if (isdigit(C
.peek(1)))
428 return lexVirtualRegister(C
, Token
);
430 if (isRegisterChar(C
.peek(1)))
431 return lexNamedVirtualRegister(C
, Token
);
436 assert(C
.peek() == '$');
438 C
.advance(); // Skip '$'
439 while (isRegisterChar(C
.peek()))
441 Token
.reset(MIToken::NamedRegister
, Range
.upto(C
))
442 .setStringValue(Range
.upto(C
).drop_front(1)); // Drop the '$'
446 static Cursor
maybeLexGlobalValue(Cursor C
, MIToken
&Token
,
447 ErrorCallbackType ErrorCallback
) {
450 if (!isdigit(C
.peek(1)))
451 return lexName(C
, Token
, MIToken::NamedGlobalValue
, /*PrefixLength=*/1,
454 C
.advance(1); // Skip the '@'
455 auto NumberRange
= C
;
456 while (isdigit(C
.peek()))
458 Token
.reset(MIToken::GlobalValue
, Range
.upto(C
))
459 .setIntegerValue(APSInt(NumberRange
.upto(C
)));
463 static Cursor
maybeLexExternalSymbol(Cursor C
, MIToken
&Token
,
464 ErrorCallbackType ErrorCallback
) {
467 return lexName(C
, Token
, MIToken::ExternalSymbol
, /*PrefixLength=*/1,
471 static Cursor
maybeLexMCSymbol(Cursor C
, MIToken
&Token
,
472 ErrorCallbackType ErrorCallback
) {
473 const StringRef Rule
= "<mcsymbol ";
474 if (!C
.remaining().startswith(Rule
))
477 C
.advance(Rule
.size());
479 // Try a simple unquoted name.
480 if (C
.peek() != '"') {
481 while (isIdentifierChar(C
.peek()))
483 StringRef String
= Start
.upto(C
).drop_front(Rule
.size());
484 if (C
.peek() != '>') {
485 ErrorCallback(C
.location(),
486 "expected the '<mcsymbol ...' to be closed by a '>'");
487 Token
.reset(MIToken::Error
, Start
.remaining());
492 Token
.reset(MIToken::MCSymbol
, Start
.upto(C
)).setStringValue(String
);
496 // Otherwise lex out a quoted name.
497 Cursor R
= lexStringConstant(C
, ErrorCallback
);
499 ErrorCallback(C
.location(),
500 "unable to parse quoted string from opening quote");
501 Token
.reset(MIToken::Error
, Start
.remaining());
504 StringRef String
= Start
.upto(R
).drop_front(Rule
.size());
505 if (R
.peek() != '>') {
506 ErrorCallback(R
.location(),
507 "expected the '<mcsymbol ...' to be closed by a '>'");
508 Token
.reset(MIToken::Error
, Start
.remaining());
513 Token
.reset(MIToken::MCSymbol
, Start
.upto(R
))
514 .setOwnedStringValue(unescapeQuotedString(String
));
518 static bool isValidHexFloatingPointPrefix(char C
) {
519 return C
== 'H' || C
== 'K' || C
== 'L' || C
== 'M';
522 static Cursor
lexFloatingPointLiteral(Cursor Range
, Cursor C
, MIToken
&Token
) {
524 // Skip over [0-9]*([eE][-+]?[0-9]+)?
525 while (isdigit(C
.peek()))
527 if ((C
.peek() == 'e' || C
.peek() == 'E') &&
528 (isdigit(C
.peek(1)) ||
529 ((C
.peek(1) == '-' || C
.peek(1) == '+') && isdigit(C
.peek(2))))) {
531 while (isdigit(C
.peek()))
534 Token
.reset(MIToken::FloatingPointLiteral
, Range
.upto(C
));
538 static Cursor
maybeLexHexadecimalLiteral(Cursor C
, MIToken
&Token
) {
539 if (C
.peek() != '0' || (C
.peek(1) != 'x' && C
.peek(1) != 'X'))
543 unsigned PrefLen
= 2;
544 if (isValidHexFloatingPointPrefix(C
.peek())) {
548 while (isxdigit(C
.peek()))
550 StringRef StrVal
= Range
.upto(C
);
551 if (StrVal
.size() <= PrefLen
)
554 Token
.reset(MIToken::HexLiteral
, Range
.upto(C
));
555 else // It must be 3, which means that there was a floating-point prefix.
556 Token
.reset(MIToken::FloatingPointLiteral
, Range
.upto(C
));
560 static Cursor
maybeLexNumericalLiteral(Cursor C
, MIToken
&Token
) {
561 if (!isdigit(C
.peek()) && (C
.peek() != '-' || !isdigit(C
.peek(1))))
565 while (isdigit(C
.peek()))
568 return lexFloatingPointLiteral(Range
, C
, Token
);
569 StringRef StrVal
= Range
.upto(C
);
570 Token
.reset(MIToken::IntegerLiteral
, StrVal
).setIntegerValue(APSInt(StrVal
));
574 static MIToken::TokenKind
getMetadataKeywordKind(StringRef Identifier
) {
575 return StringSwitch
<MIToken::TokenKind
>(Identifier
)
576 .Case("!tbaa", MIToken::md_tbaa
)
577 .Case("!alias.scope", MIToken::md_alias_scope
)
578 .Case("!noalias", MIToken::md_noalias
)
579 .Case("!range", MIToken::md_range
)
580 .Case("!DIExpression", MIToken::md_diexpr
)
581 .Case("!DILocation", MIToken::md_dilocation
)
582 .Default(MIToken::Error
);
585 static Cursor
maybeLexExlaim(Cursor C
, MIToken
&Token
,
586 ErrorCallbackType ErrorCallback
) {
591 if (isdigit(C
.peek()) || !isIdentifierChar(C
.peek())) {
592 Token
.reset(MIToken::exclaim
, Range
.upto(C
));
595 while (isIdentifierChar(C
.peek()))
597 StringRef StrVal
= Range
.upto(C
);
598 Token
.reset(getMetadataKeywordKind(StrVal
), StrVal
);
600 ErrorCallback(Token
.location(),
601 "use of unknown metadata keyword '" + StrVal
+ "'");
605 static MIToken::TokenKind
symbolToken(char C
) {
608 return MIToken::comma
;
612 return MIToken::equal
;
614 return MIToken::colon
;
616 return MIToken::lparen
;
618 return MIToken::rparen
;
620 return MIToken::lbrace
;
622 return MIToken::rbrace
;
624 return MIToken::plus
;
626 return MIToken::minus
;
628 return MIToken::less
;
630 return MIToken::greater
;
632 return MIToken::Error
;
636 static Cursor
maybeLexSymbol(Cursor C
, MIToken
&Token
) {
637 MIToken::TokenKind Kind
;
639 if (C
.peek() == ':' && C
.peek(1) == ':') {
640 Kind
= MIToken::coloncolon
;
643 Kind
= symbolToken(C
.peek());
644 if (Kind
== MIToken::Error
)
648 Token
.reset(Kind
, Range
.upto(C
));
652 static Cursor
maybeLexNewline(Cursor C
, MIToken
&Token
) {
653 if (!isNewlineChar(C
.peek()))
657 Token
.reset(MIToken::Newline
, Range
.upto(C
));
661 static Cursor
maybeLexEscapedIRValue(Cursor C
, MIToken
&Token
,
662 ErrorCallbackType ErrorCallback
) {
668 while (C
.peek() != '`') {
669 if (C
.isEOF() || isNewlineChar(C
.peek())) {
672 "end of machine instruction reached before the closing '`'");
673 Token
.reset(MIToken::Error
, Range
.remaining());
678 StringRef Value
= StrRange
.upto(C
);
680 Token
.reset(MIToken::QuotedIRValue
, Range
.upto(C
)).setStringValue(Value
);
684 StringRef
llvm::lexMIToken(StringRef Source
, MIToken
&Token
,
685 ErrorCallbackType ErrorCallback
) {
686 auto C
= skipComment(skipWhitespace(Cursor(Source
)));
688 Token
.reset(MIToken::Eof
, C
.remaining());
689 return C
.remaining();
692 if (Cursor R
= maybeLexMachineBasicBlock(C
, Token
, ErrorCallback
))
693 return R
.remaining();
694 if (Cursor R
= maybeLexIdentifier(C
, Token
))
695 return R
.remaining();
696 if (Cursor R
= maybeLexJumpTableIndex(C
, Token
))
697 return R
.remaining();
698 if (Cursor R
= maybeLexStackObject(C
, Token
))
699 return R
.remaining();
700 if (Cursor R
= maybeLexFixedStackObject(C
, Token
))
701 return R
.remaining();
702 if (Cursor R
= maybeLexConstantPoolItem(C
, Token
))
703 return R
.remaining();
704 if (Cursor R
= maybeLexSubRegisterIndex(C
, Token
, ErrorCallback
))
705 return R
.remaining();
706 if (Cursor R
= maybeLexIRBlock(C
, Token
, ErrorCallback
))
707 return R
.remaining();
708 if (Cursor R
= maybeLexIRValue(C
, Token
, ErrorCallback
))
709 return R
.remaining();
710 if (Cursor R
= maybeLexRegister(C
, Token
, ErrorCallback
))
711 return R
.remaining();
712 if (Cursor R
= maybeLexGlobalValue(C
, Token
, ErrorCallback
))
713 return R
.remaining();
714 if (Cursor R
= maybeLexExternalSymbol(C
, Token
, ErrorCallback
))
715 return R
.remaining();
716 if (Cursor R
= maybeLexMCSymbol(C
, Token
, ErrorCallback
))
717 return R
.remaining();
718 if (Cursor R
= maybeLexHexadecimalLiteral(C
, Token
))
719 return R
.remaining();
720 if (Cursor R
= maybeLexNumericalLiteral(C
, Token
))
721 return R
.remaining();
722 if (Cursor R
= maybeLexExlaim(C
, Token
, ErrorCallback
))
723 return R
.remaining();
724 if (Cursor R
= maybeLexSymbol(C
, Token
))
725 return R
.remaining();
726 if (Cursor R
= maybeLexNewline(C
, Token
))
727 return R
.remaining();
728 if (Cursor R
= maybeLexEscapedIRValue(C
, Token
, ErrorCallback
))
729 return R
.remaining();
730 if (Cursor R
= maybeLexStringConstant(C
, Token
, ErrorCallback
))
731 return R
.remaining();
733 Token
.reset(MIToken::Error
, C
.remaining());
734 ErrorCallback(C
.location(),
735 Twine("unexpected character '") + Twine(C
.peek()) + "'");
736 return C
.remaining();