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