• Home
  • Raw
  • Download

Lines Matching refs:C

50   StringRef upto(Cursor C) const {  in upto()
51 assert(C.Ptr >= Ptr && C.Ptr <= End); in upto()
52 return StringRef(Ptr, C.Ptr - Ptr); in upto()
85 static Cursor skipWhitespace(Cursor C) { in skipWhitespace() argument
86 while (isblank(C.peek())) in skipWhitespace()
87 C.advance(); in skipWhitespace()
88 return C; in skipWhitespace()
91 static bool isNewlineChar(char C) { return C == '\n' || C == '\r'; } in isNewlineChar() argument
94 static Cursor skipComment(Cursor C) { in skipComment() argument
95 if (C.peek() != ';') in skipComment()
96 return C; in skipComment()
97 while (!isNewlineChar(C.peek()) && !C.isEOF()) in skipComment()
98 C.advance(); in skipComment()
99 return C; in skipComment()
104 static bool isIdentifierChar(char C) { in isIdentifierChar() argument
105 return isalpha(C) || isdigit(C) || C == '_' || C == '-' || C == '.' || in isIdentifierChar()
106 C == '$'; in isIdentifierChar()
114 Cursor C = Cursor(Value.substr(1, Value.size() - 2)); in unescapeQuotedString() local
117 Str.reserve(C.remaining().size()); in unescapeQuotedString()
118 while (!C.isEOF()) { in unescapeQuotedString()
119 char Char = C.peek(); in unescapeQuotedString()
121 if (C.peek(1) == '\\') { in unescapeQuotedString()
124 C.advance(2); in unescapeQuotedString()
127 if (isxdigit(C.peek(1)) && isxdigit(C.peek(2))) { in unescapeQuotedString()
128 Str += hexDigitValue(C.peek(1)) * 16 + hexDigitValue(C.peek(2)); in unescapeQuotedString()
129 C.advance(3); in unescapeQuotedString()
134 C.advance(); in unescapeQuotedString()
140 static Cursor lexStringConstant(Cursor C, ErrorCallbackType ErrorCallback) { in lexStringConstant() argument
141 assert(C.peek() == '"'); in lexStringConstant()
142 for (C.advance(); C.peek() != '"'; C.advance()) { in lexStringConstant()
143 if (C.isEOF() || isNewlineChar(C.peek())) { in lexStringConstant()
145 C.location(), in lexStringConstant()
150 C.advance(); in lexStringConstant()
151 return C; in lexStringConstant()
154 static Cursor lexName(Cursor C, MIToken &Token, MIToken::TokenKind Type, in lexName() argument
156 auto Range = C; in lexName()
157 C.advance(PrefixLength); in lexName()
158 if (C.peek() == '"') { in lexName()
159 if (Cursor R = lexStringConstant(C, ErrorCallback)) { in lexName()
169 while (isIdentifierChar(C.peek())) in lexName()
170 C.advance(); in lexName()
171 Token.reset(Type, Range.upto(C)) in lexName()
172 .setStringValue(Range.upto(C).drop_front(PrefixLength)); in lexName()
173 return C; in lexName()
176 static Cursor maybeLexIntegerType(Cursor C, MIToken &Token) { in maybeLexIntegerType() argument
177 if (C.peek() != 'i' || !isdigit(C.peek(1))) in maybeLexIntegerType()
179 auto Range = C; in maybeLexIntegerType()
180 C.advance(); // Skip 'i' in maybeLexIntegerType()
181 while (isdigit(C.peek())) in maybeLexIntegerType()
182 C.advance(); in maybeLexIntegerType()
183 Token.reset(MIToken::IntegerType, Range.upto(C)); in maybeLexIntegerType()
184 return C; in maybeLexIntegerType()
233 static Cursor maybeLexIdentifier(Cursor C, MIToken &Token) { in maybeLexIdentifier() argument
234 if (!isalpha(C.peek()) && C.peek() != '_' && C.peek() != '.') in maybeLexIdentifier()
236 auto Range = C; in maybeLexIdentifier()
237 while (isIdentifierChar(C.peek())) in maybeLexIdentifier()
238 C.advance(); in maybeLexIdentifier()
239 auto Identifier = Range.upto(C); in maybeLexIdentifier()
242 return C; in maybeLexIdentifier()
245 static Cursor maybeLexMachineBasicBlock(Cursor C, MIToken &Token, in maybeLexMachineBasicBlock() argument
247 bool IsReference = C.remaining().startswith("%bb."); in maybeLexMachineBasicBlock()
248 if (!IsReference && !C.remaining().startswith("bb.")) in maybeLexMachineBasicBlock()
250 auto Range = C; in maybeLexMachineBasicBlock()
252 C.advance(PrefixLength); // Skip '%bb.' or 'bb.' in maybeLexMachineBasicBlock()
253 if (!isdigit(C.peek())) { in maybeLexMachineBasicBlock()
254 Token.reset(MIToken::Error, C.remaining()); in maybeLexMachineBasicBlock()
255 ErrorCallback(C.location(), "expected a number after '%bb.'"); in maybeLexMachineBasicBlock()
256 return C; in maybeLexMachineBasicBlock()
258 auto NumberRange = C; in maybeLexMachineBasicBlock()
259 while (isdigit(C.peek())) in maybeLexMachineBasicBlock()
260 C.advance(); in maybeLexMachineBasicBlock()
261 StringRef Number = NumberRange.upto(C); in maybeLexMachineBasicBlock()
263 if (C.peek() == '.') { in maybeLexMachineBasicBlock()
264 C.advance(); // Skip '.' in maybeLexMachineBasicBlock()
266 while (isIdentifierChar(C.peek())) in maybeLexMachineBasicBlock()
267 C.advance(); in maybeLexMachineBasicBlock()
271 Range.upto(C)) in maybeLexMachineBasicBlock()
273 .setStringValue(Range.upto(C).drop_front(StringOffset)); in maybeLexMachineBasicBlock()
274 return C; in maybeLexMachineBasicBlock()
277 static Cursor maybeLexIndex(Cursor C, MIToken &Token, StringRef Rule, in maybeLexIndex() argument
279 if (!C.remaining().startswith(Rule) || !isdigit(C.peek(Rule.size()))) in maybeLexIndex()
281 auto Range = C; in maybeLexIndex()
282 C.advance(Rule.size()); in maybeLexIndex()
283 auto NumberRange = C; in maybeLexIndex()
284 while (isdigit(C.peek())) in maybeLexIndex()
285 C.advance(); in maybeLexIndex()
286 Token.reset(Kind, Range.upto(C)).setIntegerValue(APSInt(NumberRange.upto(C))); in maybeLexIndex()
287 return C; in maybeLexIndex()
290 static Cursor maybeLexIndexAndName(Cursor C, MIToken &Token, StringRef Rule, in maybeLexIndexAndName() argument
292 if (!C.remaining().startswith(Rule) || !isdigit(C.peek(Rule.size()))) in maybeLexIndexAndName()
294 auto Range = C; in maybeLexIndexAndName()
295 C.advance(Rule.size()); in maybeLexIndexAndName()
296 auto NumberRange = C; in maybeLexIndexAndName()
297 while (isdigit(C.peek())) in maybeLexIndexAndName()
298 C.advance(); in maybeLexIndexAndName()
299 StringRef Number = NumberRange.upto(C); in maybeLexIndexAndName()
301 if (C.peek() == '.') { in maybeLexIndexAndName()
302 C.advance(); in maybeLexIndexAndName()
304 while (isIdentifierChar(C.peek())) in maybeLexIndexAndName()
305 C.advance(); in maybeLexIndexAndName()
307 Token.reset(Kind, Range.upto(C)) in maybeLexIndexAndName()
309 .setStringValue(Range.upto(C).drop_front(StringOffset)); in maybeLexIndexAndName()
310 return C; in maybeLexIndexAndName()
313 static Cursor maybeLexJumpTableIndex(Cursor C, MIToken &Token) { in maybeLexJumpTableIndex() argument
314 return maybeLexIndex(C, Token, "%jump-table.", MIToken::JumpTableIndex); in maybeLexJumpTableIndex()
317 static Cursor maybeLexStackObject(Cursor C, MIToken &Token) { in maybeLexStackObject() argument
318 return maybeLexIndexAndName(C, Token, "%stack.", MIToken::StackObject); in maybeLexStackObject()
321 static Cursor maybeLexFixedStackObject(Cursor C, MIToken &Token) { in maybeLexFixedStackObject() argument
322 return maybeLexIndex(C, Token, "%fixed-stack.", MIToken::FixedStackObject); in maybeLexFixedStackObject()
325 static Cursor maybeLexConstantPoolItem(Cursor C, MIToken &Token) { in maybeLexConstantPoolItem() argument
326 return maybeLexIndex(C, Token, "%const.", MIToken::ConstantPoolItem); in maybeLexConstantPoolItem()
329 static Cursor maybeLexSubRegisterIndex(Cursor C, MIToken &Token, in maybeLexSubRegisterIndex() argument
332 if (!C.remaining().startswith(Rule)) in maybeLexSubRegisterIndex()
334 return lexName(C, Token, MIToken::SubRegisterIndex, Rule.size(), in maybeLexSubRegisterIndex()
338 static Cursor maybeLexIRBlock(Cursor C, MIToken &Token, in maybeLexIRBlock() argument
341 if (!C.remaining().startswith(Rule)) in maybeLexIRBlock()
343 if (isdigit(C.peek(Rule.size()))) in maybeLexIRBlock()
344 return maybeLexIndex(C, Token, Rule, MIToken::IRBlock); in maybeLexIRBlock()
345 return lexName(C, Token, MIToken::NamedIRBlock, Rule.size(), ErrorCallback); in maybeLexIRBlock()
348 static Cursor maybeLexIRValue(Cursor C, MIToken &Token, in maybeLexIRValue() argument
351 if (!C.remaining().startswith(Rule)) in maybeLexIRValue()
353 if (isdigit(C.peek(Rule.size()))) in maybeLexIRValue()
354 return maybeLexIndex(C, Token, Rule, MIToken::IRValue); in maybeLexIRValue()
355 return lexName(C, Token, MIToken::NamedIRValue, Rule.size(), ErrorCallback); in maybeLexIRValue()
358 static Cursor lexVirtualRegister(Cursor C, MIToken &Token) { in lexVirtualRegister() argument
359 auto Range = C; in lexVirtualRegister()
360 C.advance(); // Skip '%' in lexVirtualRegister()
361 auto NumberRange = C; in lexVirtualRegister()
362 while (isdigit(C.peek())) in lexVirtualRegister()
363 C.advance(); in lexVirtualRegister()
364 Token.reset(MIToken::VirtualRegister, Range.upto(C)) in lexVirtualRegister()
365 .setIntegerValue(APSInt(NumberRange.upto(C))); in lexVirtualRegister()
366 return C; in lexVirtualRegister()
369 static Cursor maybeLexRegister(Cursor C, MIToken &Token) { in maybeLexRegister() argument
370 if (C.peek() != '%') in maybeLexRegister()
372 if (isdigit(C.peek(1))) in maybeLexRegister()
373 return lexVirtualRegister(C, Token); in maybeLexRegister()
374 auto Range = C; in maybeLexRegister()
375 C.advance(); // Skip '%' in maybeLexRegister()
376 while (isIdentifierChar(C.peek())) in maybeLexRegister()
377 C.advance(); in maybeLexRegister()
378 Token.reset(MIToken::NamedRegister, Range.upto(C)) in maybeLexRegister()
379 .setStringValue(Range.upto(C).drop_front(1)); // Drop the '%' in maybeLexRegister()
380 return C; in maybeLexRegister()
383 static Cursor maybeLexGlobalValue(Cursor C, MIToken &Token, in maybeLexGlobalValue() argument
385 if (C.peek() != '@') in maybeLexGlobalValue()
387 if (!isdigit(C.peek(1))) in maybeLexGlobalValue()
388 return lexName(C, Token, MIToken::NamedGlobalValue, /*PrefixLength=*/1, in maybeLexGlobalValue()
390 auto Range = C; in maybeLexGlobalValue()
391 C.advance(1); // Skip the '@' in maybeLexGlobalValue()
392 auto NumberRange = C; in maybeLexGlobalValue()
393 while (isdigit(C.peek())) in maybeLexGlobalValue()
394 C.advance(); in maybeLexGlobalValue()
395 Token.reset(MIToken::GlobalValue, Range.upto(C)) in maybeLexGlobalValue()
396 .setIntegerValue(APSInt(NumberRange.upto(C))); in maybeLexGlobalValue()
397 return C; in maybeLexGlobalValue()
400 static Cursor maybeLexExternalSymbol(Cursor C, MIToken &Token, in maybeLexExternalSymbol() argument
402 if (C.peek() != '$') in maybeLexExternalSymbol()
404 return lexName(C, Token, MIToken::ExternalSymbol, /*PrefixLength=*/1, in maybeLexExternalSymbol()
408 static bool isValidHexFloatingPointPrefix(char C) { in isValidHexFloatingPointPrefix() argument
409 return C == 'H' || C == 'K' || C == 'L' || C == 'M'; in isValidHexFloatingPointPrefix()
412 static Cursor maybeLexHexFloatingPointLiteral(Cursor C, MIToken &Token) { in maybeLexHexFloatingPointLiteral() argument
413 if (C.peek() != '0' || C.peek(1) != 'x') in maybeLexHexFloatingPointLiteral()
415 Cursor Range = C; in maybeLexHexFloatingPointLiteral()
416 C.advance(2); // Skip '0x' in maybeLexHexFloatingPointLiteral()
417 if (isValidHexFloatingPointPrefix(C.peek())) in maybeLexHexFloatingPointLiteral()
418 C.advance(); in maybeLexHexFloatingPointLiteral()
419 while (isxdigit(C.peek())) in maybeLexHexFloatingPointLiteral()
420 C.advance(); in maybeLexHexFloatingPointLiteral()
421 Token.reset(MIToken::FloatingPointLiteral, Range.upto(C)); in maybeLexHexFloatingPointLiteral()
422 return C; in maybeLexHexFloatingPointLiteral()
425 static Cursor lexFloatingPointLiteral(Cursor Range, Cursor C, MIToken &Token) { in lexFloatingPointLiteral() argument
426 C.advance(); in lexFloatingPointLiteral()
428 while (isdigit(C.peek())) in lexFloatingPointLiteral()
429 C.advance(); in lexFloatingPointLiteral()
430 if ((C.peek() == 'e' || C.peek() == 'E') && in lexFloatingPointLiteral()
431 (isdigit(C.peek(1)) || in lexFloatingPointLiteral()
432 ((C.peek(1) == '-' || C.peek(1) == '+') && isdigit(C.peek(2))))) { in lexFloatingPointLiteral()
433 C.advance(2); in lexFloatingPointLiteral()
434 while (isdigit(C.peek())) in lexFloatingPointLiteral()
435 C.advance(); in lexFloatingPointLiteral()
437 Token.reset(MIToken::FloatingPointLiteral, Range.upto(C)); in lexFloatingPointLiteral()
438 return C; in lexFloatingPointLiteral()
441 static Cursor maybeLexNumericalLiteral(Cursor C, MIToken &Token) { in maybeLexNumericalLiteral() argument
442 if (!isdigit(C.peek()) && (C.peek() != '-' || !isdigit(C.peek(1)))) in maybeLexNumericalLiteral()
444 auto Range = C; in maybeLexNumericalLiteral()
445 C.advance(); in maybeLexNumericalLiteral()
446 while (isdigit(C.peek())) in maybeLexNumericalLiteral()
447 C.advance(); in maybeLexNumericalLiteral()
448 if (C.peek() == '.') in maybeLexNumericalLiteral()
449 return lexFloatingPointLiteral(Range, C, Token); in maybeLexNumericalLiteral()
450 StringRef StrVal = Range.upto(C); in maybeLexNumericalLiteral()
452 return C; in maybeLexNumericalLiteral()
464 static Cursor maybeLexExlaim(Cursor C, MIToken &Token, in maybeLexExlaim() argument
466 if (C.peek() != '!') in maybeLexExlaim()
468 auto Range = C; in maybeLexExlaim()
469 C.advance(1); in maybeLexExlaim()
470 if (isdigit(C.peek()) || !isIdentifierChar(C.peek())) { in maybeLexExlaim()
471 Token.reset(MIToken::exclaim, Range.upto(C)); in maybeLexExlaim()
472 return C; in maybeLexExlaim()
474 while (isIdentifierChar(C.peek())) in maybeLexExlaim()
475 C.advance(); in maybeLexExlaim()
476 StringRef StrVal = Range.upto(C); in maybeLexExlaim()
481 return C; in maybeLexExlaim()
484 static MIToken::TokenKind symbolToken(char C) { in symbolToken() argument
485 switch (C) { in symbolToken()
513 static Cursor maybeLexSymbol(Cursor C, MIToken &Token) { in maybeLexSymbol() argument
516 if (C.peek() == ':' && C.peek(1) == ':') { in maybeLexSymbol()
520 Kind = symbolToken(C.peek()); in maybeLexSymbol()
523 auto Range = C; in maybeLexSymbol()
524 C.advance(Length); in maybeLexSymbol()
525 Token.reset(Kind, Range.upto(C)); in maybeLexSymbol()
526 return C; in maybeLexSymbol()
529 static Cursor maybeLexNewline(Cursor C, MIToken &Token) { in maybeLexNewline() argument
530 if (!isNewlineChar(C.peek())) in maybeLexNewline()
532 auto Range = C; in maybeLexNewline()
533 C.advance(); in maybeLexNewline()
534 Token.reset(MIToken::Newline, Range.upto(C)); in maybeLexNewline()
535 return C; in maybeLexNewline()
538 static Cursor maybeLexEscapedIRValue(Cursor C, MIToken &Token, in maybeLexEscapedIRValue() argument
540 if (C.peek() != '`') in maybeLexEscapedIRValue()
542 auto Range = C; in maybeLexEscapedIRValue()
543 C.advance(); in maybeLexEscapedIRValue()
544 auto StrRange = C; in maybeLexEscapedIRValue()
545 while (C.peek() != '`') { in maybeLexEscapedIRValue()
546 if (C.isEOF() || isNewlineChar(C.peek())) { in maybeLexEscapedIRValue()
548 C.location(), in maybeLexEscapedIRValue()
551 return C; in maybeLexEscapedIRValue()
553 C.advance(); in maybeLexEscapedIRValue()
555 StringRef Value = StrRange.upto(C); in maybeLexEscapedIRValue()
556 C.advance(); in maybeLexEscapedIRValue()
557 Token.reset(MIToken::QuotedIRValue, Range.upto(C)).setStringValue(Value); in maybeLexEscapedIRValue()
558 return C; in maybeLexEscapedIRValue()
563 auto C = skipComment(skipWhitespace(Cursor(Source))); in lexMIToken() local
564 if (C.isEOF()) { in lexMIToken()
565 Token.reset(MIToken::Eof, C.remaining()); in lexMIToken()
566 return C.remaining(); in lexMIToken()
569 if (Cursor R = maybeLexIntegerType(C, Token)) in lexMIToken()
571 if (Cursor R = maybeLexMachineBasicBlock(C, Token, ErrorCallback)) in lexMIToken()
573 if (Cursor R = maybeLexIdentifier(C, Token)) in lexMIToken()
575 if (Cursor R = maybeLexJumpTableIndex(C, Token)) in lexMIToken()
577 if (Cursor R = maybeLexStackObject(C, Token)) in lexMIToken()
579 if (Cursor R = maybeLexFixedStackObject(C, Token)) in lexMIToken()
581 if (Cursor R = maybeLexConstantPoolItem(C, Token)) in lexMIToken()
583 if (Cursor R = maybeLexSubRegisterIndex(C, Token, ErrorCallback)) in lexMIToken()
585 if (Cursor R = maybeLexIRBlock(C, Token, ErrorCallback)) in lexMIToken()
587 if (Cursor R = maybeLexIRValue(C, Token, ErrorCallback)) in lexMIToken()
589 if (Cursor R = maybeLexRegister(C, Token)) in lexMIToken()
591 if (Cursor R = maybeLexGlobalValue(C, Token, ErrorCallback)) in lexMIToken()
593 if (Cursor R = maybeLexExternalSymbol(C, Token, ErrorCallback)) in lexMIToken()
595 if (Cursor R = maybeLexHexFloatingPointLiteral(C, Token)) in lexMIToken()
597 if (Cursor R = maybeLexNumericalLiteral(C, Token)) in lexMIToken()
599 if (Cursor R = maybeLexExlaim(C, Token, ErrorCallback)) in lexMIToken()
601 if (Cursor R = maybeLexSymbol(C, Token)) in lexMIToken()
603 if (Cursor R = maybeLexNewline(C, Token)) in lexMIToken()
605 if (Cursor R = maybeLexEscapedIRValue(C, Token, ErrorCallback)) in lexMIToken()
608 Token.reset(MIToken::Error, C.remaining()); in lexMIToken()
609 ErrorCallback(C.location(), in lexMIToken()
610 Twine("unexpected character '") + Twine(C.peek()) + "'"); in lexMIToken()
611 return C.remaining(); in lexMIToken()