Go to the documentation of this file.
45 uint64_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!");
59 uint64_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!");
74 void 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!");
95 void 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();
166 int 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();
247 void 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);
318 bool 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)!");
347 UIntVal = unsigned(Val);
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);
586 KEYWORD(sanitize_address_dyninit);
600 KEYWORD(aarch64_sve_vector_pcs);
641 #define GET_ATTR_NAMES
642 #define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
643 KEYWORD(DISPLAY_NAME);
644 #include "llvm/IR/Attributes.inc"
728 KEYWORD(typeCheckedLoadVCalls);
729 KEYWORD(typeTestAssumeConstVCalls);
730 KEYWORD(typeCheckedLoadConstVCalls);
735 KEYWORD(typeidCompatibleVTable);
769 #define TYPEKEYWORD(STR, LLVMTY) \
771 if (Keyword == STR) { \
773 return lltok::Type; \
791 if (Keyword ==
"ptr") {
796 Warning(
"ptr type is only supported in -opaque-pointers mode");
806 #define INSTKEYWORD(STR, Enum) \
808 if (Keyword == #STR) { \
809 UIntVal = Instruction::Enum; \
810 return lltok::kw_##STR; \
875 #define DWKEYWORD(TYPE, TOKEN) \
877 if (Keyword.startswith("DW_" #TYPE "_")) { \
878 StrVal.assign(Keyword.begin(), Keyword.end()); \
879 return lltok::TOKEN; \
893 if (
Keyword.startswith(
"DIFlag")) {
898 if (
Keyword.startswith(
"DISPFlag")) {
903 if (
Keyword.startswith(
"CSK_")) {
908 if (Keyword ==
"NoDebug" || Keyword ==
"FullDebug" ||
909 Keyword ==
"LineTablesOnly" || Keyword ==
"DebugDirectivesOnly") {
914 if (Keyword ==
"GNU" || Keyword ==
"None" || Keyword ==
"Default") {
921 if ((TokStart[0] ==
'u' || TokStart[0] ==
's') &&
922 TokStart[1] ==
'0' && TokStart[2] ==
'x' &&
923 isxdigit(
static_cast<unsigned char>(TokStart[3]))) {
924 int len = CurPtr-TokStart-3;
927 if (!
all_of(HexStr, isxdigit)) {
933 uint32_t activeBits = Tmp.getActiveBits();
934 if (activeBits > 0 && activeBits <
bits)
935 Tmp = Tmp.trunc(activeBits);
936 APSIntVal =
APSInt(Tmp, TokStart[0] ==
'u');
941 if (TokStart[0] ==
'c' && TokStart[1] ==
'c') {
960 CurPtr = TokStart + 2;
963 if ((CurPtr[0] >=
'K' && CurPtr[0] <=
'M') || CurPtr[0] ==
'H' ||
970 if (!isxdigit(
static_cast<unsigned char>(CurPtr[0]))) {
976 while (isxdigit(
static_cast<unsigned char>(CurPtr[0])))
984 APInt(64, HexIntToVal(TokStart + 2, CurPtr)));
993 FP80HexToIntPair(TokStart+3, CurPtr, Pair);
998 HexToIntPair(TokStart+3, CurPtr, Pair);
1003 HexToIntPair(TokStart+3, CurPtr, Pair);
1008 APInt(16,HexIntToVal(TokStart+3, CurPtr)));
1013 APInt(16, HexIntToVal(TokStart + 3, CurPtr)));
1029 if (!isdigit(
static_cast<unsigned char>(TokStart[0])) &&
1030 !isdigit(
static_cast<unsigned char>(CurPtr[0]))) {
1033 StrVal.assign(TokStart, End-1);
1044 for (; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1048 if (isdigit(TokStart[0]) && CurPtr[0] ==
':') {
1049 uint64_t Val = atoull(TokStart, CurPtr);
1051 if ((
unsigned)Val != Val)
1052 Error(
"invalid value number (too large)!");
1053 UIntVal = unsigned(Val);
1060 StrVal.assign(TokStart, End-1);
1068 if (CurPtr[0] !=
'.') {
1069 if (TokStart[0] ==
'0' && TokStart[1] ==
'x')
1078 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1080 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1081 if (isdigit(
static_cast<unsigned char>(CurPtr[1])) ||
1082 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1083 isdigit(
static_cast<unsigned char>(CurPtr[2])))) {
1085 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1090 StringRef(TokStart, CurPtr - TokStart));
1099 if (!isdigit(
static_cast<unsigned char>(CurPtr[0])))
1103 for (++CurPtr; isdigit(
static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
1107 if (CurPtr[0] !=
'.') {
1108 CurPtr = TokStart+1;
1115 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1117 if (CurPtr[0] ==
'e' || CurPtr[0] ==
'E') {
1118 if (isdigit(
static_cast<unsigned char>(CurPtr[1])) ||
1119 ((CurPtr[1] ==
'-' || CurPtr[1] ==
'+') &&
1120 isdigit(
static_cast<unsigned char>(CurPtr[2])))) {
1122 while (isdigit(
static_cast<unsigned char>(CurPtr[0]))) ++CurPtr;
1127 StringRef(TokStart, CurPtr - TokStart));
LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &, LLVMContext &C)
static const char * isLabelTail(const char *CurPtr)
isLabelTail - Return true if this pointer points to a valid end of a label.
we should consider alternate ways to model stack dependencies Lots of things could be done in WebAssemblyTargetTransformInfo cpp there are numerous optimization related hooks that can be overridden in WebAssemblyTargetLowering Instead of the OptimizeReturned which should consider preserving the returned attribute through to MachineInstrs and extending the MemIntrinsicResults pass to do this optimization on calls too That would also let the WebAssemblyPeephole pass clean up dead defs for such as it does for stores Consider implementing and or getMachineCombinerPatterns Find a clean way to fix the problem which leads to the Shrink Wrapping pass being run after the WebAssembly PEI pass When setting multiple variables to the same constant
This is an optimization pass for GlobalISel generic memory operations.
#define TYPEKEYWORD(STR, LLVMTY)
static Type * getFP128Ty(LLVMContext &C)
static constexpr auto TAG
bool Error(LocTy ErrorLoc, const Twine &Msg) const
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM ID Predecessors according to mbb< bb27, 0x8b0a7c0 > Note ADDri is not a two address instruction its result reg1037 is an operand of the PHI node in bb76 and its operand reg1039 is the result of the PHI node We should treat it as a two address code and make sure the ADDri is scheduled after any node that reads reg1039 Use info(i.e. register scavenger) to assign it a free register to allow reuse the collector could move the objects and invalidate the derived pointer This is bad enough in the first but safe points can crop up unpredictably **array_addr i32 n y store obj obj **nth_el If the i64 division is lowered to a then a safe point array and nth_el no longer point into the correct object The fix for this is to copy address calculations so that dependent pointers are never live across safe point boundaries But the loads cannot be copied like this if there was an intervening store
static constexpr size_t npos
bool mayThrow(const MachineInstr &MI)
static const fltSemantics & x87DoubleExtended() LLVM_READNONE
static void cleanup(BlockFrequencyInfoImplBase &BFI)
Clear all memory not needed downstream.
static const fltSemantics & BFloat() LLVM_READNONE
bool hasSetOpaquePointersValue() const
Whether we've decided on using opaque pointers or typed pointers yet.
static Type * getTokenTy(LLVMContext &C)
to esp esp setne al movzbw ax esp setg cl movzbw cx cmove cx cl jne LBB1_2 esp ret(also really horrible code on ppc). This is due to the expand code for 64-bit compares. GCC produces multiple branches
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Deduce and propagate attributes
void setOpaquePointers(bool Enable) const
Set whether opaque pointers are enabled.
int caller(int32 arg1, int32 arg2)
We currently generate a but we really shouldn eax ecx xorl edx divl ecx eax divl ecx movl eax ret A similar code sequence works for division We currently compile i32 v2 eax eax jo LBB1_2 and
Predicate any(Predicate P0, Predicate P1)
True iff P0 or P1 are true.
const APInt & umin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be unsigned.
@ MAX_INT_BITS
Maximum number of bits that can be specified.
static const fltSemantics & IEEEquad() LLVM_READNONE
static Type * getMetadataTy(LLVMContext &C)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
static Type * getX86_AMXTy(LLVMContext &C)
bool supportsTypedPointers() const
Whether typed pointers are supported. If false, all pointers are opaque.
into xmm2 addss xmm2 xmm1 xmm3 addss xmm3 movaps xmm0 unpcklps xmm0 ret seems silly when it could just be one addps Expand libm rounding functions main should enable SSE DAZ mode and other fast SSE modes Think about doing i64 math in SSE regs on x86 This testcase should have no SSE instructions in and only one load from a constant double ret double C the select is being which prevents the dag combiner from turning select(load CPI1)
Represents a location in source code.
We currently generate a but we really shouldn eax ecx xorl edx divl ecx eax divl ecx movl eax ret A similar code sequence works for division We currently compile i32 v2 eax eax jo LBB1_2 shl
static Type * getPPC_FP128Ty(LLVMContext &C)
static const fltSemantics & IEEEhalf() LLVM_READNONE
static Type * getDoubleTy(LLVMContext &C)
(vector float) vec_cmpeq(*A, *B) C
#define DWKEYWORD(TYPE, TOKEN)
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
@ MIN_INT_BITS
Minimum number of bits that can be specified.
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int int c
static void UnEscapeLexed(std::string &Str)
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only one
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
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.
This is an important class for using LLVM in a threaded context.
we currently eax ecx subl eax ret We would use one fewer register if codegen d eax neg eax eax ret Note that this isn t beneficial if the load can be folded into the sub In this we want a sub
S is passed via registers r2 But gcc stores them to the and then reload them to and r3 before issuing the call(r0 contains the address of the format string)
static const fltSemantics & PPCDoubleDouble() LLVM_READNONE
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM currently emits rax rax movq rax rax ret It could narrow the loads and stores to emit rax rax movq rax rax ret The trouble is that there is a TokenFactor between the store and the load
void Warning(LocTy WarningLoc, const Twine &Msg) const
static Type * getX86_FP80Ty(LLVMContext &C)
Base class for user error types.
rewrite statepoints for gc
Class for arbitrary precision integers.
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
static const fltSemantics & IEEEdouble() LLVM_READNONE
StringRef - Represent a constant reference to a string, i.e.
static uint64_t allOnes(unsigned int Count)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
We have fiadd patterns now but the followings have the same cost and complexity We need a way to specify the later is more profitable def def The FP stackifier should handle simple permutates to reduce number of shuffle e g trunc
auto partition(R &&Range, UnaryPredicate P)
Provide wrappers to std::partition which take ranges instead of having to pass begin/end explicitly.
We currently generate a but we really shouldn eax ecx xorl edx divl ecx eax divl ecx movl eax ret A similar code sequence works for division We currently compile i32 v2 eax eax jo LBB1_2 xor
const CustomOperand< const MCSubtargetInfo & > Msg[]
const APInt & umax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be unsigned.
into llvm powi allowing the code generator to produce balanced multiplication trees the intrinsic needs to be extended to support and second the code generator needs to be enhanced to lower these to multiplication trees Interesting testcase for add shift mul reassoc
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional ldr LCPI1_0 ldr ldr tst movne lsr ldr LCPI1_1 and r0 bx lr it saves an instruction and a register It might be profitable to cse MOVi16 if there are lots of bit immediates with the same bottom half Robert Muth started working on an alternate jump table implementation that does not put the tables in line in the text This is more like the llvm default jump table implementation This might be useful sometime Several revisions of patches are on the mailing beginning while CMP sets them like a subtract Therefore to be able to use CMN for comparisons other than the Z bit
static Type * getHalfTy(LLVMContext &C)
static Type * getBFloatTy(LLVMContext &C)
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.
static Type * getVoidTy(LLVMContext &C)
static bool isLabelChar(char C)
isLabelChar - Return true for [-a-zA-Z$._0-9].
amdgpu Simplify well known AMD library calls
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
static Type * getLabelTy(LLVMContext &C)
#define INSTKEYWORD(STR, Enum)
Vector Shift Left don t map to llvm shl and lshr
Here we don t need to write any variables to the top of the stack since they don t overwrite each other int callee(int32 arg1, int32 arg2)
static Type * getX86_MMXTy(LLVMContext &C)
static Type * getFloatTy(LLVMContext &C)