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