37void LLLexer::Error(LocTy ErrorLoc,
const Twine &Msg,
38 LLLexer::ErrorPriority 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) {
76 Result += hexDigitValue(*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++) {
93 Pair[0] += hexDigitValue(*Buffer);
97 for (
int i = 0; i < 16 && Buffer !=
End; i++, Buffer++) {
99 Pair[1] += hexDigitValue(*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++) {
113 Pair[1] += hexDigitValue(*Buffer);
116 for (
int i = 0; i < 16 && Buffer !=
End; i++, Buffer++) {
118 Pair[0] += hexDigitValue(*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]))) {
139 *BOut = hexDigitValue(BIn[1]) * 16 + hexDigitValue(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);
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)");
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);
405 LexError(
"NUL character is not allowed in names");
418 return LexUIntID(
VarID);
437 if (CurPtr[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;
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);
694#define GET_ATTR_NAMES
695#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
696 KEYWORD(DISPLAY_NAME);
697#include "llvm/IR/Attributes.inc"
706 KEYWORD(inaccessiblemem_or_argmemonly);
817 KEYWORD(typeCheckedLoadVCalls);
818 KEYWORD(typeTestAssumeConstVCalls);
819 KEYWORD(typeCheckedLoadConstVCalls);
824 KEYWORD(typeidCompatibleVTable);
865#define TYPEKEYWORD(STR, LLVMTY) \
867 if (Keyword == STR) { \
869 return lltok::Type; \
890#define INSTKEYWORD(STR, Enum) \
892 if (Keyword == #STR) { \
893 UIntVal = Instruction::Enum; \
894 return lltok::kw_##STR; \
959#define DWKEYWORD(TYPE, TOKEN) \
961 if (Keyword.starts_with("DW_" #TYPE "_")) { \
962 StrVal.assign(Keyword.begin(), Keyword.end()); \
963 return lltok::TOKEN; \
978#define DBGRECORDTYPEKEYWORD(STR) \
980 if (Keyword == "dbg_" #STR) { \
982 return lltok::DbgRecordType; \
990#undef DBGRECORDTYPEKEYWORD
992 if (
Keyword.starts_with(
"DIFlag")) {
997 if (
Keyword.starts_with(
"DISPFlag")) {
1002 if (
Keyword.starts_with(
"CSK_")) {
1007 if (Keyword ==
"NoDebug" || Keyword ==
"FullDebug" ||
1008 Keyword ==
"LineTablesOnly" || Keyword ==
"DebugDirectivesOnly") {
1013 if (Keyword ==
"GNU" || Keyword ==
"Apple" || Keyword ==
"None" ||
1014 Keyword ==
"Default") {
1021 if ((TokStart[0] ==
'u' || TokStart[0] ==
's') &&
1022 TokStart[1] ==
'0' && TokStart[2] ==
'x' &&
1023 isxdigit(
static_cast<unsigned char>(TokStart[3]))) {
1024 int len = CurPtr-TokStart-3;
1027 if (!
all_of(HexStr, isxdigit)) {
1029 CurPtr = TokStart+3;
1032 APInt Tmp(bits, HexStr, 16);
1033 uint32_t activeBits = Tmp.getActiveBits();
1034 if (activeBits > 0 && activeBits < bits)
1035 Tmp = Tmp.trunc(activeBits);
1036 APSIntVal =
APSInt(Tmp, TokStart[0] ==
'u');
1041 if (TokStart[0] ==
'c' && TokStart[1] ==
'c') {
1042 CurPtr = TokStart+2;
1047 CurPtr = TokStart+1;
1060 CurPtr = TokStart + 2;
1063 if ((CurPtr[0] >=
'K' && CurPtr[0] <=
'M') || CurPtr[0] ==
'H' ||
1070 if (!isxdigit(
static_cast<unsigned char>(CurPtr[0]))) {
1072 CurPtr = TokStart+1;
1076 while (isxdigit(
static_cast<unsigned char>(CurPtr[0])))
1084 APInt(64, HexIntToVal(TokStart + 2, CurPtr)));
1093 FP80HexToIntPair(TokStart+3, CurPtr, Pair);
1098 HexToIntPair(TokStart+3, CurPtr, Pair);
1103 HexToIntPair(TokStart+3, CurPtr, Pair);
1108 APInt(16,HexIntToVal(TokStart+3, CurPtr)));
1113 APInt(16, HexIntToVal(TokStart + 3, CurPtr)));
1129 if (!isdigit(
static_cast<unsigned char>(TokStart[0])) &&
1130 !isdigit(
static_cast<unsigned char>(CurPtr[0]))) {
1133 StrVal.assign(TokStart,
End-1);
1144 for (; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1148 if (isdigit(TokStart[0]) && CurPtr[0] ==
':') {
1149 uint64_t Val = atoull(TokStart, CurPtr);
1151 if ((
unsigned)Val != Val)
1152 LexError(
"invalid value number (too large)");
1160 StrVal.assign(TokStart,
End-1);
1168 if (CurPtr[0] !=
'.') {
1169 if (TokStart[0] ==
'0' && TokStart[1] ==
'x')
1178 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1180 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1181 if (isdigit(
static_cast<unsigned char>(CurPtr[1])) ||
1182 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1183 isdigit(
static_cast<unsigned char>(CurPtr[2])))) {
1185 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1190 StringRef(TokStart, CurPtr - TokStart));
1199 if (!isdigit(
static_cast<unsigned char>(CurPtr[0])))
1203 for (++CurPtr; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1207 if (CurPtr[0] !=
'.') {
1208 CurPtr = TokStart+1;
1215 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1217 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1218 if (isdigit(
static_cast<unsigned char>(CurPtr[1])) ||
1219 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1220 isdigit(
static_cast<unsigned char>(CurPtr[2])))) {
1222 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1227 StringRef(TokStart, CurPtr - TokStart));
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.
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
Find IFuncs that have resolvers that always point at the same statically known callee
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
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static uint64_t allOnes(unsigned int Count)
Class for arbitrary precision integers.
An arbitrary precision integer that knows its signedness.
Base class for user error types.
static 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...
Represents a location in source code.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
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.
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.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
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.
This is an optimization pass for GlobalISel generic memory operations.
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.
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)
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.
@ And
Bitwise or logical AND 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 const fltSemantics & PPCDoubleDouble() LLVM_READNONE
static const fltSemantics & x87DoubleExtended() LLVM_READNONE
static const fltSemantics & IEEEquad() LLVM_READNONE
static const fltSemantics & IEEEdouble() LLVM_READNONE
static const fltSemantics & IEEEhalf() LLVM_READNONE
static const fltSemantics & BFloat() LLVM_READNONE