86 : MF(MF), SM(&SM), IRSlots(IRSlots), Names2RegClasses(Names2RegClasses),
87 Names2RegBanks(Names2RegBanks) {
91 auto I =
VRegInfos.insert(std::make_pair(Num,
nullptr));
96 I.first->second = Info;
98 return *
I.first->second;
102 assert(RegName !=
"" &&
"Expected named reg.");
108 I.first->second = Info;
110 return *
I.first->second;
117 struct ParsedMachineOperand {
125 : Operand(Operand), Begin(Begin), End(End), TiedDefIdx(TiedDefIdx) {
128 "Only used register operands can be tied");
165 void lex(
unsigned SkipChar = 0);
179 bool parseBasicBlocks();
182 bool parseStandaloneNamedRegister(
unsigned &
Reg);
183 bool parseStandaloneVirtualRegister(
VRegInfo *&Info);
184 bool parseStandaloneRegister(
unsigned &Reg);
185 bool parseStandaloneStackObject(
int &FI);
186 bool parseStandaloneMDNode(
MDNode *&Node);
195 bool parseNamedRegister(
unsigned &Reg);
196 bool parseVirtualRegister(
VRegInfo *&Info);
197 bool parseNamedVirtualRegister(
VRegInfo *&Info);
199 bool parseRegisterFlag(
unsigned &Flags);
200 bool parseRegisterClassOrBank(VRegInfo &RegInfo);
201 bool parseSubRegisterIndex(
unsigned &
SubReg);
202 bool parseRegisterTiedDefIndex(
unsigned &TiedDefIdx);
214 bool parseStackFrameIndex(
int &FI);
216 bool parseFixedStackFrameIndex(
int &FI);
225 bool parseDIExpression(
MDNode *&Expr);
227 bool parseCFIOffset(
int &
Offset);
228 bool parseCFIRegister(
unsigned &Reg);
229 bool parseCFIEscapeValues(std::string& Values);
242 bool parseOffset(int64_t &Offset);
243 bool parseAlignment(
unsigned &Alignment);
244 bool parseAddrspace(
unsigned &Addrspace);
246 bool parseIRValue(
const Value *&V);
258 bool getUnsigned(
unsigned &
Result);
263 bool getUint64(uint64_t &Result);
269 bool getHexUint(
APInt &Result);
279 void initNames2InstrOpCodes();
283 bool parseInstrName(
StringRef InstrName,
unsigned &OpCode);
285 bool parseInstruction(
unsigned &OpCode,
unsigned &Flags);
293 void initNames2Regs();
297 bool getRegisterByName(
StringRef RegName,
unsigned &Reg);
299 void initNames2RegMasks();
306 void initNames2SubRegIndices();
316 const Value *getIRValue(
unsigned Slot);
318 void initNames2TargetIndices();
325 void initNames2DirectTargetFlags();
333 void initNames2BitmaskTargetFlags();
339 bool getBitmaskTargetFlag(
StringRef Name,
unsigned &Flag);
341 void initNames2MMOTargetFlags();
351 bool parseStringConstant(std::string &Result);
358 :
MF(PFS.
MF),
Error(Error),
Source(Source), CurrentSource(Source), PFS(PFS)
361 void MIParser::lex(
unsigned SkipChar) {
363 CurrentSource.data() + SkipChar, Token,
399 return "<unknown token>";
404 if (Token.isNot(TokenKind))
411 if (Token.isNot(TokenKind))
417 bool MIParser::parseBasicBlockDefinition(
423 auto Loc = Token.location();
424 auto Name = Token.stringValue();
426 bool HasAddressTaken =
false;
427 bool IsLandingPad =
false;
428 unsigned Alignment = 0;
433 switch (Token.kind()) {
435 HasAddressTaken =
true;
443 if (parseAlignment(Alignment))
463 BB = dyn_cast_or_null<BasicBlock>(
467 "' is not defined in the function '" +
472 bool WasInserted = MBBSlots.
insert(std::make_pair(ID, MBB)).second;
474 return error(Loc,
Twine(
"redefinition of machine basic block with id #") +
477 MBB->setAlignment(Alignment);
479 MBB->setHasAddressTaken();
480 MBB->setIsEHPad(IsLandingPad);
484 bool MIParser::parseBasicBlockDefinitions(
490 if (Token.isErrorOrEOF())
491 return Token.isError();
493 return error(
"expected a basic block definition before instructions");
494 unsigned BraceDepth = 0;
496 if (parseBasicBlockDefinition(MBBSlots))
498 bool IsAfterNewline =
false;
502 Token.isErrorOrEOF())
505 return error(
"basic block definition should be located at the start of " 508 IsAfterNewline =
true;
511 IsAfterNewline =
false;
516 return error(
"extraneous closing brace ('}')");
522 if (!Token.isError() && BraceDepth)
523 return error(
"expected '}'");
524 }
while (!Token.isErrorOrEOF());
525 return Token.isError();
533 if (Token.isNewlineOrEOF())
537 return error(
"expected a named register");
539 if (parseNamedRegister(Reg))
547 return error(
"expected a lane mask");
549 "Use correct get-function for lane mask");
552 return error(
"invalid lane mask value");
566 if (Token.isNewlineOrEOF())
570 return error(
"expected a machine basic block reference");
579 return error(
"expected an integer literal after '('");
580 if (getUnsigned(Weight))
613 bool ExplicitSuccessors =
false;
616 if (parseBasicBlockSuccessors(MBB))
618 ExplicitSuccessors =
true;
620 if (parseBasicBlockLiveins(MBB))
626 if (!Token.isNewlineOrEOF())
627 return error(
"expected line break at the end of a list");
632 bool IsInBundle =
false;
656 return error(
"nested instruction bundles are not allowed");
665 assert(Token.isNewlineOrEOF() &&
"MI is not fully parsed");
670 if (!ExplicitSuccessors) {
678 AddFalthroughFrom = &MBB;
687 bool MIParser::parseBasicBlocks() {
692 if (Token.isErrorOrEOF())
693 return Token.isError();
702 if (AddFalthroughFrom) {
703 if (!AddFalthroughFrom->isSuccessor(MBB))
705 AddFalthroughFrom->normalizeSuccProbs();
706 AddFalthroughFrom =
nullptr;
708 if (parseBasicBlock(*MBB, AddFalthroughFrom))
721 while (Token.isRegister() || Token.isRegisterFlag()) {
722 auto Loc = Token.location();
724 if (parseRegisterOperand(MO, TiedDefIdx,
true))
727 ParsedMachineOperand(MO, Loc, Token.location(), TiedDefIdx));
735 unsigned OpCode, Flags = 0;
736 if (Token.isError() || parseInstruction(OpCode, Flags))
742 auto Loc = Token.location();
744 if (parseMachineOperandAndTargetFlags(MO, TiedDefIdx))
747 ParsedMachineOperand(MO, Loc, Token.location(), TiedDefIdx));
752 return error(
"expected ',' before the next machine operand");
760 return error(
"expected a metadata node after 'debug-location'");
771 while (!Token.isNewlineOrEOF()) {
773 if (parseMachineMemoryOperand(MemOp))
776 if (Token.isNewlineOrEOF())
779 return error(
"expected ',' before the next machine memory operand");
785 if (!MCID.isVariadic()) {
787 if (verifyImplicitOperands(Operands, MCID))
794 for (
const auto &Operand : Operands)
796 if (assignRegisterTies(*MI, Operands))
798 if (MemOperands.
empty())
810 return error(
"expected a machine basic block reference");
816 "expected end of string after the machine basic block reference");
820 bool MIParser::parseStandaloneNamedRegister(
unsigned &
Reg) {
823 return error(
"expected a named register");
824 if (parseNamedRegister(Reg))
828 return error(
"expected end of string after the register reference");
832 bool MIParser::parseStandaloneVirtualRegister(
VRegInfo *&Info) {
835 return error(
"expected a virtual register");
836 if (parseVirtualRegister(Info))
840 return error(
"expected end of string after the register reference");
844 bool MIParser::parseStandaloneRegister(
unsigned &Reg) {
848 return error(
"expected either a named or virtual register");
851 if (parseRegister(Reg, Info))
856 return error(
"expected end of string after the register reference");
860 bool MIParser::parseStandaloneStackObject(
int &FI) {
863 return error(
"expected a stack object");
864 if (parseStackFrameIndex(FI))
867 return error(
"expected end of string after the stack object reference");
871 bool MIParser::parseStandaloneMDNode(
MDNode *&Node) {
877 if (parseDIExpression(Node))
880 return error(
"expected a metadata node");
882 return error(
"expected end of string after the metadata node");
888 return MO.
isDef() ?
"implicit-def" :
"implicit";
900 for (
const auto &
I : Operands) {
926 assert(
TRI &&
"Expected target register info");
927 for (
const auto &
I : ImplicitOperands) {
930 return error(Operands.
empty() ? Token.location() : Operands.
back().End,
931 Twine(
"missing implicit register operand '") +
938 bool MIParser::parseInstruction(
unsigned &OpCode,
unsigned &Flags) {
972 return error(
"expected a machine instruction");
973 StringRef InstrName = Token.stringValue();
974 if (parseInstrName(InstrName, OpCode))
975 return error(
Twine(
"unknown machine instruction name '") + InstrName +
"'");
980 bool MIParser::parseNamedRegister(
unsigned &Reg) {
983 if (getRegisterByName(Name, Reg))
984 return error(
Twine(
"unknown register name '") + Name +
"'");
988 bool MIParser::parseNamedVirtualRegister(
VRegInfo *&Info) {
997 bool MIParser::parseVirtualRegister(
VRegInfo *&Info) {
999 return parseNamedVirtualRegister(Info);
1002 if (getUnsigned(ID))
1008 bool MIParser::parseRegister(
unsigned &Reg,
VRegInfo *&Info) {
1009 switch (Token.kind()) {
1014 return parseNamedRegister(Reg);
1017 if (parseVirtualRegister(Info))
1027 bool MIParser::parseRegisterClassOrBank(
VRegInfo &RegInfo) {
1029 return error(
"expected '_', register class, or register bank name");
1039 switch (RegInfo.
Kind) {
1045 return error(Loc,
Twine(
"conflicting register classes, previously: ") +
1054 return error(Loc,
"register class specification on generic register");
1064 return error(Loc,
"expected '_', register class, or register bank name");
1065 RegBank = RBNameI->getValue();
1070 switch (RegInfo.
Kind) {
1076 return error(Loc,
"conflicting generic register banks");
1082 return error(Loc,
"register bank specification on normal register");
1087 bool MIParser::parseRegisterFlag(
unsigned &Flags) {
1088 const unsigned OldFlags = Flags;
1089 switch (Token.kind()) {
1123 if (OldFlags == Flags)
1126 return error(
"duplicate '" + Token.stringValue() +
"' register flag");
1131 bool MIParser::parseSubRegisterIndex(
unsigned &
SubReg) {
1135 return error(
"expected a subregister index after '.'");
1136 auto Name = Token.stringValue();
1137 SubReg = getSubRegIndex(
Name);
1139 return error(
Twine(
"use of unknown subregister index '") +
Name +
"'");
1144 bool MIParser::parseRegisterTiedDefIndex(
unsigned &TiedDefIdx) {
1148 return error(
"expected an integer literal after 'tied-def'");
1149 if (getUnsigned(TiedDefIdx))
1160 for (
unsigned I = 0,
E = Operands.
size();
I !=
E; ++
I) {
1161 if (!Operands[
I].TiedDefIdx)
1165 unsigned DefIdx = Operands[
I].TiedDefIdx.getValue();
1167 return error(Operands[
I].Begin,
1168 Twine(
"use of invalid tied-def operand index '" +
1169 Twine(DefIdx) +
"'; instruction has only ") +
1171 const auto &DefOperand = Operands[DefIdx].Operand;
1172 if (!DefOperand.isReg() || !DefOperand.isDef())
1174 return error(Operands[
I].Begin,
1175 Twine(
"use of invalid tied-def operand index '") +
1176 Twine(DefIdx) +
"'; the operand #" +
Twine(DefIdx) +
1177 " isn't a defined register");
1179 for (
const auto &TiedPair : TiedRegisterPairs) {
1180 if (TiedPair.first == DefIdx)
1181 return error(Operands[
I].Begin,
1182 Twine(
"the tied-def operand #") +
Twine(DefIdx) +
1183 " is already tied with another register operand");
1185 TiedRegisterPairs.push_back(std::make_pair(DefIdx,
I));
1189 for (
const auto &TiedPair : TiedRegisterPairs)
1198 while (Token.isRegisterFlag()) {
1199 if (parseRegisterFlag(Flags))
1202 if (!Token.isRegister())
1203 return error(
"expected a register after register flags");
1206 if (parseRegister(Reg, RegInfo))
1209 unsigned SubReg = 0;
1211 if (parseSubRegisterIndex(SubReg))
1214 return error(
"subregister index expects a virtual register");
1218 return error(
"register class specification expects a virtual register");
1220 if (parseRegisterClassOrBank(*RegInfo))
1227 if (!parseRegisterTiedDefIndex(Idx))
1232 if (parseLowLevelType(Token.location(), Ty))
1233 return error(
"expected tied-def or low-level type after '('");
1239 return error(
"inconsistent type for generic virtual register");
1247 return error(
"unexpected type on physical register");
1250 if (parseLowLevelType(Token.location(), Ty))
1257 return error(
"inconsistent type for generic virtual register");
1266 return error(
"generic virtual registers must have a type");
1279 const APSInt &Int = Token.integerValue();
1280 if (Int.getMinSignedBits() > 64)
1281 return error(
"integer literal is too large to be an immediate operand");
1289 auto Source = StringValue.
str();
1299 if (parseIRConstant(Loc,
StringRef(Loc, Token.range().end() - Loc), C))
1306 if (Token.range().front() ==
's' || Token.range().front() ==
'p') {
1309 return error(
"expected integers after 's'/'p' type character");
1312 if (Token.range().front() ==
's') {
1316 }
else if (Token.range().front() ==
'p') {
1318 unsigned AS =
APSInt(Token.range().drop_front()).getZExtValue();
1327 "expected sN, pA, <M x sN>, or <M x pA> for GlobalISel type");
1331 return error(Loc,
"expected <M x sN> or <M x pA> for vector type");
1332 uint64_t NumElements = Token.integerValue().getZExtValue();
1336 return error(Loc,
"expected <M x sN> or <M x pA> for vector type");
1339 if (Token.range().front() !=
's' && Token.range().front() !=
'p')
1340 return error(Loc,
"expected <M x sN> or <M x pA> for vector type");
1343 return error(
"expected integers after 's'/'p' type character");
1345 if (Token.range().front() ==
's')
1347 else if (Token.range().front() ==
'p') {
1349 unsigned AS =
APSInt(Token.range().drop_front()).getZExtValue();
1352 return error(Loc,
"expected <M x sN> or <M x pA> for vector type");
1356 return error(Loc,
"expected <M x sN> or <M x pA> for vector type");
1363 bool MIParser::parseTypedImmediateOperand(
MachineOperand &Dest) {
1366 if (TypeStr.front() !=
'i' && TypeStr.front() !=
's' &&
1367 TypeStr.front() !=
'p')
1369 "a typed immediate operand should start with one of 'i', 's', or 'p'");
1372 return error(
"expected integers after 'i'/'s'/'p' type character");
1374 auto Loc = Token.location();
1378 !(Token.range() ==
"true" || Token.range() ==
"false"))
1379 return error(
"expected an integer literal");
1382 if (parseIRConstant(Loc, C))
1389 auto Loc = Token.location();
1393 return error(
"expected a floating point literal");
1395 if (parseIRConstant(Loc, C))
1401 bool MIParser::getUnsigned(
unsigned &
Result) {
1402 if (Token.hasIntegerValue()) {
1404 uint64_t Val64 = Token.integerValue().getLimitedValue(Limit);
1406 return error(
"expected 32-bit integer (too large)");
1415 return error(
"expected 32-bit integer (too large)");
1426 if (getUnsigned(Number))
1428 auto MBBInfo = PFS.
MBBSlots.find(Number);
1430 return error(
Twine(
"use of undefined machine basic block #") +
1432 MBB = MBBInfo->second;
1435 if (!Token.stringValue().empty() && Token.stringValue() != MBB->
getName())
1436 return error(
Twine(
"the name of machine basic block #") +
Twine(Number) +
1437 " isn't '" + Token.stringValue() +
"'");
1450 bool MIParser::parseStackFrameIndex(
int &FI) {
1453 if (getUnsigned(ID))
1457 return error(
Twine(
"use of undefined stack object '%stack.") +
Twine(ID) +
1460 if (
const auto *Alloca =
1462 Name = Alloca->getName();
1463 if (!Token.stringValue().empty() && Token.stringValue() !=
Name)
1464 return error(
Twine(
"the name of the stack object '%stack.") +
Twine(ID) +
1465 "' isn't '" + Token.stringValue() +
"'");
1467 FI = ObjectInfo->second;
1473 if (parseStackFrameIndex(FI))
1479 bool MIParser::parseFixedStackFrameIndex(
int &FI) {
1482 if (getUnsigned(ID))
1486 return error(
Twine(
"use of undefined fixed stack object '%fixed-stack.") +
1489 FI = ObjectInfo->second;
1493 bool MIParser::parseFixedStackObjectOperand(
MachineOperand &Dest) {
1495 if (parseFixedStackFrameIndex(FI))
1501 bool MIParser::parseGlobalValue(
GlobalValue *&GV) {
1502 switch (Token.kind()) {
1507 return error(
Twine(
"use of undefined global value '") + Token.range() +
1513 if (getUnsigned(GVIdx))
1516 return error(
Twine(
"use of undefined global value '@") +
Twine(GVIdx) +
1529 if (parseGlobalValue(GV))
1533 if (parseOperandsOffset(Dest))
1538 bool MIParser::parseConstantPoolIndexOperand(
MachineOperand &Dest) {
1541 if (getUnsigned(ID))
1545 return error(
"use of undefined constant '%const." +
Twine(ID) +
"'");
1548 if (parseOperandsOffset(Dest))
1553 bool MIParser::parseJumpTableIndexOperand(
MachineOperand &Dest) {
1556 if (getUnsigned(ID))
1560 return error(
"use of undefined jump table '%jump-table." +
Twine(ID) +
"'");
1566 bool MIParser::parseExternalSymbolOperand(
MachineOperand &Dest) {
1571 if (parseOperandsOffset(Dest))
1576 bool MIParser::parseSubRegisterIndexOperand(
MachineOperand &Dest) {
1579 unsigned SubRegIndex = getSubRegIndex(Token.stringValue());
1580 if (SubRegIndex == 0)
1581 return error(
Twine(
"unknown subregister index '") + Name +
"'");
1590 auto Loc = Token.location();
1593 return error(
"expected metadata id after '!'");
1595 if (getUnsigned(ID))
1599 return error(Loc,
"use of undefined metadata '!" +
Twine(ID) +
"'");
1601 Node = NodeInfo->second.
get();
1605 bool MIParser::parseDIExpression(
MDNode *&Expr) {
1623 return error(
Twine(
"invalid DWARF op '") + Token.stringValue() +
"'");
1627 Token.integerValue().isSigned())
1628 return error(
"expected unsigned integer");
1630 auto &U = Token.integerValue();
1652 if (parseDIExpression(Node))
1659 bool MIParser::parseCFIOffset(
int &
Offset) {
1661 return error(
"expected a cfi offset");
1662 if (Token.integerValue().getMinSignedBits() > 32)
1663 return error(
"expected a 32 bit integer (the cfi offset is too large)");
1664 Offset = (int)Token.integerValue().getExtValue();
1669 bool MIParser::parseCFIRegister(
unsigned &Reg) {
1671 return error(
"expected a cfi register");
1673 if (parseNamedRegister(LLVMReg))
1676 assert(
TRI &&
"Expected target register info");
1677 int DwarfReg =
TRI->getDwarfRegNum(LLVMReg,
true);
1679 return error(
"invalid DWARF register");
1685 bool MIParser::parseCFIEscapeValues(std::string &Values) {
1688 return error(
"expected a hexadecimal literal");
1690 if (getUnsigned(Value))
1692 if (Value > UINT8_MAX)
1693 return error(
"expected a 8-bit integer (too large)");
1694 Values.push_back(static_cast<uint8_t>(Value));
1701 auto Kind = Token.kind();
1708 if (parseCFIRegister(Reg))
1714 parseCFIOffset(Offset))
1721 parseCFIOffset(Offset))
1727 if (parseCFIRegister(Reg))
1733 if (parseCFIOffset(Offset))
1740 if (parseCFIOffset(Offset))
1747 parseCFIOffset(Offset))
1757 if (parseCFIRegister(Reg))
1765 if (parseCFIRegister(Reg))
1772 parseCFIRegister(Reg2))
1784 if (parseCFIEscapeValues(Values))
1798 switch (Token.kind()) {
1800 BB = dyn_cast_or_null<BasicBlock>(
1803 return error(
Twine(
"use of undefined IR block '") + Token.range() +
"'");
1807 unsigned SlotNumber = 0;
1808 if (getUnsigned(SlotNumber))
1810 BB =
const_cast<BasicBlock *
>(getIRBlock(SlotNumber, F));
1812 return error(
Twine(
"use of undefined IR block '%ir-block.") +
1813 Twine(SlotNumber) +
"'");
1829 return error(
"expected a global value");
1831 if (parseGlobalValue(GV))
1835 return error(
"expected an IR function reference");
1841 return error(
"expected an IR block reference");
1842 if (parseIRBlock(BB, *F))
1848 if (parseOperandsOffset(Dest))
1857 return error(
"expected syntax intrinsic(@llvm.whatever)");
1860 return error(
"expected syntax intrinsic(@llvm.whatever)");
1862 std::string
Name = Token.stringValue();
1866 return error(
"expected ')' to terminate intrinsic name");
1876 return error(
"unknown intrinsic name");
1888 return error(
"expected syntax intpred(whatever) or floatpred(whatever");
1891 return error(
"whatever");
1914 return error(
"invalid floating-point predicate");
1929 return error(
"invalid integer predicate");
1935 return error(
"predicate should be terminated by ')'.");
1946 return error(
"expected the name of the target index");
1948 if (getTargetIndex(Token.stringValue(),
Index))
1949 return error(
"use of undefined target index '" + Token.stringValue() +
"'");
1954 if (parseOperandsOffset(Dest))
1959 bool MIParser::parseCustomRegisterMaskOperand(
MachineOperand &Dest) {
1960 assert(Token.stringValue() ==
"CustomRegMask" &&
"Expected a custom RegMask");
1968 return error(
"expected a named register");
1970 if (parseNamedRegister(Reg))
1973 Mask[Reg / 32] |= 1U << (Reg % 32);
1986 bool MIParser::parseLiveoutRegisterMaskOperand(
MachineOperand &Dest) {
1994 return error(
"expected a named register");
1996 if (parseNamedRegister(Reg))
1999 Mask[Reg / 32] |= 1U << (Reg % 32);
2013 switch (Token.kind()) {
2028 return parseRegisterOperand(Dest, TiedDefIdx);
2030 return parseImmediateOperand(Dest);
2037 return parseFPImmediateOperand(Dest);
2039 return parseMBBOperand(Dest);
2041 return parseStackObjectOperand(Dest);
2043 return parseFixedStackObjectOperand(Dest);
2046 return parseGlobalAddressOperand(Dest);
2048 return parseConstantPoolIndexOperand(Dest);
2050 return parseJumpTableIndexOperand(Dest);
2052 return parseExternalSymbolOperand(Dest);
2054 return parseSubRegisterIndexOperand(Dest);
2057 return parseMetadataOperand(Dest);
2072 return parseCFIOperand(Dest);
2074 return parseBlockAddressOperand(Dest);
2076 return parseIntrinsicOperand(Dest);
2078 return parseTargetIndexOperand(Dest);
2080 return parseLiveoutRegisterMaskOperand(Dest);
2083 return parsePredicateOperand(Dest);
2087 if (
const auto *RegMask = getRegMask(Token.stringValue())) {
2091 }
else if (Token.stringValue() ==
"CustomRegMask") {
2092 return parseCustomRegisterMaskOperand(Dest);
2094 return parseTypedImmediateOperand(Dest);
2097 return error(
"expected a machine operand");
2102 bool MIParser::parseMachineOperandAndTargetFlags(
2105 bool HasTargetFlags =
false;
2107 HasTargetFlags =
true;
2112 return error(
"expected the name of the target flag");
2113 if (getDirectTargetFlag(Token.stringValue(), TF)) {
2114 if (getBitmaskTargetFlag(Token.stringValue(), TF))
2115 return error(
"use of undefined target flag '" + Token.stringValue() +
2122 return error(
"expected the name of the target flag");
2123 unsigned BitFlag = 0;
2124 if (getBitmaskTargetFlag(Token.stringValue(), BitFlag))
2125 return error(
"use of undefined target flag '" + Token.stringValue() +
2134 auto Loc = Token.location();
2135 if (parseMachineOperand(Dest, TiedDefIdx))
2137 if (!HasTargetFlags)
2140 return error(Loc,
"register operands can't have target flags");
2145 bool MIParser::parseOffset(int64_t &
Offset) {
2152 return error(
"expected an integer literal after '" + Sign +
"'");
2153 if (Token.integerValue().getMinSignedBits() > 64)
2154 return error(
"expected 64-bit integer (too large)");
2155 Offset = Token.integerValue().getExtValue();
2162 bool MIParser::parseAlignment(
unsigned &Alignment) {
2166 return error(
"expected an integer literal after 'align'");
2167 if (getUnsigned(Alignment))
2173 bool MIParser::parseAddrspace(
unsigned &Addrspace) {
2177 return error(
"expected an integer literal after 'addrspace'");
2178 if (getUnsigned(Addrspace))
2186 if (parseOffset(Offset))
2192 bool MIParser::parseIRValue(
const Value *&V) {
2193 switch (Token.kind()) {
2199 unsigned SlotNumber = 0;
2200 if (getUnsigned(SlotNumber))
2202 V = getIRValue(SlotNumber);
2208 if (parseGlobalValue(GV))
2215 if (parseIRConstant(Token.location(), Token.stringValue(),
C))
2224 return error(
Twine(
"use of undefined IR value '") + Token.range() +
"'");
2228 bool MIParser::getUint64(uint64_t &Result) {
2229 if (Token.hasIntegerValue()) {
2230 if (Token.integerValue().getActiveBits() > 64)
2231 return error(
"expected 64-bit integer (too large)");
2232 Result = Token.integerValue().getZExtValue();
2240 return error(
"expected 64-bit integer (too large)");
2247 bool MIParser::getHexUint(
APInt &Result) {
2250 assert(S[0] ==
'0' && tolower(S[1]) ==
'x');
2252 if (!isxdigit(S[2]))
2259 unsigned NumBits = (A == 0) ? 32 : A.getActiveBits();
2265 const auto OldFlags = Flags;
2266 switch (Token.kind()) {
2281 if (getMMOTargetFlag(Token.stringValue(), TF))
2282 return error(
"use of undefined target MMO flag '" + Token.stringValue() +
2290 if (OldFlags == Flags)
2293 return error(
"duplicate '" + Token.stringValue() +
"' memory operand flag");
2299 switch (Token.kind()) {
2314 if (parseFixedStackFrameIndex(FI))
2322 if (parseStackFrameIndex(FI))
2330 switch (Token.kind()) {
2334 if (parseGlobalValue(GV))
2345 "expected a global value or an external symbol after 'call-entry'");
2361 if (parseMemoryPseudoSourceValue(PSV))
2364 if (parseOffset(Offset))
2373 return error(
"expected an IR value reference");
2374 const Value *V =
nullptr;
2375 if (parseIRValue(V))
2378 return error(
"expected a pointer IR value");
2381 if (parseOffset(Offset))
2393 return error(
"expected '(' in syncscope");
2396 if (parseStringConstant(SSN))
2401 return error(
"expected ')' in syncscope");
2407 bool MIParser::parseOptionalAtomicOrdering(
AtomicOrdering &Order) {
2426 return error(
"expected an atomic scope, ordering or a size integer literal");
2433 while (Token.isMemoryOperandFlag()) {
2434 if (parseMemoryOperandFlag(Flags))
2438 (Token.stringValue() !=
"load" && Token.stringValue() !=
"store"))
2439 return error(
"expected 'load' or 'store' memory operation");
2440 if (Token.stringValue() ==
"load")
2459 if (parseOptionalAtomicOrdering(Order))
2462 if (parseOptionalAtomicOrdering(FailureOrder))
2466 return error(
"expected the size integer literal after memory operation");
2468 if (getUint64(Size))
2479 if (Token.stringValue() !=
Word)
2480 return error(
Twine(
"expected '") + Word +
"'");
2483 if (parseMachinePointerInfo(Ptr))
2486 unsigned BaseAlignment =
Size;
2490 switch (Token.kind()) {
2492 if (parseAlignment(BaseAlignment))
2521 return error(
"expected 'align' or '!tbaa' or '!alias.scope' or " 2522 "'!noalias' or '!range'");
2528 SSID, Order, FailureOrder);
2532 void MIParser::initNames2InstrOpCodes() {
2533 if (!Names2InstrOpCodes.empty())
2536 assert(
TII &&
"Expected target instruction info");
2537 for (
unsigned I = 0,
E =
TII->getNumOpcodes();
I <
E; ++
I)
2538 Names2InstrOpCodes.insert(std::make_pair(
StringRef(
TII->getName(
I)),
I));
2541 bool MIParser::parseInstrName(
StringRef InstrName,
unsigned &OpCode) {
2542 initNames2InstrOpCodes();
2543 auto InstrInfo = Names2InstrOpCodes.find(InstrName);
2544 if (InstrInfo == Names2InstrOpCodes.end())
2546 OpCode = InstrInfo->getValue();
2550 void MIParser::initNames2Regs() {
2551 if (!Names2Regs.empty())
2554 Names2Regs.insert(std::make_pair(
"noreg", 0));
2556 assert(
TRI &&
"Expected target register info");
2557 for (
unsigned I = 0,
E =
TRI->getNumRegs();
I <
E; ++
I) {
2559 Names2Regs.insert(std::make_pair(
StringRef(
TRI->getName(
I)).lower(),
I))
2562 assert(WasInserted &&
"Expected registers to be unique case-insensitively");
2566 bool MIParser::getRegisterByName(
StringRef RegName,
unsigned &Reg) {
2568 auto RegInfo = Names2Regs.find(RegName);
2569 if (RegInfo == Names2Regs.end())
2571 Reg = RegInfo->getValue();
2575 void MIParser::initNames2RegMasks() {
2576 if (!Names2RegMasks.empty())
2579 assert(
TRI &&
"Expected target register info");
2583 for (
size_t I = 0,
E = RegMasks.
size();
I <
E; ++
I)
2584 Names2RegMasks.insert(
2585 std::make_pair(
StringRef(RegMaskNames[
I]).lower(), RegMasks[I]));
2589 initNames2RegMasks();
2590 auto RegMaskInfo = Names2RegMasks.find(Identifier);
2591 if (RegMaskInfo == Names2RegMasks.end())
2593 return RegMaskInfo->getValue();
2596 void MIParser::initNames2SubRegIndices() {
2597 if (!Names2SubRegIndices.empty())
2601 Names2SubRegIndices.insert(
2606 initNames2SubRegIndices();
2607 auto SubRegInfo = Names2SubRegIndices.find(Name);
2608 if (SubRegInfo == Names2SubRegIndices.end())
2610 return SubRegInfo->getValue();
2618 for (
auto &BB : F) {
2621 int Slot = MST.getLocalSlot(&BB);
2624 Slots2BasicBlocks.
insert(std::make_pair(
unsigned(Slot), &BB));
2631 auto BlockInfo = Slots2BasicBlocks.
find(Slot);
2632 if (BlockInfo == Slots2BasicBlocks.
end())
2634 return BlockInfo->second;
2637 const BasicBlock *MIParser::getIRBlock(
unsigned Slot) {
2638 if (Slots2BasicBlocks.empty())
2645 return getIRBlock(Slot);
2656 Slots2Values.
insert(std::make_pair(
unsigned(Slot), V));
2664 for (
const auto &
Arg : F.
args())
2666 for (
const auto &BB : F) {
2668 for (
const auto &
I : BB)
2673 const Value *MIParser::getIRValue(
unsigned Slot) {
2674 if (Slots2Values.empty())
2676 auto ValueInfo = Slots2Values.find(Slot);
2682 void MIParser::initNames2TargetIndices() {
2683 if (!Names2TargetIndices.empty())
2686 assert(
TII &&
"Expected target instruction info");
2687 auto Indices =
TII->getSerializableTargetIndices();
2688 for (
const auto &
I : Indices)
2689 Names2TargetIndices.insert(std::make_pair(
StringRef(
I.second),
I.first));
2693 initNames2TargetIndices();
2694 auto IndexInfo = Names2TargetIndices.find(Name);
2695 if (IndexInfo == Names2TargetIndices.end())
2697 Index = IndexInfo->second;
2701 void MIParser::initNames2DirectTargetFlags() {
2702 if (!Names2DirectTargetFlags.empty())
2705 assert(
TII &&
"Expected target instruction info");
2707 for (
const auto &
I : Flags)
2708 Names2DirectTargetFlags.insert(
2712 bool MIParser::getDirectTargetFlag(
StringRef Name,
unsigned &
Flag) {
2713 initNames2DirectTargetFlags();
2714 auto FlagInfo = Names2DirectTargetFlags.find(Name);
2715 if (FlagInfo == Names2DirectTargetFlags.end())
2717 Flag = FlagInfo->second;
2721 void MIParser::initNames2BitmaskTargetFlags() {
2722 if (!Names2BitmaskTargetFlags.empty())
2725 assert(
TII &&
"Expected target instruction info");
2727 for (
const auto &
I : Flags)
2728 Names2BitmaskTargetFlags.insert(
2732 bool MIParser::getBitmaskTargetFlag(
StringRef Name,
unsigned &Flag) {
2733 initNames2BitmaskTargetFlags();
2734 auto FlagInfo = Names2BitmaskTargetFlags.find(Name);
2735 if (FlagInfo == Names2BitmaskTargetFlags.end())
2737 Flag = FlagInfo->second;
2741 void MIParser::initNames2MMOTargetFlags() {
2742 if (!Names2MMOTargetFlags.empty())
2745 assert(
TII &&
"Expected target instruction info");
2746 auto Flags =
TII->getSerializableMachineMemOperandTargetFlags();
2747 for (
const auto &
I : Flags)
2748 Names2MMOTargetFlags.insert(
2752 bool MIParser::getMMOTargetFlag(
StringRef Name,
2754 initNames2MMOTargetFlags();
2755 auto FlagInfo = Names2MMOTargetFlags.find(Name);
2756 if (FlagInfo == Names2MMOTargetFlags.end())
2758 Flag = FlagInfo->second;
2762 bool MIParser::parseStringConstant(std::string &Result) {
2764 return error(
"expected string constant");
2765 Result = Token.stringValue();
2773 return MIParser(PFS, Error, Src).parseBasicBlockDefinitions(PFS.
MBBSlots);
2778 return MIParser(PFS, Error, Src).parseBasicBlocks();
2784 return MIParser(PFS, Error, Src).parseStandaloneMBB(MBB);
2790 return MIParser(PFS, Error, Src).parseStandaloneRegister(Reg);
2796 return MIParser(PFS, Error, Src).parseStandaloneNamedRegister(Reg);
2802 return MIParser(PFS, Error, Src).parseStandaloneVirtualRegister(Info);
2808 return MIParser(PFS, Error, Src).parseStandaloneStackObject(FI);
2813 return MIParser(PFS, Error, Src).parseStandaloneMDNode(Node);
bool isFPPredicate() const
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
Return an array that contains the direct target flag values and their names.
virtual StringRef getBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
union llvm::VRegInfo::@323 D
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
bool parseMachineBasicBlockDefinitions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine basic block definitions, and skip the machine instructions.
static void initSlots2BasicBlocks(const Function &F, DenseMap< unsigned, const BasicBlock *> &Slots2BasicBlocks)
A common definition of LaneBitmask for use in TableGen and CodeGen.
uint64_t getZExtValue() const
Get zero extended value.
static MachineOperand CreateCImm(const ConstantInt *CI)
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
DenseMap< unsigned, unsigned > JumpTableSlots
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
const T & back() const
back - Get the last element.
MDNode * Scope
The tag for alias scope specification (used with noalias).
Atomic ordering constants.
DenseMap< unsigned, unsigned > ConstantPoolSlots
Compute iterated dominance frontiers using a linear time algorithm.
MDNode * TBAA
The tag for type-based alias analysis.
Constant * parseConstantValue(StringRef Asm, SMDiagnostic &Err, const Module &M, const SlotMapping *Slots=nullptr)
Parse a type and a constant value in the given string.
void setTargetFlags(unsigned F)
A Module instance is used to store all the information related to an LLVM module. ...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
static BranchProbability getRaw(uint32_t N)
static MCCFIInstruction createRememberState(MCSymbol *L)
.cfi_remember_state Save all current rules for all registers.
const MCPhysReg * getImplicitUses() const
Return a list of registers that are potentially read by any instance of this machine instruction...
static MachineOperand CreateJTI(unsigned Idx, unsigned char TargetFlags=0)
Describe properties that are true of each instruction in the target description file.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
SyncScope::ID getOrInsertSyncScopeID(StringRef SSN)
getOrInsertSyncScopeID - Maps synchronization scope name to synchronization scope ID...
int getLocalSlot(const Value *V)
Return the slot number of the specified local value.
0 1 0 0 True if ordered and less than
ArrayRef< std::pair< unsigned, const char * > > getSerializableBitmaskMachineOperandTargetFlags() const override
Return an array that contains the bitmask target flag values and their names.
iterator find(StringRef Key)
DenseMap< unsigned, int > StackObjectSlots
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
1 1 1 0 True if unordered or not equal
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 getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
unsigned const TargetRegisterInfo * TRI
DenseMap< unsigned, VRegInfo * > VRegInfos
Manage lifetime of a slot tracker for printing IR.
bool parseMBBReference(PerFunctionMIParsingState &PFS, MachineBasicBlock *&MBB, StringRef Src, SMDiagnostic &Error)
const TargetRegisterClass * RC
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, const DebugLoc &DL, bool NoImp=false)
CreateMachineInstr - Allocate a new MachineInstr.
StringRef lexMIToken(StringRef Source, MIToken &Token, function_ref< void(StringRef::iterator, const Twine &)> ErrorCallback)
Consume a single machine instruction token in the given source and return the remaining source string...
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment)
.cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but Offset is a relative value that is added/subt...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
static MachineOperand CreateIntrinsicID(Intrinsic::ID ID)
unsigned getBitWidth() const
Return the number of bits in the APInt.
static MachineOperand CreateReg(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register)
.cfi_undefined From now on the previous value of Register can't be restored anymore.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
const char * getRegClassName(const TargetRegisterClass *Class) const
Returns the name of the register class.
1 0 0 1 True if unordered or equal
void guessSuccessors(const MachineBasicBlock &MBB, SmallVectorImpl< MachineBasicBlock *> &Result, bool &IsFallthrough)
Determine a possible list of successors of a basic block based on the basic block machine operand bei...
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
std::map< unsigned, TrackingMDNodeRef > MetadataNodes
A description of a memory reference used in the backend.
std::string toString(Error E)
Write all error messages (if any) in E to a string.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const HexagonInstrInfo * TII
static const BasicBlock * getIRBlockFromSlot(unsigned Slot, const DenseMap< unsigned, const BasicBlock *> &Slots2BasicBlocks)
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
VRegInfo & getVRegInfoNamed(StringRef RegName)
support::ulittle32_t Word
static constexpr LaneBitmask getAll()
0 1 0 1 True if ordered and less than or equal
const Name2RegBankMap & Names2RegBanks
The memory access is dereferenceable (i.e., doesn't trap).
static MachineOperand CreateRegMask(const uint32_t *Mask)
CreateRegMask - Creates a register mask operand referencing Mask.
static MachineOperand CreateRegLiveOut(const uint32_t *Mask)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE R Default(T Value)
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
This file implements a class to represent arbitrary precision integral constant values and operations...
AtomicOrdering
Atomic ordering for LLVM's memory model.
DenseMap< unsigned, int > FixedStackObjectSlots
static std::string getRegisterName(const TargetRegisterInfo *TRI, unsigned Reg)
const MemoryBuffer * getMemoryBuffer(unsigned i) const
Type * getType() const
All values are typed, get the type of this value.
PseudoSourceValueManager & getPSVManager() const
virtual unsigned lookupName(const char *Name, unsigned Len) const =0
Look up target intrinsic by name.
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type. ...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const char * getSubRegIndexName(unsigned SubIdx) const
Return the human-readable symbolic target-specific name for the specified SubRegIndex.
virtual const TargetInstrInfo * getInstrInfo() const
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
bool parseVirtualRegisterReference(PerFunctionMIParsingState &PFS, VRegInfo *&Info, StringRef Src, SMDiagnostic &Error)
static MachineOperand CreatePredicate(unsigned Pred)
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
const PseudoSourceValue * getFixedStack(int FI)
Return a pseudo source value referencing a fixed stack frame entry, e.g., a spill slot...
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
void normalizeSuccProbs()
Normalize probabilities of all successors so that the sum of them becomes one.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
const char * getName(unsigned RegNo) const
Return the human-readable symbolic target-specific name for the specified physical register...
Flag
These should be considered private to the implementation of the MCInstrDesc class.
iterator find(const_arg_type_t< KeyT > Val)
unsigned getMainFileID() const
bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
The memory access is volatile.
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register)
.cfi_same_value Current value of Register is the same as in the previous frame.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
A switch()-like statement whose cases are string literals.
bool parseStackObjectReference(PerFunctionMIParsingState &PFS, int &FI, StringRef Src, SMDiagnostic &Error)
const MCPhysReg * getImplicitDefs() const
Return a list of registers that are potentially written by any instance of this machine instruction...
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
unsigned const MachineRegisterInfo * MRI
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
static const char * printImplicitRegisterFlag(const MachineOperand &MO)
static MCCFIInstruction createDefCfa(MCSymbol *L, unsigned Register, int Offset)
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it...
static Intrinsic::ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
static MachineOperand CreateCPI(unsigned Idx, int Offset, unsigned char TargetFlags=0)
LLVM Basic Block Representation.
const PseudoSourceValue * getExternalSymbolCallEntry(const char *ES)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
This is an important class for using LLVM in a threaded context.
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
static MachineOperand CreateFPImm(const ConstantFP *CFP)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
size_t size() const
size - Get the array size.
static MCCFIInstruction createWindowSave(MCSymbol *L)
.cfi_window_save SPARC register window is saved.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isPointerTy() const
True if this is an instance of PointerType.
StringMap< VRegInfo * > VRegInfosNamed
unsigned getOperationEncoding(StringRef OperationEncodingString)
const MCPhysReg * ImplicitDefs
void setType(unsigned VReg, LLT Ty)
Set the low-level type of VReg to Ty.
BumpPtrAllocator Allocator
static MachineOperand CreateBA(const BlockAddress *BA, int64_t Offset, unsigned char TargetFlags=0)
bool parseNamedRegisterReference(PerFunctionMIParsingState &PFS, unsigned &Reg, StringRef Src, SMDiagnostic &Error)
void setFlag(MIFlag Flag)
Set a MI flag.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_rel_offset Previous value of Register is saved at offset Offset from the current CFA register...
static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset, unsigned char TargetFlags=0)
static MachineOperand CreateTargetIndex(unsigned Idx, int64_t Offset, unsigned char TargetFlags=0)
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register)
.cfi_restore says that the rule for Register is now the same as it was at the beginning of the functi...
0 1 1 1 True if ordered (no nans)
The memory access is non-temporal.
llvm::Expected< Value > parse(llvm::StringRef JSON)
Parses the provided JSON source, or returns a ParseError.
std::vector< GlobalValue * > GlobalValues
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
void setOffset(int64_t Offset)
1 1 1 1 Always true (always folded)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
void incorporateFunction(const Function &F)
Incorporate the given function.
const SlotMapping & IRSlots
static MCCFIInstruction createRestoreState(MCSymbol *L)
.cfi_restore_state Restore the previously saved state.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This class contains a discriminated union of information about pointers in memory operands...
const char * createExternalSymbolName(StringRef Name)
Allocate a string and populate it with the given external symbol name.
1 1 0 1 True if unordered, less than, or equal
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None) const
Return an SMDiagnostic at the specified location with the specified string.
bool parseMachineInstructions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine instructions.
TargetIntrinsicInfo - Interface to description of machine instruction set.
Struct that holds a reference to a particular GUID in a global value summary.
The memory access writes data.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
0 0 1 0 True if ordered and greater than
const Name2RegClassMap & Names2RegClasses
unsigned createIncompleteVirtualRegister(StringRef Name="")
Creates a new virtual register that has no register class, register bank or size assigned yet...
static MachineOperand CreateMetadata(const MDNode *Meta)
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
void setFlags(unsigned flags)
enum llvm::VRegInfo::uint8_t Kind
MachineOperand class - Representation of each machine instruction operand.
1 1 0 0 True if unordered or less than
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
static bool isImplicitOperandIn(const MachineOperand &ImplicitOperand, ArrayRef< ParsedMachineOperand > Operands)
Return true if the parsed machine operands contain a given machine operand.
StringRef getMessage() const
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
MDNode * NoAlias
The tag specifying the noalias scope.
uint32_t * allocateRegMask()
Allocate and initialize a register mask with NumRegister bits.
This class implements the register bank concept.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
ValueSymbolTable * getValueSymbolTable()
getSymbolTable() - Return the symbol table if any, otherwise nullptr.
bool isIntPredicate() const
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Class for arbitrary precision integers.
Special value supplied for machine level alias analysis.
const PseudoSourceValue * getJumpTable()
Return a pseudo source value referencing a jump table.
const PseudoSourceValue * getGlobalValueCallEntry(const GlobalValue *GV)
static MachineOperand CreateES(const char *SymName, unsigned char TargetFlags=0)
const PseudoSourceValue * getGOT()
Return a pseudo source value referencing the global offset table (or something the like)...
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(StringLiteral S, T Value)
This struct contains the mappings from the slot numbers to unnamed metadata nodes, global values and types.
bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node, StringRef Src, SMDiagnostic &Error)
static SMLoc getFromPointer(const char *Ptr)
Flags
Flags values. These may be or'd together.
amdgpu Simplify well known AMD library false Value Value * Arg
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
bool Explicit
VReg was explicitly specified in the .mir file.
Representation of each machine instruction.
const AllocaInst * getObjectAllocation(int ObjectIdx) const
Return the underlying Alloca of the specified stack object if it exists.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
const char * getBufferEnd() const
static MachineOperand CreateMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
LLVM_NODISCARD bool empty() const
unsigned greater or equal
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
virtual const TargetIntrinsicInfo * getIntrinsicInfo() const
If intrinsic information is available, return it. If not, return null.
static MachineOperand CreateCFIIndex(unsigned CFIIndex)
static MachineOperand CreateImm(int64_t Val)
VRegInfo & getVRegInfo(unsigned Num)
The memory access always returns the same value (or traps).
bool isCall() const
Return true if the instruction is a call.
0 1 1 0 True if ordered and operands are unequal
DenseMap< unsigned, MachineBasicBlock * > MBBSlots
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getNumSubRegIndices() const
Return the number of sub-register indices understood by the target.
1 0 1 0 True if unordered or greater than
const char * getBufferStart() const
Value * lookup(StringRef Name) const
This method finds the value with the given Name in the the symbol table.
std::string str() const
Return the twine contents as a std::string.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Synchronized with respect to all concurrently executing threads.
const PseudoSourceValue * getStack()
Return a pseudo source value referencing the area below the stack frame of a function, e.g., the argument space.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void insert(iterator MBBI, MachineBasicBlock *MBB)
0 0 0 1 True if ordered and equal
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
static LLT pointer(uint16_t AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space (defaulting to 0).
A token produced by the machine instruction lexer.
1 0 1 1 True if unordered, greater than, or equal
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
Lightweight error class with error context and mandatory checking.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
StringRef - Represent a constant reference to a string, i.e.
static LLT vector(uint16_t NumElements, unsigned ScalarSizeInBits)
Get a low-level vector of some number of elements and element width.
const RegisterBank * RegBank
Represents a location in source code.
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals)
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
OutputIt copy(R &&Range, OutputIt Out)
bool parseRegisterReference(PerFunctionMIParsingState &PFS, unsigned &Reg, StringRef Src, SMDiagnostic &Error)
0 0 1 1 True if ordered and greater than or equal
static void mapValueToSlot(const Value *V, ModuleSlotTracker &MST, DenseMap< unsigned, const Value *> &Slots2Values)
static void initSlots2Values(const Function &F, DenseMap< unsigned, const Value *> &Slots2Values)
Creates the mapping from slot numbers to function's unnamed IR values.
MachineInstr::mmo_iterator allocateMemRefsArray(unsigned long Num)
allocateMemRefsArray - Allocate an array to hold MachineMemOperand pointers.
static MachineOperand CreateFI(int Idx)
const PseudoSourceValue * getConstantPool()
Return a pseudo source value referencing the constant pool.
void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd)
Assign this MachineInstr's memory reference descriptor list.
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2)
.cfi_register Previous value of Register1 is saved in register Register2.
iterator_range< arg_iterator > args()
0 0 0 0 Always false (always folded)
bool empty() const
empty - Check if the array is empty.
const MCPhysReg * ImplicitUses
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
PerFunctionMIParsingState(MachineFunction &MF, SourceMgr &SM, const SlotMapping &IRSlots, const Name2RegClassMap &Names2RegClasses, const Name2RegBankMap &Names2RegBanks)
void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.