LLVM 22.0.0git
LLLexer.cpp
Go to the documentation of this file.
1//===- LLLexer.cpp - Lexer for .ll Files ----------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// Implement the Lexer for .ll files.
10//
11//===----------------------------------------------------------------------===//
12
14#include "llvm/ADT/APInt.h"
15#include "llvm/ADT/STLExtras.h"
17#include "llvm/ADT/Twine.h"
19#include "llvm/IR/Instruction.h"
22#include <cassert>
23#include <cctype>
24#include <cstdio>
25
26using namespace llvm;
27
28// Both the lexer and parser can issue error messages. If the lexer issues a
29// lexer error, since we do not terminate execution immediately, usually that
30// is followed by the parser issuing a parser error. However, the error issued
31// by the lexer is more relevant in that case as opposed to potentially more
32// generic parser error. So instead of always recording the last error message
33// use the `Priority` to establish a priority, with Lexer > Parser > None. We
34// record the issued message only if the message has same or higher priority
35// than the existing one. This prevents lexer errors from being overwritten by
36// parser errors.
37void LLLexer::Error(LocTy ErrorLoc, const Twine &Msg,
38 LLLexer::ErrorPriority Priority) {
39 if (Priority < ErrorInfo.Priority)
40 return;
41 ErrorInfo.Error = SM.GetMessage(ErrorLoc, SourceMgr::DK_Error, Msg);
42 ErrorInfo.Priority = Priority;
43}
44
45void LLLexer::Warning(LocTy WarningLoc, const Twine &Msg) const {
46 SM.PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg);
47}
48
49//===----------------------------------------------------------------------===//
50// Helper functions.
51//===----------------------------------------------------------------------===//
52
53// atoull - Convert an ascii string of decimal digits into the unsigned long
54// long representation... this does not have to do input error checking,
55// because we know that the input will be matched by a suitable regex...
56//
57uint64_t LLLexer::atoull(const char *Buffer, const char *End) {
58 uint64_t Result = 0;
59 for (; Buffer != End; Buffer++) {
60 uint64_t OldRes = Result;
61 Result *= 10;
62 Result += *Buffer-'0';
63 if (Result < OldRes) { // overflow detected.
64 LexError("constant bigger than 64 bits detected");
65 return 0;
66 }
67 }
68 return Result;
69}
70
71uint64_t LLLexer::HexIntToVal(const char *Buffer, const char *End) {
72 uint64_t Result = 0;
73 for (; Buffer != End; ++Buffer) {
74 uint64_t OldRes = Result;
75 Result *= 16;
76 Result += hexDigitValue(*Buffer);
77
78 if (Result < OldRes) { // overflow detected.
79 LexError("constant bigger than 64 bits detected");
80 return 0;
81 }
82 }
83 return Result;
84}
85
86void LLLexer::HexToIntPair(const char *Buffer, const char *End,
87 uint64_t Pair[2]) {
88 Pair[0] = 0;
89 if (End - Buffer >= 16) {
90 for (int i = 0; i < 16; i++, Buffer++) {
91 assert(Buffer != End);
92 Pair[0] *= 16;
93 Pair[0] += hexDigitValue(*Buffer);
94 }
95 }
96 Pair[1] = 0;
97 for (int i = 0; i < 16 && Buffer != End; i++, Buffer++) {
98 Pair[1] *= 16;
99 Pair[1] += hexDigitValue(*Buffer);
100 }
101 if (Buffer != End)
102 LexError("constant bigger than 128 bits detected");
103}
104
105/// FP80HexToIntPair - translate an 80 bit FP80 number (20 hexits) into
106/// { low64, high16 } as usual for an APInt.
107void LLLexer::FP80HexToIntPair(const char *Buffer, const char *End,
108 uint64_t Pair[2]) {
109 Pair[1] = 0;
110 for (int i=0; i<4 && Buffer != End; i++, Buffer++) {
111 assert(Buffer != End);
112 Pair[1] *= 16;
113 Pair[1] += hexDigitValue(*Buffer);
114 }
115 Pair[0] = 0;
116 for (int i = 0; i < 16 && Buffer != End; i++, Buffer++) {
117 Pair[0] *= 16;
118 Pair[0] += hexDigitValue(*Buffer);
119 }
120 if (Buffer != End)
121 LexError("constant bigger than 128 bits detected");
122}
123
124// UnEscapeLexed - Run through the specified buffer and change \xx codes to the
125// appropriate character.
126static void UnEscapeLexed(std::string &Str) {
127 if (Str.empty()) return;
128
129 char *Buffer = &Str[0], *EndBuffer = Buffer+Str.size();
130 char *BOut = Buffer;
131 for (char *BIn = Buffer; BIn != EndBuffer; ) {
132 if (BIn[0] == '\\') {
133 if (BIn < EndBuffer-1 && BIn[1] == '\\') {
134 *BOut++ = '\\'; // Two \ becomes one
135 BIn += 2;
136 } else if (BIn < EndBuffer-2 &&
137 isxdigit(static_cast<unsigned char>(BIn[1])) &&
138 isxdigit(static_cast<unsigned char>(BIn[2]))) {
139 *BOut = hexDigitValue(BIn[1]) * 16 + hexDigitValue(BIn[2]);
140 BIn += 3; // Skip over handled chars
141 ++BOut;
142 } else {
143 *BOut++ = *BIn++;
144 }
145 } else {
146 *BOut++ = *BIn++;
147 }
148 }
149 Str.resize(BOut-Buffer);
150}
151
152/// isLabelChar - Return true for [-a-zA-Z$._0-9].
153static bool isLabelChar(char C) {
154 return isalnum(static_cast<unsigned char>(C)) || C == '-' || C == '$' ||
155 C == '.' || C == '_';
156}
157
158/// isLabelTail - Return true if this pointer points to a valid end of a label.
159static const char *isLabelTail(const char *CurPtr) {
160 while (true) {
161 if (CurPtr[0] == ':') return CurPtr+1;
162 if (!isLabelChar(CurPtr[0])) return nullptr;
163 ++CurPtr;
164 }
165}
166
167//===----------------------------------------------------------------------===//
168// Lexer definition.
169//===----------------------------------------------------------------------===//
170
172 LLVMContext &C)
173 : CurBuf(StartBuf), ErrorInfo(Err), SM(SM), Context(C) {
174 CurPtr = CurBuf.begin();
175}
176
177int LLLexer::getNextChar() {
178 char CurChar = *CurPtr++;
179 switch (CurChar) {
180 default: return (unsigned char)CurChar;
181 case 0:
182 // A nul character in the stream is either the end of the current buffer or
183 // a random nul in the file. Disambiguate that here.
184 if (CurPtr-1 != CurBuf.end())
185 return 0; // Just whitespace.
186
187 // Otherwise, return end of file.
188 --CurPtr; // Another call to lex will return EOF again.
189 return EOF;
190 }
191}
192
193lltok::Kind LLLexer::LexToken() {
194 // Set token end to next location, since the end is exclusive.
195 PrevTokEnd = CurPtr;
196 while (true) {
197 TokStart = CurPtr;
198
199 int CurChar = getNextChar();
200 switch (CurChar) {
201 default:
202 // Handle letters: [a-zA-Z_]
203 if (isalpha(static_cast<unsigned char>(CurChar)) || CurChar == '_')
204 return LexIdentifier();
205 return lltok::Error;
206 case EOF: return lltok::Eof;
207 case 0:
208 case ' ':
209 case '\t':
210 case '\n':
211 case '\r':
212 // Ignore whitespace.
213 continue;
214 case '+': return LexPositive();
215 case '@': return LexAt();
216 case '$': return LexDollar();
217 case '%': return LexPercent();
218 case '"': return LexQuote();
219 case '.':
220 if (const char *Ptr = isLabelTail(CurPtr)) {
221 CurPtr = Ptr;
222 StrVal.assign(TokStart, CurPtr-1);
223 return lltok::LabelStr;
224 }
225 if (CurPtr[0] == '.' && CurPtr[1] == '.') {
226 CurPtr += 2;
227 return lltok::dotdotdot;
228 }
229 return lltok::Error;
230 case ';':
231 SkipLineComment();
232 continue;
233 case '!': return LexExclaim();
234 case '^':
235 return LexCaret();
236 case ':':
237 return lltok::colon;
238 case '#': return LexHash();
239 case '0': case '1': case '2': case '3': case '4':
240 case '5': case '6': case '7': case '8': case '9':
241 case '-':
242 return LexDigitOrNegative();
243 case '=': return lltok::equal;
244 case '[': return lltok::lsquare;
245 case ']': return lltok::rsquare;
246 case '{': return lltok::lbrace;
247 case '}': return lltok::rbrace;
248 case '<': return lltok::less;
249 case '>': return lltok::greater;
250 case '(': return lltok::lparen;
251 case ')': return lltok::rparen;
252 case ',': return lltok::comma;
253 case '*': return lltok::star;
254 case '|': return lltok::bar;
255 case '/':
256 if (getNextChar() != '*')
257 return lltok::Error;
258 if (SkipCComment())
259 return lltok::Error;
260 continue;
261 }
262 }
263}
264
265void LLLexer::SkipLineComment() {
266 while (true) {
267 if (CurPtr[0] == '\n' || CurPtr[0] == '\r' || getNextChar() == EOF)
268 return;
269 }
270}
271
272/// This skips C-style /**/ comments. Returns true if there
273/// was an error.
274bool LLLexer::SkipCComment() {
275 while (true) {
276 int CurChar = getNextChar();
277 switch (CurChar) {
278 case EOF:
279 LexError("unterminated comment");
280 return true;
281 case '*':
282 // End of the comment?
283 CurChar = getNextChar();
284 if (CurChar == '/')
285 return false;
286 if (CurChar == EOF) {
287 LexError("unterminated comment");
288 return true;
289 }
290 }
291 }
292}
293
294/// Lex all tokens that start with an @ character.
295/// GlobalVar @\"[^\"]*\"
296/// GlobalVar @[-a-zA-Z$._][-a-zA-Z$._0-9]*
297/// GlobalVarID @[0-9]+
298lltok::Kind LLLexer::LexAt() {
299 return LexVar(lltok::GlobalVar, lltok::GlobalID);
300}
301
302lltok::Kind LLLexer::LexDollar() {
303 if (const char *Ptr = isLabelTail(TokStart)) {
304 CurPtr = Ptr;
305 StrVal.assign(TokStart, CurPtr - 1);
306 return lltok::LabelStr;
307 }
308
309 // Handle DollarStringConstant: $\"[^\"]*\"
310 if (CurPtr[0] == '"') {
311 ++CurPtr;
312
313 while (true) {
314 int CurChar = getNextChar();
315
316 if (CurChar == EOF) {
317 LexError("end of file in COMDAT variable name");
318 return lltok::Error;
319 }
320 if (CurChar == '"') {
321 StrVal.assign(TokStart + 2, CurPtr - 1);
322 UnEscapeLexed(StrVal);
323 if (StringRef(StrVal).contains(0)) {
324 LexError("NUL character is not allowed in names");
325 return lltok::Error;
326 }
327 return lltok::ComdatVar;
328 }
329 }
330 }
331
332 // Handle ComdatVarName: $[-a-zA-Z$._][-a-zA-Z$._0-9]*
333 if (ReadVarName())
334 return lltok::ComdatVar;
335
336 return lltok::Error;
337}
338
339/// ReadString - Read a string until the closing quote.
340lltok::Kind LLLexer::ReadString(lltok::Kind kind) {
341 const char *Start = CurPtr;
342 while (true) {
343 int CurChar = getNextChar();
344
345 if (CurChar == EOF) {
346 LexError("end of file in string constant");
347 return lltok::Error;
348 }
349 if (CurChar == '"') {
350 StrVal.assign(Start, CurPtr-1);
351 UnEscapeLexed(StrVal);
352 return kind;
353 }
354 }
355}
356
357/// ReadVarName - Read the rest of a token containing a variable name.
358bool LLLexer::ReadVarName() {
359 const char *NameStart = CurPtr;
360 if (isalpha(static_cast<unsigned char>(CurPtr[0])) ||
361 CurPtr[0] == '-' || CurPtr[0] == '$' ||
362 CurPtr[0] == '.' || CurPtr[0] == '_') {
363 ++CurPtr;
364 while (isalnum(static_cast<unsigned char>(CurPtr[0])) ||
365 CurPtr[0] == '-' || CurPtr[0] == '$' ||
366 CurPtr[0] == '.' || CurPtr[0] == '_')
367 ++CurPtr;
368
369 StrVal.assign(NameStart, CurPtr);
370 return true;
371 }
372 return false;
373}
374
375// Lex an ID: [0-9]+. On success, the ID is stored in UIntVal and Token is
376// returned, otherwise the Error token is returned.
377lltok::Kind LLLexer::LexUIntID(lltok::Kind Token) {
378 if (!isdigit(static_cast<unsigned char>(CurPtr[0])))
379 return lltok::Error;
380
381 for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
382 /*empty*/;
383
384 uint64_t Val = atoull(TokStart + 1, CurPtr);
385 if ((unsigned)Val != Val)
386 LexError("invalid value number (too large)");
387 UIntVal = unsigned(Val);
388 return Token;
389}
390
391lltok::Kind LLLexer::LexVar(lltok::Kind Var, lltok::Kind VarID) {
392 // Handle StringConstant: \"[^\"]*\"
393 if (CurPtr[0] == '"') {
394 ++CurPtr;
395
396 while (true) {
397 int CurChar = getNextChar();
398
399 if (CurChar == EOF) {
400 LexError("end of file in global variable name");
401 return lltok::Error;
402 }
403 if (CurChar == '"') {
404 StrVal.assign(TokStart+2, CurPtr-1);
405 UnEscapeLexed(StrVal);
406 if (StringRef(StrVal).contains(0)) {
407 LexError("NUL character is not allowed in names");
408 return lltok::Error;
409 }
410 return Var;
411 }
412 }
413 }
414
415 // Handle VarName: [-a-zA-Z$._][-a-zA-Z$._0-9]*
416 if (ReadVarName())
417 return Var;
418
419 // Handle VarID: [0-9]+
420 return LexUIntID(VarID);
421}
422
423/// Lex all tokens that start with a % character.
424/// LocalVar ::= %\"[^\"]*\"
425/// LocalVar ::= %[-a-zA-Z$._][-a-zA-Z$._0-9]*
426/// LocalVarID ::= %[0-9]+
427lltok::Kind LLLexer::LexPercent() {
428 return LexVar(lltok::LocalVar, lltok::LocalVarID);
429}
430
431/// Lex all tokens that start with a " character.
432/// QuoteLabel "[^"]+":
433/// StringConstant "[^"]*"
434lltok::Kind LLLexer::LexQuote() {
435 lltok::Kind kind = ReadString(lltok::StringConstant);
436 if (kind == lltok::Error || kind == lltok::Eof)
437 return kind;
438
439 if (CurPtr[0] == ':') {
440 ++CurPtr;
441 if (StringRef(StrVal).contains(0)) {
442 LexError("NUL character is not allowed in names");
443 kind = lltok::Error;
444 } else {
445 kind = lltok::LabelStr;
446 }
447 }
448
449 return kind;
450}
451
452/// Lex all tokens that start with a ! character.
453/// !foo
454/// !
455lltok::Kind LLLexer::LexExclaim() {
456 // Lex a metadata name as a MetadataVar.
457 if (isalpha(static_cast<unsigned char>(CurPtr[0])) ||
458 CurPtr[0] == '-' || CurPtr[0] == '$' ||
459 CurPtr[0] == '.' || CurPtr[0] == '_' || CurPtr[0] == '\\') {
460 ++CurPtr;
461 while (isalnum(static_cast<unsigned char>(CurPtr[0])) ||
462 CurPtr[0] == '-' || CurPtr[0] == '$' ||
463 CurPtr[0] == '.' || CurPtr[0] == '_' || CurPtr[0] == '\\')
464 ++CurPtr;
465
466 StrVal.assign(TokStart+1, CurPtr); // Skip !
467 UnEscapeLexed(StrVal);
468 return lltok::MetadataVar;
469 }
470 return lltok::exclaim;
471}
472
473/// Lex all tokens that start with a ^ character.
474/// SummaryID ::= ^[0-9]+
475lltok::Kind LLLexer::LexCaret() {
476 // Handle SummaryID: ^[0-9]+
477 return LexUIntID(lltok::SummaryID);
478}
479
480/// Lex all tokens that start with a # character.
481/// AttrGrpID ::= #[0-9]+
482/// Hash ::= #
483lltok::Kind LLLexer::LexHash() {
484 // Handle AttrGrpID: #[0-9]+
485 if (isdigit(static_cast<unsigned char>(CurPtr[0])))
486 return LexUIntID(lltok::AttrGrpID);
487 return lltok::hash;
488}
489
490/// Lex a label, integer type, keyword, or hexadecimal integer constant.
491/// Label [-a-zA-Z$._0-9]+:
492/// IntegerType i[0-9]+
493/// Keyword sdiv, float, ...
494/// HexIntConstant [us]0x[0-9A-Fa-f]+
495lltok::Kind LLLexer::LexIdentifier() {
496 const char *StartChar = CurPtr;
497 const char *IntEnd = CurPtr[-1] == 'i' ? nullptr : StartChar;
498 const char *KeywordEnd = nullptr;
499
500 for (; isLabelChar(*CurPtr); ++CurPtr) {
501 // If we decide this is an integer, remember the end of the sequence.
502 if (!IntEnd && !isdigit(static_cast<unsigned char>(*CurPtr)))
503 IntEnd = CurPtr;
504 if (!KeywordEnd && !isalnum(static_cast<unsigned char>(*CurPtr)) &&
505 *CurPtr != '_')
506 KeywordEnd = CurPtr;
507 }
508
509 // If we stopped due to a colon, unless we were directed to ignore it,
510 // this really is a label.
511 if (!IgnoreColonInIdentifiers && *CurPtr == ':') {
512 StrVal.assign(StartChar-1, CurPtr++);
513 return lltok::LabelStr;
514 }
515
516 // Otherwise, this wasn't a label. If this was valid as an integer type,
517 // return it.
518 if (!IntEnd) IntEnd = CurPtr;
519 if (IntEnd != StartChar) {
520 CurPtr = IntEnd;
521 uint64_t NumBits = atoull(StartChar, CurPtr);
522 if (NumBits < IntegerType::MIN_INT_BITS ||
523 NumBits > IntegerType::MAX_INT_BITS) {
524 LexError("bitwidth for integer type out of range");
525 return lltok::Error;
526 }
527 TyVal = IntegerType::get(Context, NumBits);
528 return lltok::Type;
529 }
530
531 // Otherwise, this was a letter sequence. See which keyword this is.
532 if (!KeywordEnd) KeywordEnd = CurPtr;
533 CurPtr = KeywordEnd;
534 --StartChar;
535 StringRef Keyword(StartChar, CurPtr - StartChar);
536
537#define KEYWORD(STR) \
538 do { \
539 if (Keyword == #STR) \
540 return lltok::kw_##STR; \
541 } while (false)
542
543 KEYWORD(true); KEYWORD(false);
544 KEYWORD(declare); KEYWORD(define);
545 KEYWORD(global); KEYWORD(constant);
546
547 KEYWORD(dso_local);
548 KEYWORD(dso_preemptable);
549
550 KEYWORD(private);
551 KEYWORD(internal);
552 KEYWORD(available_externally);
553 KEYWORD(linkonce);
554 KEYWORD(linkonce_odr);
555 KEYWORD(weak); // Use as a linkage, and a modifier for "cmpxchg".
556 KEYWORD(weak_odr);
557 KEYWORD(appending);
558 KEYWORD(dllimport);
559 KEYWORD(dllexport);
560 KEYWORD(common);
561 KEYWORD(default);
562 KEYWORD(hidden);
563 KEYWORD(protected);
564 KEYWORD(unnamed_addr);
565 KEYWORD(local_unnamed_addr);
566 KEYWORD(externally_initialized);
567 KEYWORD(extern_weak);
568 KEYWORD(external);
569 KEYWORD(thread_local);
570 KEYWORD(localdynamic);
571 KEYWORD(initialexec);
572 KEYWORD(localexec);
573 KEYWORD(zeroinitializer);
574 KEYWORD(undef);
575 KEYWORD(null);
576 KEYWORD(none);
577 KEYWORD(poison);
578 KEYWORD(to);
579 KEYWORD(caller);
580 KEYWORD(within);
581 KEYWORD(from);
582 KEYWORD(tail);
583 KEYWORD(musttail);
584 KEYWORD(notail);
585 KEYWORD(target);
586 KEYWORD(triple);
587 KEYWORD(source_filename);
588 KEYWORD(unwind);
589 KEYWORD(datalayout);
590 KEYWORD(volatile);
591 KEYWORD(atomic);
592 KEYWORD(unordered);
593 KEYWORD(monotonic);
598 KEYWORD(syncscope);
599
600 KEYWORD(nnan);
601 KEYWORD(ninf);
602 KEYWORD(nsz);
603 KEYWORD(arcp);
605 KEYWORD(reassoc);
606 KEYWORD(afn);
607 KEYWORD(fast);
608 KEYWORD(nuw);
609 KEYWORD(nsw);
610 KEYWORD(nusw);
611 KEYWORD(exact);
612 KEYWORD(disjoint);
613 KEYWORD(inbounds);
614 KEYWORD(nneg);
615 KEYWORD(samesign);
616 KEYWORD(inrange);
617 KEYWORD(addrspace);
618 KEYWORD(section);
620 KEYWORD(code_model);
621 KEYWORD(alias);
622 KEYWORD(ifunc);
623 KEYWORD(module);
624 KEYWORD(asm);
625 KEYWORD(sideeffect);
626 KEYWORD(inteldialect);
627 KEYWORD(gc);
628 KEYWORD(prefix);
629 KEYWORD(prologue);
630
631 KEYWORD(no_sanitize_address);
632 KEYWORD(no_sanitize_hwaddress);
633 KEYWORD(sanitize_address_dyninit);
634
635 KEYWORD(ccc);
636 KEYWORD(fastcc);
637 KEYWORD(coldcc);
638 KEYWORD(cfguard_checkcc);
639 KEYWORD(x86_stdcallcc);
640 KEYWORD(x86_fastcallcc);
641 KEYWORD(x86_thiscallcc);
642 KEYWORD(x86_vectorcallcc);
643 KEYWORD(arm_apcscc);
644 KEYWORD(arm_aapcscc);
645 KEYWORD(arm_aapcs_vfpcc);
646 KEYWORD(aarch64_vector_pcs);
647 KEYWORD(aarch64_sve_vector_pcs);
648 KEYWORD(aarch64_sme_preservemost_from_x0);
649 KEYWORD(aarch64_sme_preservemost_from_x1);
650 KEYWORD(aarch64_sme_preservemost_from_x2);
651 KEYWORD(msp430_intrcc);
652 KEYWORD(avr_intrcc);
653 KEYWORD(avr_signalcc);
654 KEYWORD(ptx_kernel);
655 KEYWORD(ptx_device);
656 KEYWORD(spir_kernel);
657 KEYWORD(spir_func);
658 KEYWORD(intel_ocl_bicc);
659 KEYWORD(x86_64_sysvcc);
660 KEYWORD(win64cc);
661 KEYWORD(x86_regcallcc);
662 KEYWORD(swiftcc);
663 KEYWORD(swifttailcc);
664 KEYWORD(anyregcc);
665 KEYWORD(preserve_mostcc);
666 KEYWORD(preserve_allcc);
667 KEYWORD(preserve_nonecc);
668 KEYWORD(ghccc);
669 KEYWORD(x86_intrcc);
670 KEYWORD(hhvmcc);
671 KEYWORD(hhvm_ccc);
672 KEYWORD(cxx_fast_tlscc);
673 KEYWORD(amdgpu_vs);
674 KEYWORD(amdgpu_ls);
675 KEYWORD(amdgpu_hs);
676 KEYWORD(amdgpu_es);
677 KEYWORD(amdgpu_gs);
678 KEYWORD(amdgpu_ps);
679 KEYWORD(amdgpu_cs);
680 KEYWORD(amdgpu_cs_chain);
681 KEYWORD(amdgpu_cs_chain_preserve);
682 KEYWORD(amdgpu_kernel);
683 KEYWORD(amdgpu_gfx);
684 KEYWORD(amdgpu_gfx_whole_wave);
685 KEYWORD(tailcc);
686 KEYWORD(m68k_rtdcc);
687 KEYWORD(graalcc);
688 KEYWORD(riscv_vector_cc);
689 KEYWORD(riscv_vls_cc);
690 KEYWORD(cheriot_compartmentcallcc);
691 KEYWORD(cheriot_compartmentcalleecc);
692 KEYWORD(cheriot_librarycallcc);
693
694 KEYWORD(cc);
695 KEYWORD(c);
696
697 KEYWORD(attributes);
698 KEYWORD(sync);
699 KEYWORD(async);
700
701#define GET_ATTR_NAMES
702#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
703 KEYWORD(DISPLAY_NAME);
704#include "llvm/IR/Attributes.inc"
705
706 KEYWORD(read);
707 KEYWORD(write);
708 KEYWORD(readwrite);
709 KEYWORD(argmem);
710 KEYWORD(inaccessiblemem);
711 KEYWORD(errnomem);
712 KEYWORD(argmemonly);
713 KEYWORD(inaccessiblememonly);
714 KEYWORD(inaccessiblemem_or_argmemonly);
715 KEYWORD(nocapture);
716 KEYWORD(address_is_null);
717 KEYWORD(address);
718 KEYWORD(provenance);
719 KEYWORD(read_provenance);
720
721 // nofpclass attribute
722 KEYWORD(all);
723 KEYWORD(nan);
724 KEYWORD(snan);
725 KEYWORD(qnan);
726 KEYWORD(inf);
727 // ninf already a keyword
728 KEYWORD(pinf);
729 KEYWORD(norm);
730 KEYWORD(nnorm);
731 KEYWORD(pnorm);
732 // sub already a keyword
733 KEYWORD(nsub);
734 KEYWORD(psub);
735 KEYWORD(zero);
736 KEYWORD(nzero);
737 KEYWORD(pzero);
738
739 KEYWORD(type);
740 KEYWORD(opaque);
741
742 KEYWORD(comdat);
743
744 // Comdat types
745 KEYWORD(any);
746 KEYWORD(exactmatch);
747 KEYWORD(largest);
748 KEYWORD(nodeduplicate);
749 KEYWORD(samesize);
750
751 KEYWORD(eq); KEYWORD(ne); KEYWORD(slt); KEYWORD(sgt); KEYWORD(sle);
752 KEYWORD(sge); KEYWORD(ult); KEYWORD(ugt); KEYWORD(ule); KEYWORD(uge);
753 KEYWORD(oeq); KEYWORD(one); KEYWORD(olt); KEYWORD(ogt); KEYWORD(ole);
754 KEYWORD(oge); KEYWORD(ord); KEYWORD(uno); KEYWORD(ueq); KEYWORD(une);
755
756 KEYWORD(xchg); KEYWORD(nand); KEYWORD(max); KEYWORD(min); KEYWORD(umax);
757 KEYWORD(umin); KEYWORD(fmax); KEYWORD(fmin);
758 KEYWORD(fmaximum);
759 KEYWORD(fminimum);
760 KEYWORD(uinc_wrap);
761 KEYWORD(udec_wrap);
762 KEYWORD(usub_cond);
763 KEYWORD(usub_sat);
764
765 KEYWORD(splat);
766 KEYWORD(vscale);
767 KEYWORD(x);
768 KEYWORD(blockaddress);
769 KEYWORD(dso_local_equivalent);
770 KEYWORD(no_cfi);
771 KEYWORD(ptrauth);
772
773 // Metadata types.
774 KEYWORD(distinct);
775
776 // Use-list order directives.
777 KEYWORD(uselistorder);
778 KEYWORD(uselistorder_bb);
779
780 KEYWORD(personality);
782 KEYWORD(catch);
783 KEYWORD(filter);
784
785 // Summary index keywords.
786 KEYWORD(path);
787 KEYWORD(hash);
788 KEYWORD(gv);
789 KEYWORD(guid);
790 KEYWORD(name);
791 KEYWORD(summaries);
792 KEYWORD(flags);
793 KEYWORD(blockcount);
794 KEYWORD(linkage);
795 KEYWORD(visibility);
796 KEYWORD(notEligibleToImport);
797 KEYWORD(live);
798 KEYWORD(dsoLocal);
799 KEYWORD(canAutoHide);
800 KEYWORD(importType);
801 KEYWORD(definition);
802 KEYWORD(declaration);
804 KEYWORD(insts);
805 KEYWORD(funcFlags);
806 KEYWORD(readNone);
807 KEYWORD(readOnly);
808 KEYWORD(noRecurse);
809 KEYWORD(returnDoesNotAlias);
810 KEYWORD(noInline);
811 KEYWORD(alwaysInline);
812 KEYWORD(noUnwind);
813 KEYWORD(mayThrow);
814 KEYWORD(hasUnknownCall);
815 KEYWORD(mustBeUnreachable);
816 KEYWORD(calls);
817 KEYWORD(callee);
818 KEYWORD(params);
819 KEYWORD(param);
820 KEYWORD(hotness);
821 KEYWORD(unknown);
822 KEYWORD(critical);
823 KEYWORD(relbf);
824 KEYWORD(variable);
825 KEYWORD(vTableFuncs);
826 KEYWORD(virtFunc);
827 KEYWORD(aliasee);
828 KEYWORD(refs);
829 KEYWORD(typeIdInfo);
830 KEYWORD(typeTests);
831 KEYWORD(typeTestAssumeVCalls);
832 KEYWORD(typeCheckedLoadVCalls);
833 KEYWORD(typeTestAssumeConstVCalls);
834 KEYWORD(typeCheckedLoadConstVCalls);
835 KEYWORD(vFuncId);
836 KEYWORD(offset);
837 KEYWORD(args);
838 KEYWORD(typeid);
839 KEYWORD(typeidCompatibleVTable);
840 KEYWORD(summary);
841 KEYWORD(typeTestRes);
842 KEYWORD(kind);
843 KEYWORD(unsat);
844 KEYWORD(byteArray);
845 KEYWORD(inline);
846 KEYWORD(single);
848 KEYWORD(sizeM1BitWidth);
849 KEYWORD(alignLog2);
850 KEYWORD(sizeM1);
851 KEYWORD(bitMask);
852 KEYWORD(inlineBits);
853 KEYWORD(vcall_visibility);
854 KEYWORD(wpdResolutions);
855 KEYWORD(wpdRes);
856 KEYWORD(indir);
857 KEYWORD(singleImpl);
858 KEYWORD(branchFunnel);
859 KEYWORD(singleImplName);
860 KEYWORD(resByArg);
861 KEYWORD(byArg);
862 KEYWORD(uniformRetVal);
863 KEYWORD(uniqueRetVal);
864 KEYWORD(virtualConstProp);
865 KEYWORD(info);
866 KEYWORD(byte);
867 KEYWORD(bit);
868 KEYWORD(varFlags);
869 KEYWORD(callsites);
870 KEYWORD(clones);
871 KEYWORD(stackIds);
872 KEYWORD(allocs);
873 KEYWORD(versions);
874 KEYWORD(memProf);
875 KEYWORD(notcold);
876
877#undef KEYWORD
878
879 // Keywords for types.
880#define TYPEKEYWORD(STR, LLVMTY) \
881 do { \
882 if (Keyword == STR) { \
883 TyVal = LLVMTY; \
884 return lltok::Type; \
885 } \
886 } while (false)
887
888 TYPEKEYWORD("void", Type::getVoidTy(Context));
889 TYPEKEYWORD("half", Type::getHalfTy(Context));
890 TYPEKEYWORD("bfloat", Type::getBFloatTy(Context));
891 TYPEKEYWORD("float", Type::getFloatTy(Context));
892 TYPEKEYWORD("double", Type::getDoubleTy(Context));
893 TYPEKEYWORD("x86_fp80", Type::getX86_FP80Ty(Context));
894 TYPEKEYWORD("fp128", Type::getFP128Ty(Context));
895 TYPEKEYWORD("ppc_fp128", Type::getPPC_FP128Ty(Context));
896 TYPEKEYWORD("label", Type::getLabelTy(Context));
897 TYPEKEYWORD("metadata", Type::getMetadataTy(Context));
898 TYPEKEYWORD("x86_amx", Type::getX86_AMXTy(Context));
899 TYPEKEYWORD("token", Type::getTokenTy(Context));
900 TYPEKEYWORD("ptr", PointerType::getUnqual(Context));
901
902#undef TYPEKEYWORD
903
904 // Keywords for instructions.
905#define INSTKEYWORD(STR, Enum) \
906 do { \
907 if (Keyword == #STR) { \
908 UIntVal = Instruction::Enum; \
909 return lltok::kw_##STR; \
910 } \
911 } while (false)
912
913 INSTKEYWORD(fneg, FNeg);
914
915 INSTKEYWORD(add, Add); INSTKEYWORD(fadd, FAdd);
916 INSTKEYWORD(sub, Sub); INSTKEYWORD(fsub, FSub);
917 INSTKEYWORD(mul, Mul); INSTKEYWORD(fmul, FMul);
918 INSTKEYWORD(udiv, UDiv); INSTKEYWORD(sdiv, SDiv); INSTKEYWORD(fdiv, FDiv);
919 INSTKEYWORD(urem, URem); INSTKEYWORD(srem, SRem); INSTKEYWORD(frem, FRem);
920 INSTKEYWORD(shl, Shl); INSTKEYWORD(lshr, LShr); INSTKEYWORD(ashr, AShr);
921 INSTKEYWORD(and, And); INSTKEYWORD(or, Or); INSTKEYWORD(xor, Xor);
922 INSTKEYWORD(icmp, ICmp); INSTKEYWORD(fcmp, FCmp);
923
924 INSTKEYWORD(phi, PHI);
925 INSTKEYWORD(call, Call);
926 INSTKEYWORD(trunc, Trunc);
927 INSTKEYWORD(zext, ZExt);
928 INSTKEYWORD(sext, SExt);
929 INSTKEYWORD(fptrunc, FPTrunc);
930 INSTKEYWORD(fpext, FPExt);
931 INSTKEYWORD(uitofp, UIToFP);
932 INSTKEYWORD(sitofp, SIToFP);
933 INSTKEYWORD(fptoui, FPToUI);
934 INSTKEYWORD(fptosi, FPToSI);
935 INSTKEYWORD(inttoptr, IntToPtr);
936 INSTKEYWORD(ptrtoaddr, PtrToAddr);
937 INSTKEYWORD(ptrtoint, PtrToInt);
938 INSTKEYWORD(bitcast, BitCast);
939 INSTKEYWORD(addrspacecast, AddrSpaceCast);
940 INSTKEYWORD(select, Select);
941 INSTKEYWORD(va_arg, VAArg);
942 INSTKEYWORD(ret, Ret);
943 INSTKEYWORD(br, Br);
944 INSTKEYWORD(switch, Switch);
945 INSTKEYWORD(indirectbr, IndirectBr);
946 INSTKEYWORD(invoke, Invoke);
947 INSTKEYWORD(resume, Resume);
948 INSTKEYWORD(unreachable, Unreachable);
949 INSTKEYWORD(callbr, CallBr);
950
951 INSTKEYWORD(alloca, Alloca);
952 INSTKEYWORD(load, Load);
953 INSTKEYWORD(store, Store);
954 INSTKEYWORD(cmpxchg, AtomicCmpXchg);
955 INSTKEYWORD(atomicrmw, AtomicRMW);
956 INSTKEYWORD(fence, Fence);
957 INSTKEYWORD(getelementptr, GetElementPtr);
958
959 INSTKEYWORD(extractelement, ExtractElement);
960 INSTKEYWORD(insertelement, InsertElement);
961 INSTKEYWORD(shufflevector, ShuffleVector);
962 INSTKEYWORD(extractvalue, ExtractValue);
963 INSTKEYWORD(insertvalue, InsertValue);
964 INSTKEYWORD(landingpad, LandingPad);
965 INSTKEYWORD(cleanupret, CleanupRet);
966 INSTKEYWORD(catchret, CatchRet);
967 INSTKEYWORD(catchswitch, CatchSwitch);
968 INSTKEYWORD(catchpad, CatchPad);
969 INSTKEYWORD(cleanuppad, CleanupPad);
970
971 INSTKEYWORD(freeze, Freeze);
972
973#undef INSTKEYWORD
974
975#define DWKEYWORD(TYPE, TOKEN) \
976 do { \
977 if (Keyword.starts_with("DW_" #TYPE "_")) { \
978 StrVal.assign(Keyword.begin(), Keyword.end()); \
979 return lltok::TOKEN; \
980 } \
981 } while (false)
982
983 DWKEYWORD(TAG, DwarfTag);
984 DWKEYWORD(ATE, DwarfAttEncoding);
985 DWKEYWORD(VIRTUALITY, DwarfVirtuality);
986 DWKEYWORD(LANG, DwarfLang);
987 DWKEYWORD(LNAME, DwarfSourceLangName);
988 DWKEYWORD(CC, DwarfCC);
989 DWKEYWORD(OP, DwarfOp);
990 DWKEYWORD(MACINFO, DwarfMacinfo);
991 DWKEYWORD(APPLE_ENUM_KIND, DwarfEnumKind);
992
993#undef DWKEYWORD
994
995// Keywords for debug record types.
996#define DBGRECORDTYPEKEYWORD(STR) \
997 do { \
998 if (Keyword == "dbg_" #STR) { \
999 StrVal = #STR; \
1000 return lltok::DbgRecordType; \
1001 } \
1002 } while (false)
1003
1004 DBGRECORDTYPEKEYWORD(value);
1005 DBGRECORDTYPEKEYWORD(declare);
1006 DBGRECORDTYPEKEYWORD(assign);
1007 DBGRECORDTYPEKEYWORD(label);
1008#undef DBGRECORDTYPEKEYWORD
1009
1010 if (Keyword.starts_with("DIFlag")) {
1011 StrVal.assign(Keyword.begin(), Keyword.end());
1012 return lltok::DIFlag;
1013 }
1014
1015 if (Keyword.starts_with("DISPFlag")) {
1016 StrVal.assign(Keyword.begin(), Keyword.end());
1017 return lltok::DISPFlag;
1018 }
1019
1020 if (Keyword.starts_with("CSK_")) {
1021 StrVal.assign(Keyword.begin(), Keyword.end());
1022 return lltok::ChecksumKind;
1023 }
1024
1025 if (Keyword == "NoDebug" || Keyword == "FullDebug" ||
1026 Keyword == "LineTablesOnly" || Keyword == "DebugDirectivesOnly") {
1027 StrVal.assign(Keyword.begin(), Keyword.end());
1028 return lltok::EmissionKind;
1029 }
1030
1031 if (Keyword == "GNU" || Keyword == "Apple" || Keyword == "None" ||
1032 Keyword == "Default") {
1033 StrVal.assign(Keyword.begin(), Keyword.end());
1034 return lltok::NameTableKind;
1035 }
1036
1037 if (Keyword == "Binary" || Keyword == "Decimal" || Keyword == "Rational") {
1038 StrVal.assign(Keyword.begin(), Keyword.end());
1039 return lltok::FixedPointKind;
1040 }
1041
1042 // Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by
1043 // the CFE to avoid forcing it to deal with 64-bit numbers.
1044 if ((TokStart[0] == 'u' || TokStart[0] == 's') &&
1045 TokStart[1] == '0' && TokStart[2] == 'x' &&
1046 isxdigit(static_cast<unsigned char>(TokStart[3]))) {
1047 int len = CurPtr-TokStart-3;
1048 uint32_t bits = len * 4;
1049 StringRef HexStr(TokStart + 3, len);
1050 if (!all_of(HexStr, isxdigit)) {
1051 // Bad token, return it as an error.
1052 CurPtr = TokStart+3;
1053 return lltok::Error;
1054 }
1055 APInt Tmp(bits, HexStr, 16);
1056 uint32_t activeBits = Tmp.getActiveBits();
1057 if (activeBits > 0 && activeBits < bits)
1058 Tmp = Tmp.trunc(activeBits);
1059 APSIntVal = APSInt(Tmp, TokStart[0] == 'u');
1060 return lltok::APSInt;
1061 }
1062
1063 // If this is "cc1234", return this as just "cc".
1064 if (TokStart[0] == 'c' && TokStart[1] == 'c') {
1065 CurPtr = TokStart+2;
1066 return lltok::kw_cc;
1067 }
1068
1069 // Finally, if this isn't known, return an error.
1070 CurPtr = TokStart+1;
1071 return lltok::Error;
1072}
1073
1074/// Lex all tokens that start with a 0x prefix, knowing they match and are not
1075/// labels.
1076/// HexFPConstant 0x[0-9A-Fa-f]+
1077/// HexFP80Constant 0xK[0-9A-Fa-f]+
1078/// HexFP128Constant 0xL[0-9A-Fa-f]+
1079/// HexPPC128Constant 0xM[0-9A-Fa-f]+
1080/// HexHalfConstant 0xH[0-9A-Fa-f]+
1081/// HexBFloatConstant 0xR[0-9A-Fa-f]+
1082lltok::Kind LLLexer::Lex0x() {
1083 CurPtr = TokStart + 2;
1084
1085 char Kind;
1086 if ((CurPtr[0] >= 'K' && CurPtr[0] <= 'M') || CurPtr[0] == 'H' ||
1087 CurPtr[0] == 'R') {
1088 Kind = *CurPtr++;
1089 } else {
1090 Kind = 'J';
1091 }
1092
1093 if (!isxdigit(static_cast<unsigned char>(CurPtr[0]))) {
1094 // Bad token, return it as an error.
1095 CurPtr = TokStart+1;
1096 return lltok::Error;
1097 }
1098
1099 while (isxdigit(static_cast<unsigned char>(CurPtr[0])))
1100 ++CurPtr;
1101
1102 if (Kind == 'J') {
1103 // HexFPConstant - Floating point constant represented in IEEE format as a
1104 // hexadecimal number for when exponential notation is not precise enough.
1105 // Half, BFloat, Float, and double only.
1106 APFloatVal = APFloat(APFloat::IEEEdouble(),
1107 APInt(64, HexIntToVal(TokStart + 2, CurPtr)));
1108 return lltok::APFloat;
1109 }
1110
1111 uint64_t Pair[2];
1112 switch (Kind) {
1113 default: llvm_unreachable("Unknown kind!");
1114 case 'K':
1115 // F80HexFPConstant - x87 long double in hexadecimal format (10 bytes)
1116 FP80HexToIntPair(TokStart+3, CurPtr, Pair);
1117 APFloatVal = APFloat(APFloat::x87DoubleExtended(), APInt(80, Pair));
1118 return lltok::APFloat;
1119 case 'L':
1120 // F128HexFPConstant - IEEE 128-bit in hexadecimal format (16 bytes)
1121 HexToIntPair(TokStart+3, CurPtr, Pair);
1122 APFloatVal = APFloat(APFloat::IEEEquad(), APInt(128, Pair));
1123 return lltok::APFloat;
1124 case 'M':
1125 // PPC128HexFPConstant - PowerPC 128-bit in hexadecimal format (16 bytes)
1126 HexToIntPair(TokStart+3, CurPtr, Pair);
1127 APFloatVal = APFloat(APFloat::PPCDoubleDouble(), APInt(128, Pair));
1128 return lltok::APFloat;
1129 case 'H':
1130 APFloatVal = APFloat(APFloat::IEEEhalf(),
1131 APInt(16,HexIntToVal(TokStart+3, CurPtr)));
1132 return lltok::APFloat;
1133 case 'R':
1134 // Brain floating point
1135 APFloatVal = APFloat(APFloat::BFloat(),
1136 APInt(16, HexIntToVal(TokStart + 3, CurPtr)));
1137 return lltok::APFloat;
1138 }
1139}
1140
1141/// Lex tokens for a label or a numeric constant, possibly starting with -.
1142/// Label [-a-zA-Z$._0-9]+:
1143/// NInteger -[0-9]+
1144/// FPConstant [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
1145/// PInteger [0-9]+
1146/// HexFPConstant 0x[0-9A-Fa-f]+
1147/// HexFP80Constant 0xK[0-9A-Fa-f]+
1148/// HexFP128Constant 0xL[0-9A-Fa-f]+
1149/// HexPPC128Constant 0xM[0-9A-Fa-f]+
1150lltok::Kind LLLexer::LexDigitOrNegative() {
1151 // If the letter after the negative is not a number, this is probably a label.
1152 if (!isdigit(static_cast<unsigned char>(TokStart[0])) &&
1153 !isdigit(static_cast<unsigned char>(CurPtr[0]))) {
1154 // Okay, this is not a number after the -, it's probably a label.
1155 if (const char *End = isLabelTail(CurPtr)) {
1156 StrVal.assign(TokStart, End-1);
1157 CurPtr = End;
1158 return lltok::LabelStr;
1159 }
1160
1161 return lltok::Error;
1162 }
1163
1164 // At this point, it is either a label, int or fp constant.
1165
1166 // Skip digits, we have at least one.
1167 for (; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1168 /*empty*/;
1169
1170 // Check if this is a fully-numeric label:
1171 if (isdigit(TokStart[0]) && CurPtr[0] == ':') {
1172 uint64_t Val = atoull(TokStart, CurPtr);
1173 ++CurPtr; // Skip the colon.
1174 if ((unsigned)Val != Val)
1175 LexError("invalid value number (too large)");
1176 UIntVal = unsigned(Val);
1177 return lltok::LabelID;
1178 }
1179
1180 // Check to see if this really is a string label, e.g. "-1:".
1181 if (isLabelChar(CurPtr[0]) || CurPtr[0] == ':') {
1182 if (const char *End = isLabelTail(CurPtr)) {
1183 StrVal.assign(TokStart, End-1);
1184 CurPtr = End;
1185 return lltok::LabelStr;
1186 }
1187 }
1188
1189 // If the next character is a '.', then it is a fp value, otherwise its
1190 // integer.
1191 if (CurPtr[0] != '.') {
1192 if (TokStart[0] == '0' && TokStart[1] == 'x')
1193 return Lex0x();
1194 APSIntVal = APSInt(StringRef(TokStart, CurPtr - TokStart));
1195 return lltok::APSInt;
1196 }
1197
1198 ++CurPtr;
1199
1200 // Skip over [0-9]*([eE][-+]?[0-9]+)?
1201 while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1202
1203 if (CurPtr[0] == 'e' || CurPtr[0] == 'E') {
1204 if (isdigit(static_cast<unsigned char>(CurPtr[1])) ||
1205 ((CurPtr[1] == '-' || CurPtr[1] == '+') &&
1206 isdigit(static_cast<unsigned char>(CurPtr[2])))) {
1207 CurPtr += 2;
1208 while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1209 }
1210 }
1211
1212 APFloatVal = APFloat(APFloat::IEEEdouble(),
1213 StringRef(TokStart, CurPtr - TokStart));
1214 return lltok::APFloat;
1215}
1216
1217/// Lex a floating point constant starting with +.
1218/// FPConstant [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
1219lltok::Kind LLLexer::LexPositive() {
1220 // If the letter after the negative is a number, this is probably not a
1221 // label.
1222 if (!isdigit(static_cast<unsigned char>(CurPtr[0])))
1223 return lltok::Error;
1224
1225 // Skip digits.
1226 for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1227 /*empty*/;
1228
1229 // At this point, we need a '.'.
1230 if (CurPtr[0] != '.') {
1231 CurPtr = TokStart+1;
1232 return lltok::Error;
1233 }
1234
1235 ++CurPtr;
1236
1237 // Skip over [0-9]*([eE][-+]?[0-9]+)?
1238 while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1239
1240 if (CurPtr[0] == 'e' || CurPtr[0] == 'E') {
1241 if (isdigit(static_cast<unsigned char>(CurPtr[1])) ||
1242 ((CurPtr[1] == '-' || CurPtr[1] == '+') &&
1243 isdigit(static_cast<unsigned char>(CurPtr[2])))) {
1244 CurPtr += 2;
1245 while (isdigit(static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1246 }
1247 }
1248
1249 APFloatVal = APFloat(APFloat::IEEEdouble(),
1250 StringRef(TokStart, CurPtr - TokStart));
1251 return lltok::APFloat;
1252}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Mark last scratch load
AMDGPU Register Bank Select
Rewrite undef for PHI
This file implements a class to represent arbitrary precision integral constant values and operations...
static void cleanup(BlockFrequencyInfoImplBase &BFI)
Clear all memory not needed downstream.
Prepare callbr
static void zero(T &Obj)
static void UnEscapeLexed(std::string &Str)
Definition LLLexer.cpp:126
static const char * isLabelTail(const char *CurPtr)
isLabelTail - Return true if this pointer points to a valid end of a label.
Definition LLLexer.cpp:159
#define DBGRECORDTYPEKEYWORD(STR)
static bool isLabelChar(char C)
isLabelChar - Return true for [-a-zA-Z$._0-9].
Definition LLLexer.cpp:153
#define TYPEKEYWORD(STR, LLVMTY)
#define DWKEYWORD(TYPE, TOKEN)
#define INSTKEYWORD(STR, Enum)
#define KEYWORD(STR)
lazy value info
nvptx lower args
objc arc contract
static constexpr auto TAG
dot regions Print regions of function to dot true view regions View regions of function(with no function bodies)"
static const char * name
This file contains some templates that are useful if you are working with the STL at all.
#define OP(OPC)
Definition Instruction.h:46
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition Value.cpp:480
This file contains some functions that are useful when dealing with strings.
static uint64_t allOnes(unsigned int Count)
static const fltSemantics & BFloat()
Definition APFloat.h:295
static const fltSemantics & IEEEquad()
Definition APFloat.h:298
static const fltSemantics & IEEEdouble()
Definition APFloat.h:297
static const fltSemantics & x87DoubleExtended()
Definition APFloat.h:317
static const fltSemantics & IEEEhalf()
Definition APFloat.h:294
static const fltSemantics & PPCDoubleDouble()
Definition APFloat.h:299
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition Type.cpp:319
@ MIN_INT_BITS
Minimum number of bits that can be specified.
@ MAX_INT_BITS
Maximum number of bits that can be specified.
void Warning(LocTy WarningLoc, const Twine &Msg) const
Definition LLLexer.cpp:45
LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &, LLVMContext &C)
Definition LLLexer.cpp:171
SMLoc LocTy
Definition LLLexer.h:70
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition SourceMgr.h:297
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Definition SourceMgr.h:37
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
iterator end() const
Definition StringRef.h:114
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
static LLVM_ABI Type * getX86_AMXTy(LLVMContext &C)
Definition Type.cpp:292
static LLVM_ABI Type * getMetadataTy(LLVMContext &C)
Definition Type.cpp:287
static LLVM_ABI Type * getTokenTy(LLVMContext &C)
Definition Type.cpp:288
static LLVM_ABI Type * getPPC_FP128Ty(LLVMContext &C)
Definition Type.cpp:291
static LLVM_ABI Type * getFP128Ty(LLVMContext &C)
Definition Type.cpp:290
static LLVM_ABI Type * getLabelTy(LLVMContext &C)
Definition Type.cpp:282
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
Definition Type.cpp:281
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
Definition Type.cpp:286
static LLVM_ABI Type * getX86_FP80Ty(LLVMContext &C)
Definition Type.cpp:289
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
Definition Type.cpp:285
static LLVM_ABI Type * getBFloatTy(LLVMContext &C)
Definition Type.cpp:284
static LLVM_ABI Type * getHalfTy(LLVMContext &C)
Definition Type.cpp:283
CallInst * Call
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
@ StringConstant
Definition LLToken.h:496
@ NameTableKind
Definition LLToken.h:504
@ FixedPointKind
Definition LLToken.h:505
This is an optimization pass for GlobalISel generic memory operations.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
std::tuple< const DIScope *, const DIScope *, const DILocalVariable * > VarID
A unique key that represents a debug variable.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1725
unsigned hexDigitValue(char C)
Interpret the given character C as a hexadecimal digit and return its value.
LLVM_ABI FPClassTest fneg(FPClassTest Mask)
Return the test mask which returns true if the value's sign bit is flipped.
LLVM_ABI Error write(MCStreamer &Out, ArrayRef< std::string > Inputs, OnCuIndexOverflow OverflowOptValue)
Definition DWP.cpp:622
@ Or
Bitwise or logical OR of integers.
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
@ FMul
Product of floats.
@ And
Bitwise or logical AND of integers.
@ Sub
Subtraction of integers.
@ Add
Sum of integers.
@ FAdd
Sum of floats.
auto partition(R &&Range, UnaryPredicate P)
Provide wrappers to std::partition which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1975