37void LLLexer::Error(LocTy ErrorLoc,
const Twine &Msg,
38 LLLexer::ErrorPriority Priority) {
39 if (Priority < ErrorInfo.Priority)
42 ErrorInfo.Priority = Priority;
57uint64_t LLLexer::atoull(
const char *Buffer,
const char *End) {
59 for (; Buffer != End; Buffer++) {
62 Result += *Buffer-
'0';
63 if (Result < OldRes) {
64 LexError(
"constant bigger than 64 bits detected");
71uint64_t LLLexer::HexIntToVal(
const char *Buffer,
const char *End) {
73 for (; Buffer != End; ++Buffer) {
78 if (Result < OldRes) {
79 LexError(
"constant bigger than 64 bits detected");
86void LLLexer::HexToIntPair(
const char *Buffer,
const char *End,
89 if (End - Buffer >= 16) {
90 for (
int i = 0; i < 16; i++, Buffer++) {
97 for (
int i = 0; i < 16 && Buffer != End; i++, Buffer++) {
102 LexError(
"constant bigger than 128 bits detected");
107void LLLexer::FP80HexToIntPair(
const char *Buffer,
const char *End,
110 for (
int i=0; i<4 && Buffer != End; i++, Buffer++) {
116 for (
int i = 0; i < 16 && Buffer != End; i++, Buffer++) {
121 LexError(
"constant bigger than 128 bits detected");
127 if (Str.empty())
return;
129 char *Buffer = &Str[0], *EndBuffer = Buffer+Str.size();
131 for (
char *BIn = Buffer; BIn != EndBuffer; ) {
132 if (BIn[0] ==
'\\') {
133 if (BIn < EndBuffer-1 && BIn[1] ==
'\\') {
136 }
else if (BIn < EndBuffer-2 &&
137 isxdigit(
static_cast<unsigned char>(BIn[1])) &&
138 isxdigit(
static_cast<unsigned char>(BIn[2]))) {
149 Str.resize(BOut-Buffer);
154 return isalnum(
static_cast<unsigned char>(
C)) ||
C ==
'-' ||
C ==
'$' ||
155 C ==
'.' ||
C ==
'_';
161 if (CurPtr[0] ==
':')
return CurPtr+1;
173 : CurBuf(StartBuf), ErrorInfo(Err), SM(SM), Context(
C) {
174 CurPtr = CurBuf.begin();
177int LLLexer::getNextChar() {
178 char CurChar = *CurPtr++;
180 default:
return (
unsigned char)CurChar;
184 if (CurPtr-1 != CurBuf.
end())
197 int CurChar = getNextChar();
201 if (isalpha(
static_cast<unsigned char>(CurChar)) || CurChar ==
'_')
202 return LexIdentifier();
212 case '+':
return LexPositive();
213 case '@':
return LexAt();
214 case '$':
return LexDollar();
215 case '%':
return LexPercent();
216 case '"':
return LexQuote();
220 StrVal.assign(TokStart, CurPtr-1);
223 if (CurPtr[0] ==
'.' && CurPtr[1] ==
'.') {
231 case '!':
return LexExclaim();
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':
240 return LexDigitOrNegative();
254 if (getNextChar() !=
'*')
263void LLLexer::SkipLineComment() {
265 if (CurPtr[0] ==
'\n' || CurPtr[0] ==
'\r' || getNextChar() == EOF)
272bool LLLexer::SkipCComment() {
274 int CurChar = getNextChar();
277 LexError(
"unterminated comment");
281 CurChar = getNextChar();
284 if (CurChar == EOF) {
285 LexError(
"unterminated comment");
303 StrVal.assign(TokStart, CurPtr - 1);
308 if (CurPtr[0] ==
'"') {
312 int CurChar = getNextChar();
314 if (CurChar == EOF) {
315 LexError(
"end of file in COMDAT variable name");
318 if (CurChar ==
'"') {
319 StrVal.assign(TokStart + 2, CurPtr - 1);
321 if (StringRef(StrVal).
contains(0)) {
322 LexError(
"NUL character is not allowed in names");
339 const char *
Start = CurPtr;
341 int CurChar = getNextChar();
343 if (CurChar == EOF) {
344 LexError(
"end of file in string constant");
347 if (CurChar ==
'"') {
348 StrVal.assign(Start, CurPtr-1);
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] ==
'_') {
362 while (isalnum(
static_cast<unsigned char>(CurPtr[0])) ||
363 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
364 CurPtr[0] ==
'.' || CurPtr[0] ==
'_')
367 StrVal.assign(NameStart, CurPtr);
376 if (!isdigit(
static_cast<unsigned char>(CurPtr[0])))
379 for (++CurPtr; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
382 uint64_t Val = atoull(TokStart + 1, CurPtr);
383 if ((
unsigned)Val != Val)
384 LexError(
"invalid value number (too large)");
385 UIntVal = unsigned(Val);
391 if (CurPtr[0] ==
'"') {
395 int CurChar = getNextChar();
397 if (CurChar == EOF) {
398 LexError(
"end of file in global variable name");
401 if (CurChar ==
'"') {
402 StrVal.assign(TokStart+2, CurPtr-1);
404 if (StringRef(StrVal).
contains(0)) {
405 LexError(
"NUL character is not allowed in names");
418 return LexUIntID(
VarID);
437 if (CurPtr[0] ==
':') {
439 if (StringRef(StrVal).
contains(0)) {
440 LexError(
"NUL character is not allowed in names");
455 if (isalpha(
static_cast<unsigned char>(CurPtr[0])) ||
456 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
457 CurPtr[0] ==
'.' || CurPtr[0] ==
'_' || CurPtr[0] ==
'\\') {
459 while (isalnum(
static_cast<unsigned char>(CurPtr[0])) ||
460 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
461 CurPtr[0] ==
'.' || CurPtr[0] ==
'_' || CurPtr[0] ==
'\\')
464 StrVal.assign(TokStart+1, CurPtr);
483 if (isdigit(
static_cast<unsigned char>(CurPtr[0])))
494 const char *StartChar = CurPtr;
495 const char *IntEnd = CurPtr[-1] ==
'i' ? nullptr : StartChar;
496 const char *KeywordEnd =
nullptr;
500 if (!IntEnd && !isdigit(
static_cast<unsigned char>(*CurPtr)))
502 if (!KeywordEnd && !isalnum(
static_cast<unsigned char>(*CurPtr)) &&
509 if (!IgnoreColonInIdentifiers && *CurPtr ==
':') {
510 StrVal.assign(StartChar-1, CurPtr++);
516 if (!IntEnd) IntEnd = CurPtr;
517 if (IntEnd != StartChar) {
519 uint64_t NumBits = atoull(StartChar, CurPtr);
522 LexError(
"bitwidth for integer type out of range");
530 if (!KeywordEnd) KeywordEnd = CurPtr;
533 StringRef
Keyword(StartChar, CurPtr - StartChar);
535#define KEYWORD(STR) \
537 if (Keyword == #STR) \
538 return lltok::kw_##STR; \
564 KEYWORD(externally_initialized);
630 KEYWORD(no_sanitize_hwaddress);
631 KEYWORD(sanitize_address_dyninit);
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);
679 KEYWORD(amdgpu_cs_chain_preserve);
682 KEYWORD(amdgpu_gfx_whole_wave);
696#define GET_ATTR_NAMES
697#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
698 KEYWORD(DISPLAY_NAME);
699#include "llvm/IR/Attributes.inc"
709 KEYWORD(inaccessiblemem_or_argmemonly);
827 KEYWORD(typeCheckedLoadVCalls);
828 KEYWORD(typeTestAssumeConstVCalls);
829 KEYWORD(typeCheckedLoadConstVCalls);
834 KEYWORD(typeidCompatibleVTable);
875#define TYPEKEYWORD(STR, LLVMTY) \
877 if (Keyword == STR) { \
879 return lltok::Type; \
900#define INSTKEYWORD(STR, Enum) \
902 if (Keyword == #STR) { \
903 UIntVal = Instruction::Enum; \
904 return lltok::kw_##STR; \
970#define DWKEYWORD(TYPE, TOKEN) \
972 if (Keyword.starts_with("DW_" #TYPE "_")) { \
973 StrVal.assign(Keyword.begin(), Keyword.end()); \
974 return lltok::TOKEN; \
985 DWKEYWORD(APPLE_ENUM_KIND, DwarfEnumKind);
990#define DBGRECORDTYPEKEYWORD(STR) \
992 if (Keyword == "dbg_" #STR) { \
994 return lltok::DbgRecordType; \
1002#undef DBGRECORDTYPEKEYWORD
1004 if (
Keyword.starts_with(
"DIFlag")) {
1009 if (
Keyword.starts_with(
"DISPFlag")) {
1014 if (
Keyword.starts_with(
"CSK_")) {
1019 if (Keyword ==
"NoDebug" || Keyword ==
"FullDebug" ||
1020 Keyword ==
"LineTablesOnly" || Keyword ==
"DebugDirectivesOnly") {
1025 if (Keyword ==
"GNU" || Keyword ==
"Apple" || Keyword ==
"None" ||
1026 Keyword ==
"Default") {
1031 if (Keyword ==
"Binary" || Keyword ==
"Decimal" || Keyword ==
"Rational") {
1038 if ((TokStart[0] ==
'u' || TokStart[0] ==
's') &&
1039 TokStart[1] ==
'0' && TokStart[2] ==
'x' &&
1040 isxdigit(
static_cast<unsigned char>(TokStart[3]))) {
1041 int len = CurPtr-TokStart-3;
1042 uint32_t bits = len * 4;
1043 StringRef HexStr(TokStart + 3, len);
1044 if (!
all_of(HexStr, isxdigit)) {
1046 CurPtr = TokStart+3;
1049 APInt Tmp(bits, HexStr, 16);
1050 uint32_t activeBits = Tmp.getActiveBits();
1051 if (activeBits > 0 && activeBits < bits)
1052 Tmp = Tmp.trunc(activeBits);
1053 APSIntVal =
APSInt(Tmp, TokStart[0] ==
'u');
1058 if (TokStart[0] ==
'c' && TokStart[1] ==
'c') {
1059 CurPtr = TokStart+2;
1064 CurPtr = TokStart+1;
1077 CurPtr = TokStart + 2;
1080 if ((CurPtr[0] >=
'K' && CurPtr[0] <=
'M') || CurPtr[0] ==
'H' ||
1087 if (!isxdigit(
static_cast<unsigned char>(CurPtr[0]))) {
1089 CurPtr = TokStart+1;
1093 while (isxdigit(
static_cast<unsigned char>(CurPtr[0])))
1101 APInt(64, HexIntToVal(TokStart + 2, CurPtr)));
1110 FP80HexToIntPair(TokStart+3, CurPtr, Pair);
1115 HexToIntPair(TokStart+3, CurPtr, Pair);
1120 HexToIntPair(TokStart+3, CurPtr, Pair);
1125 APInt(16,HexIntToVal(TokStart+3, CurPtr)));
1130 APInt(16, HexIntToVal(TokStart + 3, CurPtr)));
1146 if (!isdigit(
static_cast<unsigned char>(TokStart[0])) &&
1147 !isdigit(
static_cast<unsigned char>(CurPtr[0]))) {
1150 StrVal.assign(TokStart, End-1);
1161 for (; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1165 if (isdigit(TokStart[0]) && CurPtr[0] ==
':') {
1166 uint64_t Val = atoull(TokStart, CurPtr);
1168 if ((
unsigned)Val != Val)
1169 LexError(
"invalid value number (too large)");
1170 UIntVal = unsigned(Val);
1177 StrVal.assign(TokStart, End-1);
1185 if (CurPtr[0] !=
'.') {
1186 if (TokStart[0] ==
'0' && TokStart[1] ==
'x')
1188 APSIntVal =
APSInt(StringRef(TokStart, CurPtr - TokStart));
1195 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1197 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1198 if (isdigit(
static_cast<unsigned char>(CurPtr[1])) ||
1199 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1200 isdigit(
static_cast<unsigned char>(CurPtr[2])))) {
1202 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1207 StringRef(TokStart, CurPtr - TokStart));
1216 if (!isdigit(
static_cast<unsigned char>(CurPtr[0])))
1220 for (++CurPtr; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1224 if (CurPtr[0] !=
'.') {
1225 CurPtr = TokStart+1;
1232 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1234 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1235 if (isdigit(
static_cast<unsigned char>(CurPtr[1])) ||
1236 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1237 isdigit(
static_cast<unsigned char>(CurPtr[2])))) {
1239 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1244 StringRef(TokStart, CurPtr - TokStart));
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Mark last scratch load
AMDGPU Register Bank Select
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.
static void UnEscapeLexed(std::string &Str)
static const char * isLabelTail(const char *CurPtr)
isLabelTail - Return true if this pointer points to a valid end of a label.
#define DBGRECORDTYPEKEYWORD(STR)
static bool isLabelChar(char C)
isLabelChar - Return true for [-a-zA-Z$._0-9].
#define TYPEKEYWORD(STR, LLVMTY)
#define DWKEYWORD(TYPE, TOKEN)
#define INSTKEYWORD(STR, Enum)
static constexpr auto TAG
dot regions Print regions of function to dot true view regions View regions of function(with no function bodies)"
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static uint64_t allOnes(unsigned int Count)
Lightweight error class with error context and mandatory checking.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
@ 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
LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &, LLVMContext &C)
This is an important class for using LLVM in a threaded context.
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...
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static LLVM_ABI Type * getX86_AMXTy(LLVMContext &C)
static LLVM_ABI Type * getMetadataTy(LLVMContext &C)
static LLVM_ABI Type * getTokenTy(LLVMContext &C)
static LLVM_ABI Type * getPPC_FP128Ty(LLVMContext &C)
static LLVM_ABI Type * getFP128Ty(LLVMContext &C)
static LLVM_ABI Type * getLabelTy(LLVMContext &C)
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
static LLVM_ABI Type * getX86_FP80Ty(LLVMContext &C)
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
static LLVM_ABI Type * getBFloatTy(LLVMContext &C)
static LLVM_ABI Type * getHalfTy(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.
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.
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)
@ Or
Bitwise or logical OR of integers.
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
@ And
Bitwise or logical AND of integers.
@ Sub
Subtraction of integers.
auto partition(R &&Range, UnaryPredicate P)
Provide wrappers to std::partition which take ranges instead of having to pass begin/end explicitly.
static LLVM_ABI const fltSemantics & PPCDoubleDouble() LLVM_READNONE
static LLVM_ABI const fltSemantics & x87DoubleExtended() LLVM_READNONE
static LLVM_ABI const fltSemantics & IEEEquad() LLVM_READNONE
static LLVM_ABI const fltSemantics & IEEEdouble() LLVM_READNONE
static LLVM_ABI const fltSemantics & IEEEhalf() LLVM_READNONE
static LLVM_ABI const fltSemantics & BFloat() LLVM_READNONE