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);
688 KEYWORD(cheriot_compartmentcallcc);
689 KEYWORD(cheriot_compartmentcalleecc);
690 KEYWORD(cheriot_librarycallcc);
699#define GET_ATTR_NAMES
700#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
701 KEYWORD(DISPLAY_NAME);
702#include "llvm/IR/Attributes.inc"
712 KEYWORD(inaccessiblemem_or_argmemonly);
830 KEYWORD(typeCheckedLoadVCalls);
831 KEYWORD(typeTestAssumeConstVCalls);
832 KEYWORD(typeCheckedLoadConstVCalls);
837 KEYWORD(typeidCompatibleVTable);
878#define TYPEKEYWORD(STR, LLVMTY) \
880 if (Keyword == STR) { \
882 return lltok::Type; \
903#define INSTKEYWORD(STR, Enum) \
905 if (Keyword == #STR) { \
906 UIntVal = Instruction::Enum; \
907 return lltok::kw_##STR; \
973#define DWKEYWORD(TYPE, TOKEN) \
975 if (Keyword.starts_with("DW_" #TYPE "_")) { \
976 StrVal.assign(Keyword.begin(), Keyword.end()); \
977 return lltok::TOKEN; \
988 DWKEYWORD(APPLE_ENUM_KIND, DwarfEnumKind);
993#define DBGRECORDTYPEKEYWORD(STR) \
995 if (Keyword == "dbg_" #STR) { \
997 return lltok::DbgRecordType; \
1005#undef DBGRECORDTYPEKEYWORD
1007 if (
Keyword.starts_with(
"DIFlag")) {
1012 if (
Keyword.starts_with(
"DISPFlag")) {
1017 if (
Keyword.starts_with(
"CSK_")) {
1022 if (Keyword ==
"NoDebug" || Keyword ==
"FullDebug" ||
1023 Keyword ==
"LineTablesOnly" || Keyword ==
"DebugDirectivesOnly") {
1028 if (Keyword ==
"GNU" || Keyword ==
"Apple" || Keyword ==
"None" ||
1029 Keyword ==
"Default") {
1034 if (Keyword ==
"Binary" || Keyword ==
"Decimal" || Keyword ==
"Rational") {
1041 if ((TokStart[0] ==
'u' || TokStart[0] ==
's') &&
1042 TokStart[1] ==
'0' && TokStart[2] ==
'x' &&
1043 isxdigit(
static_cast<unsigned char>(TokStart[3]))) {
1044 int len = CurPtr-TokStart-3;
1045 uint32_t bits = len * 4;
1046 StringRef HexStr(TokStart + 3, len);
1047 if (!
all_of(HexStr, isxdigit)) {
1049 CurPtr = TokStart+3;
1052 APInt Tmp(bits, HexStr, 16);
1053 uint32_t activeBits = Tmp.getActiveBits();
1054 if (activeBits > 0 && activeBits < bits)
1055 Tmp = Tmp.trunc(activeBits);
1056 APSIntVal =
APSInt(Tmp, TokStart[0] ==
'u');
1061 if (TokStart[0] ==
'c' && TokStart[1] ==
'c') {
1062 CurPtr = TokStart+2;
1067 CurPtr = TokStart+1;
1080 CurPtr = TokStart + 2;
1083 if ((CurPtr[0] >=
'K' && CurPtr[0] <=
'M') || CurPtr[0] ==
'H' ||
1090 if (!isxdigit(
static_cast<unsigned char>(CurPtr[0]))) {
1092 CurPtr = TokStart+1;
1096 while (isxdigit(
static_cast<unsigned char>(CurPtr[0])))
1104 APInt(64, HexIntToVal(TokStart + 2, CurPtr)));
1113 FP80HexToIntPair(TokStart+3, CurPtr, Pair);
1118 HexToIntPair(TokStart+3, CurPtr, Pair);
1123 HexToIntPair(TokStart+3, CurPtr, Pair);
1128 APInt(16,HexIntToVal(TokStart+3, CurPtr)));
1133 APInt(16, HexIntToVal(TokStart + 3, CurPtr)));
1149 if (!isdigit(
static_cast<unsigned char>(TokStart[0])) &&
1150 !isdigit(
static_cast<unsigned char>(CurPtr[0]))) {
1153 StrVal.assign(TokStart, End-1);
1164 for (; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1168 if (isdigit(TokStart[0]) && CurPtr[0] ==
':') {
1169 uint64_t Val = atoull(TokStart, CurPtr);
1171 if ((
unsigned)Val != Val)
1172 LexError(
"invalid value number (too large)");
1173 UIntVal = unsigned(Val);
1180 StrVal.assign(TokStart, End-1);
1188 if (CurPtr[0] !=
'.') {
1189 if (TokStart[0] ==
'0' && TokStart[1] ==
'x')
1191 APSIntVal =
APSInt(StringRef(TokStart, CurPtr - TokStart));
1198 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1200 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1201 if (isdigit(
static_cast<unsigned char>(CurPtr[1])) ||
1202 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1203 isdigit(
static_cast<unsigned char>(CurPtr[2])))) {
1205 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1210 StringRef(TokStart, CurPtr - TokStart));
1219 if (!isdigit(
static_cast<unsigned char>(CurPtr[0])))
1223 for (++CurPtr; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1227 if (CurPtr[0] !=
'.') {
1228 CurPtr = TokStart+1;
1235 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1237 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1238 if (isdigit(
static_cast<unsigned char>(CurPtr[1])) ||
1239 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1240 isdigit(
static_cast<unsigned char>(CurPtr[2])))) {
1242 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1247 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