45uint64_t LLLexer::atoull(
const char *Buffer,
const char *End) {
47 for (; Buffer != End; Buffer++) {
50 Result += *Buffer-
'0';
51 if (Result < OldRes) {
52 Error(
"constant bigger than 64 bits detected!");
59uint64_t LLLexer::HexIntToVal(
const char *Buffer,
const char *End) {
61 for (; Buffer != End; ++Buffer) {
64 Result += hexDigitValue(*Buffer);
66 if (Result < OldRes) {
67 Error(
"constant bigger than 64 bits detected!");
74void LLLexer::HexToIntPair(
const char *Buffer,
const char *End,
77 if (End - Buffer >= 16) {
78 for (
int i = 0; i < 16; i++, Buffer++) {
81 Pair[0] += hexDigitValue(*Buffer);
85 for (
int i = 0; i < 16 && Buffer != End; i++, Buffer++) {
87 Pair[1] += hexDigitValue(*Buffer);
90 Error(
"constant bigger than 128 bits detected!");
95void LLLexer::FP80HexToIntPair(
const char *Buffer,
const char *End,
98 for (
int i=0; i<4 && Buffer != End; i++, Buffer++) {
101 Pair[1] += hexDigitValue(*Buffer);
104 for (
int i = 0; i < 16 && Buffer != End; i++, Buffer++) {
106 Pair[0] += hexDigitValue(*Buffer);
109 Error(
"constant bigger than 128 bits detected!");
115 if (Str.empty())
return;
117 char *Buffer = &Str[0], *EndBuffer = Buffer+Str.size();
119 for (
char *BIn = Buffer; BIn != EndBuffer; ) {
120 if (BIn[0] ==
'\\') {
121 if (BIn < EndBuffer-1 && BIn[1] ==
'\\') {
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]);
137 Str.resize(BOut-Buffer);
142 return isalnum(
static_cast<unsigned char>(
C)) ||
C ==
'-' ||
C ==
'$' ||
143 C ==
'.' ||
C ==
'_';
149 if (CurPtr[0] ==
':')
return CurPtr+1;
162 IgnoreColonInIdentifiers(
false) {
163 CurPtr = CurBuf.
begin();
166int LLLexer::getNextChar() {
167 char CurChar = *CurPtr++;
169 default:
return (
unsigned char)CurChar;
173 if (CurPtr-1 != CurBuf.
end())
186 int CurChar = getNextChar();
190 if (isalpha(
static_cast<unsigned char>(CurChar)) || CurChar ==
'_')
191 return LexIdentifier();
202 case '+':
return LexPositive();
203 case '@':
return LexAt();
204 case '$':
return LexDollar();
205 case '%':
return LexPercent();
206 case '"':
return LexQuote();
210 StrVal.assign(TokStart, CurPtr-1);
213 if (CurPtr[0] ==
'.' && CurPtr[1] ==
'.') {
221 case '!':
return LexExclaim();
226 case '#':
return LexHash();
227 case '0':
case '1':
case '2':
case '3':
case '4':
228 case '5':
case '6':
case '7':
case '8':
case '9':
230 return LexDigitOrNegative();
247void LLLexer::SkipLineComment() {
249 if (CurPtr[0] ==
'\n' || CurPtr[0] ==
'\r' || getNextChar() == EOF)
265 StrVal.assign(TokStart, CurPtr - 1);
270 if (CurPtr[0] ==
'"') {
274 int CurChar = getNextChar();
276 if (CurChar == EOF) {
277 Error(
"end of file in COMDAT variable name");
280 if (CurChar ==
'"') {
281 StrVal.assign(TokStart + 2, CurPtr - 1);
284 Error(
"Null bytes are not allowed in names");
301 const char *Start = CurPtr;
303 int CurChar = getNextChar();
305 if (CurChar == EOF) {
306 Error(
"end of file in string constant");
309 if (CurChar ==
'"') {
310 StrVal.assign(Start, CurPtr-1);
318bool LLLexer::ReadVarName() {
319 const char *NameStart = CurPtr;
320 if (isalpha(
static_cast<unsigned char>(CurPtr[0])) ||
321 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
322 CurPtr[0] ==
'.' || CurPtr[0] ==
'_') {
324 while (isalnum(
static_cast<unsigned char>(CurPtr[0])) ||
325 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
326 CurPtr[0] ==
'.' || CurPtr[0] ==
'_')
329 StrVal.assign(NameStart, CurPtr);
338 if (!isdigit(
static_cast<unsigned char>(CurPtr[0])))
341 for (++CurPtr; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
344 uint64_t Val = atoull(TokStart + 1, CurPtr);
345 if ((
unsigned)Val != Val)
346 Error(
"invalid value number (too large)!");
353 if (CurPtr[0] ==
'"') {
357 int CurChar = getNextChar();
359 if (CurChar == EOF) {
360 Error(
"end of file in global variable name");
363 if (CurChar ==
'"') {
364 StrVal.assign(TokStart+2, CurPtr-1);
367 Error(
"Null bytes are not allowed in names");
380 return LexUIntID(VarID);
399 if (CurPtr[0] ==
':') {
402 Error(
"Null bytes are not allowed in names");
417 if (isalpha(
static_cast<unsigned char>(CurPtr[0])) ||
418 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
419 CurPtr[0] ==
'.' || CurPtr[0] ==
'_' || CurPtr[0] ==
'\\') {
421 while (isalnum(
static_cast<unsigned char>(CurPtr[0])) ||
422 CurPtr[0] ==
'-' || CurPtr[0] ==
'$' ||
423 CurPtr[0] ==
'.' || CurPtr[0] ==
'_' || CurPtr[0] ==
'\\')
426 StrVal.assign(TokStart+1, CurPtr);
453 const char *StartChar = CurPtr;
454 const char *IntEnd = CurPtr[-1] ==
'i' ? nullptr : StartChar;
455 const char *KeywordEnd =
nullptr;
459 if (!IntEnd && !isdigit(
static_cast<unsigned char>(*CurPtr)))
461 if (!KeywordEnd && !isalnum(
static_cast<unsigned char>(*CurPtr)) &&
468 if (!IgnoreColonInIdentifiers && *CurPtr ==
':') {
469 StrVal.assign(StartChar-1, CurPtr++);
475 if (!IntEnd) IntEnd = CurPtr;
476 if (IntEnd != StartChar) {
478 uint64_t NumBits = atoull(StartChar, CurPtr);
481 Error(
"bitwidth for integer type out of range!");
489 if (!KeywordEnd) KeywordEnd = CurPtr;
494#define KEYWORD(STR) \
496 if (Keyword == #STR) \
497 return lltok::kw_##STR; \
523 KEYWORD(externally_initialized);
584 KEYWORD(no_sanitize_hwaddress);
585 KEYWORD(sanitize_address_dyninit);
599 KEYWORD(aarch64_sve_vector_pcs);
600 KEYWORD(aarch64_sme_preservemost_from_x0);
601 KEYWORD(aarch64_sme_preservemost_from_x2);
642#define GET_ATTR_NAMES
643#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
644 KEYWORD(DISPLAY_NAME);
645#include "llvm/IR/Attributes.inc"
654 KEYWORD(inaccessiblemem_or_argmemonly);
758 KEYWORD(typeCheckedLoadVCalls);
759 KEYWORD(typeTestAssumeConstVCalls);
760 KEYWORD(typeCheckedLoadConstVCalls);
765 KEYWORD(typeidCompatibleVTable);
807#define TYPEKEYWORD(STR, LLVMTY) \
809 if (Keyword == STR) { \
811 return lltok::Type; \
829 if (Keyword ==
"ptr") {
831 Warning(
"ptr type is only supported in -opaque-pointers mode");
841#define INSTKEYWORD(STR, Enum) \
843 if (Keyword == #STR) { \
844 UIntVal = Instruction::Enum; \
845 return lltok::kw_##STR; \
910#define DWKEYWORD(TYPE, TOKEN) \
912 if (Keyword.startswith("DW_" #TYPE "_")) { \
913 StrVal.assign(Keyword.begin(), Keyword.end()); \
914 return lltok::TOKEN; \
928 if (
Keyword.startswith(
"DIFlag")) {
933 if (
Keyword.startswith(
"DISPFlag")) {
938 if (
Keyword.startswith(
"CSK_")) {
943 if (Keyword ==
"NoDebug" || Keyword ==
"FullDebug" ||
944 Keyword ==
"LineTablesOnly" || Keyword ==
"DebugDirectivesOnly") {
949 if (Keyword ==
"GNU" || Keyword ==
"None" || Keyword ==
"Default") {
956 if ((TokStart[0] ==
'u' || TokStart[0] ==
's') &&
957 TokStart[1] ==
'0' && TokStart[2] ==
'x' &&
958 isxdigit(
static_cast<unsigned char>(TokStart[3]))) {
959 int len = CurPtr-TokStart-3;
962 if (!
all_of(HexStr, isxdigit)) {
968 uint32_t activeBits = Tmp.getActiveBits();
969 if (activeBits > 0 && activeBits <
bits)
970 Tmp = Tmp.trunc(activeBits);
971 APSIntVal =
APSInt(Tmp, TokStart[0] ==
'u');
976 if (TokStart[0] ==
'c' && TokStart[1] ==
'c') {
995 CurPtr = TokStart + 2;
998 if ((CurPtr[0] >=
'K' && CurPtr[0] <=
'M') || CurPtr[0] ==
'H' ||
1005 if (!isxdigit(
static_cast<unsigned char>(CurPtr[0]))) {
1007 CurPtr = TokStart+1;
1011 while (isxdigit(
static_cast<unsigned char>(CurPtr[0])))
1019 APInt(64, HexIntToVal(TokStart + 2, CurPtr)));
1028 FP80HexToIntPair(TokStart+3, CurPtr, Pair);
1033 HexToIntPair(TokStart+3, CurPtr, Pair);
1038 HexToIntPair(TokStart+3, CurPtr, Pair);
1043 APInt(16,HexIntToVal(TokStart+3, CurPtr)));
1048 APInt(16, HexIntToVal(TokStart + 3, CurPtr)));
1064 if (!isdigit(
static_cast<unsigned char>(TokStart[0])) &&
1065 !isdigit(
static_cast<unsigned char>(CurPtr[0]))) {
1068 StrVal.assign(TokStart, End-1);
1079 for (; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1083 if (isdigit(TokStart[0]) && CurPtr[0] ==
':') {
1084 uint64_t Val = atoull(TokStart, CurPtr);
1086 if ((
unsigned)Val != Val)
1087 Error(
"invalid value number (too large)!");
1095 StrVal.assign(TokStart, End-1);
1103 if (CurPtr[0] !=
'.') {
1104 if (TokStart[0] ==
'0' && TokStart[1] ==
'x')
1113 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1115 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1116 if (isdigit(
static_cast<unsigned char>(CurPtr[1])) ||
1117 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1118 isdigit(
static_cast<unsigned char>(CurPtr[2])))) {
1120 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1125 StringRef(TokStart, CurPtr - TokStart));
1134 if (!isdigit(
static_cast<unsigned char>(CurPtr[0])))
1138 for (++CurPtr; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1142 if (CurPtr[0] !=
'.') {
1143 CurPtr = TokStart+1;
1150 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1152 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1153 if (isdigit(
static_cast<unsigned char>(CurPtr[1])) ||
1154 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1155 isdigit(
static_cast<unsigned char>(CurPtr[2])))) {
1157 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1162 StringRef(TokStart, CurPtr - TokStart));
amdgpu Simplify well known AMD library calls
amdgpu 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
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.
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)
print Print MemDeps of function
static constexpr auto TAG
rewrite statepoints for gc
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
Lightweight error class with error context and mandatory checking.
@ MIN_INT_BITS
Minimum number of bits that can be specified.
@ MAX_INT_BITS
Maximum number of bits that can be specified.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
void Warning(LocTy WarningLoc, const Twine &Msg) const
bool Error(LocTy ErrorLoc, const Twine &Msg) const
LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &, LLVMContext &C)
This is an important class for using LLVM in a threaded context.
bool supportsTypedPointers() const
Whether typed pointers are supported. If false, all pointers are opaque.
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.
static constexpr size_t npos
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 * getX86_MMXTy(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.
Error write(MCStreamer &Out, ArrayRef< std::string > Inputs)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
FPClassTest fneg(FPClassTest Mask)
Return the test mask which returns true if the value's sign bit is flipped.
@ 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.
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
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