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;
105 struct ParsedMachineOperand {
113 : Operand(Operand), Begin(Begin), End(End), TiedDefIdx(TiedDefIdx) {
116 "Only used register operands can be tied");
153 void lex(
unsigned SkipChar = 0);
167 bool parseBasicBlocks();
170 bool parseStandaloneNamedRegister(
unsigned &
Reg);
171 bool parseStandaloneVirtualRegister(
VRegInfo *&Info);
172 bool parseStandaloneRegister(
unsigned &
Reg);
173 bool parseStandaloneStackObject(
int &FI);
174 bool parseStandaloneMDNode(
MDNode *&Node);
183 bool parseNamedRegister(
unsigned &
Reg);
184 bool parseVirtualRegister(
VRegInfo *&Info);
186 bool parseRegisterFlag(
unsigned &
Flags);
187 bool parseRegisterClassOrBank(
VRegInfo &RegInfo);
188 bool parseSubRegisterIndex(
unsigned &
SubReg);
189 bool parseRegisterTiedDefIndex(
unsigned &TiedDefIdx);
201 bool parseStackFrameIndex(
int &FI);
203 bool parseFixedStackFrameIndex(
int &FI);
213 bool parseCFIOffset(
int &
Offset);
214 bool parseCFIRegister(
unsigned &
Reg);
227 bool parseOffset(int64_t &
Offset);
228 bool parseAlignment(
unsigned &Alignment);
230 bool parseIRValue(
const Value *&V);
242 bool getUnsigned(
unsigned &Result);
247 bool getUint64(uint64_t &Result);
253 bool getHexUint(
APInt &Result);
263 void initNames2InstrOpCodes();
267 bool parseInstrName(
StringRef InstrName,
unsigned &OpCode);
269 bool parseInstruction(
unsigned &OpCode,
unsigned &
Flags);
277 void initNames2Regs();
281 bool getRegisterByName(
StringRef RegName,
unsigned &
Reg);
283 void initNames2RegMasks();
290 void initNames2SubRegIndices();
300 const Value *getIRValue(
unsigned Slot);
302 void initNames2TargetIndices();
309 void initNames2DirectTargetFlags();
317 void initNames2BitmaskTargetFlags();
325 void initNames2MMOTargetFlags();
335 bool parseStringConstant(std::string &Result);
342 : MF(PFS.MF), Error(Error), Source(Source), CurrentSource(Source), PFS(PFS)
345 void MIParser::lex(
unsigned SkipChar) {
347 CurrentSource.data() + SkipChar, Token,
383 return "<unknown token>";
388 if (Token.isNot(TokenKind))
395 if (Token.isNot(TokenKind))
401 bool MIParser::parseBasicBlockDefinition(
407 auto Loc = Token.location();
408 auto Name = Token.stringValue();
410 bool HasAddressTaken =
false;
411 bool IsLandingPad =
false;
412 unsigned Alignment = 0;
417 switch (Token.kind()) {
419 HasAddressTaken =
true;
427 if (parseAlignment(Alignment))
432 if (parseIRBlock(BB, *MF.getFunction()))
447 BB = dyn_cast_or_null<BasicBlock>(
448 MF.getFunction()->getValueSymbolTable()->lookup(
Name));
451 "' is not defined in the function '" +
454 auto *MBB = MF.CreateMachineBasicBlock(BB);
455 MF.insert(MF.end(), MBB);
456 bool WasInserted = MBBSlots.
insert(std::make_pair(ID, MBB)).second;
458 return error(Loc,
Twine(
"redefinition of machine basic block with id #") +
461 MBB->setAlignment(Alignment);
463 MBB->setHasAddressTaken();
464 MBB->setIsEHPad(IsLandingPad);
468 bool MIParser::parseBasicBlockDefinitions(
474 if (Token.isErrorOrEOF())
475 return Token.isError();
477 return error(
"expected a basic block definition before instructions");
478 unsigned BraceDepth = 0;
480 if (parseBasicBlockDefinition(MBBSlots))
482 bool IsAfterNewline =
false;
486 Token.isErrorOrEOF())
489 return error(
"basic block definition should be located at the start of "
492 IsAfterNewline =
true;
495 IsAfterNewline =
false;
500 return error(
"extraneous closing brace ('}')");
506 if (!Token.isError() && BraceDepth)
507 return error(
"expected '}'");
508 }
while (!Token.isErrorOrEOF());
509 return Token.isError();
517 if (Token.isNewlineOrEOF())
521 return error(
"expected a named register");
523 if (parseNamedRegister(Reg))
531 return error(
"expected a lane mask");
533 "Use correct get-function for lane mask");
536 return error(
"invalid lane mask value");
550 if (Token.isNewlineOrEOF())
554 return error(
"expected a machine basic block reference");
563 return error(
"expected an integer literal after '('");
564 if (getUnsigned(Weight))
597 bool ExplicitSuccessors =
false;
600 if (parseBasicBlockSuccessors(MBB))
602 ExplicitSuccessors =
true;
604 if (parseBasicBlockLiveins(MBB))
610 if (!Token.isNewlineOrEOF())
611 return error(
"expected line break at the end of a list");
616 bool IsInBundle =
false;
640 return error(
"nested instruction bundles are not allowed");
649 assert(Token.isNewlineOrEOF() &&
"MI is not fully parsed");
654 if (!ExplicitSuccessors) {
662 AddFalthroughFrom = &MBB;
671 bool MIParser::parseBasicBlocks() {
676 if (Token.isErrorOrEOF())
677 return Token.isError();
686 if (AddFalthroughFrom) {
687 if (!AddFalthroughFrom->isSuccessor(MBB))
689 AddFalthroughFrom->normalizeSuccProbs();
690 AddFalthroughFrom =
nullptr;
692 if (parseBasicBlock(*MBB, AddFalthroughFrom))
705 while (Token.isRegister() || Token.isRegisterFlag()) {
706 auto Loc = Token.location();
708 if (parseRegisterOperand(MO, TiedDefIdx,
true))
711 ParsedMachineOperand(MO, Loc, Token.location(), TiedDefIdx));
719 unsigned OpCode,
Flags = 0;
720 if (Token.isError() || parseInstruction(OpCode, Flags))
726 auto Loc = Token.location();
728 if (parseMachineOperandAndTargetFlags(MO, TiedDefIdx))
731 ParsedMachineOperand(MO, Loc, Token.location(), TiedDefIdx));
736 return error(
"expected ',' before the next machine operand");
744 return error(
"expected a metadata node after 'debug-location'");
755 while (!Token.isNewlineOrEOF()) {
757 if (parseMachineMemoryOperand(MemOp))
760 if (Token.isNewlineOrEOF())
763 return error(
"expected ',' before the next machine memory operand");
768 const auto &MCID = MF.getSubtarget().getInstrInfo()->get(OpCode);
769 if (!MCID.isVariadic()) {
771 if (verifyImplicitOperands(Operands, MCID))
776 MI = MF.CreateMachineInstr(MCID, DebugLocation,
true);
778 for (
const auto &Operand : Operands)
780 if (assignRegisterTies(*MI, Operands))
782 if (MemOperands.
empty())
785 MF.allocateMemRefsArray(MemOperands.
size());
786 std::copy(MemOperands.
begin(), MemOperands.
end(), MemRefs);
794 return error(
"expected a machine basic block reference");
800 "expected end of string after the machine basic block reference");
804 bool MIParser::parseStandaloneNamedRegister(
unsigned &Reg) {
807 return error(
"expected a named register");
808 if (parseNamedRegister(Reg))
812 return error(
"expected end of string after the register reference");
816 bool MIParser::parseStandaloneVirtualRegister(
VRegInfo *&Info) {
819 return error(
"expected a virtual register");
820 if (parseVirtualRegister(Info))
824 return error(
"expected end of string after the register reference");
828 bool MIParser::parseStandaloneRegister(
unsigned &Reg) {
832 return error(
"expected either a named or virtual register");
835 if (parseRegister(Reg, Info))
840 return error(
"expected end of string after the register reference");
844 bool MIParser::parseStandaloneStackObject(
int &FI) {
847 return error(
"expected a stack object");
848 if (parseStackFrameIndex(FI))
851 return error(
"expected end of string after the stack object reference");
855 bool MIParser::parseStandaloneMDNode(
MDNode *&Node) {
858 return error(
"expected a metadata node");
862 return error(
"expected end of string after the metadata node");
868 return MO.
isDef() ?
"implicit-def" :
"implicit";
880 for (
const auto &
I : Operands) {
905 const auto *TRI = MF.getSubtarget().getRegisterInfo();
906 assert(TRI &&
"Expected target register info");
907 for (
const auto &
I : ImplicitOperands) {
910 return error(Operands.
empty() ? Token.location() : Operands.
back().End,
911 Twine(
"missing implicit register operand '") +
918 bool MIParser::parseInstruction(
unsigned &OpCode,
unsigned &Flags) {
924 return error(
"expected a machine instruction");
925 StringRef InstrName = Token.stringValue();
926 if (parseInstrName(InstrName, OpCode))
927 return error(
Twine(
"unknown machine instruction name '") + InstrName +
"'");
932 bool MIParser::parseNamedRegister(
unsigned &Reg) {
935 if (getRegisterByName(Name, Reg))
936 return error(
Twine(
"unknown register name '") + Name +
"'");
940 bool MIParser::parseVirtualRegister(
VRegInfo *&Info) {
945 Info = &PFS.getVRegInfo(ID);
949 bool MIParser::parseRegister(
unsigned &Reg,
VRegInfo *&Info) {
950 switch (Token.kind()) {
955 return parseNamedRegister(Reg);
957 if (parseVirtualRegister(Info))
967 bool MIParser::parseRegisterClassOrBank(
VRegInfo &RegInfo) {
969 return error(
"expected '_', register class, or register bank name");
974 auto RCNameI = PFS.Names2RegClasses.
find(Name);
975 if (RCNameI != PFS.Names2RegClasses.end()) {
979 switch (RegInfo.
Kind) {
985 return error(Loc,
Twine(
"conflicting register classes, previously: ") +
994 return error(Loc,
"register class specification on generic register");
1002 auto RBNameI = PFS.Names2RegBanks.find(Name);
1003 if (RBNameI == PFS.Names2RegBanks.end())
1004 return error(Loc,
"expected '_', register class, or register bank name");
1005 RegBank = RBNameI->getValue();
1010 switch (RegInfo.
Kind) {
1016 return error(Loc,
"conflicting generic register banks");
1022 return error(Loc,
"register bank specification on normal register");
1027 bool MIParser::parseRegisterFlag(
unsigned &Flags) {
1028 const unsigned OldFlags =
Flags;
1029 switch (Token.kind()) {
1060 if (OldFlags == Flags)
1063 return error(
"duplicate '" + Token.stringValue() +
"' register flag");
1068 bool MIParser::parseSubRegisterIndex(
unsigned &
SubReg) {
1072 return error(
"expected a subregister index after '.'");
1073 auto Name = Token.stringValue();
1074 SubReg = getSubRegIndex(Name);
1076 return error(
Twine(
"use of unknown subregister index '") + Name +
"'");
1081 bool MIParser::parseRegisterTiedDefIndex(
unsigned &TiedDefIdx) {
1085 return error(
"expected an integer literal after 'tied-def'");
1086 if (getUnsigned(TiedDefIdx))
1097 for (
unsigned I = 0,
E = Operands.
size();
I !=
E; ++
I) {
1098 if (!Operands[
I].TiedDefIdx)
1102 unsigned DefIdx = Operands[
I].TiedDefIdx.getValue();
1104 return error(Operands[
I].Begin,
1105 Twine(
"use of invalid tied-def operand index '" +
1106 Twine(DefIdx) +
"'; instruction has only ") +
1108 const auto &DefOperand = Operands[DefIdx].Operand;
1109 if (!DefOperand.isReg() || !DefOperand.isDef())
1111 return error(Operands[
I].Begin,
1112 Twine(
"use of invalid tied-def operand index '") +
1113 Twine(DefIdx) +
"'; the operand #" +
Twine(DefIdx) +
1114 " isn't a defined register");
1116 for (
const auto &TiedPair : TiedRegisterPairs) {
1117 if (TiedPair.first == DefIdx)
1118 return error(Operands[
I].Begin,
1119 Twine(
"the tied-def operand #") +
Twine(DefIdx) +
1120 " is already tied with another register operand");
1122 TiedRegisterPairs.push_back(std::make_pair(DefIdx,
I));
1126 for (
const auto &TiedPair : TiedRegisterPairs)
1135 while (Token.isRegisterFlag()) {
1136 if (parseRegisterFlag(Flags))
1139 if (!Token.isRegister())
1140 return error(
"expected a register after register flags");
1143 if (parseRegister(Reg, RegInfo))
1146 unsigned SubReg = 0;
1148 if (parseSubRegisterIndex(SubReg))
1151 return error(
"subregister index expects a virtual register");
1155 return error(
"register class specification expects a virtual register");
1157 if (parseRegisterClassOrBank(*RegInfo))
1164 if (!parseRegisterTiedDefIndex(Idx))
1169 if (parseLowLevelType(Token.location(), Ty))
1170 return error(
"expected tied-def or low-level type after '('");
1176 return error(
"inconsistent type for generic virtual register");
1184 return error(
"unexpected type on physical register");
1187 if (parseLowLevelType(Token.location(), Ty))
1194 return error(
"inconsistent type for generic virtual register");
1203 return error(
"generic virtual registers must have a type");
1215 const APSInt &
Int = Token.integerValue();
1216 if (Int.getMinSignedBits() > 64)
1217 return error(
"integer literal is too large to be an immediate operand");
1235 if (parseIRConstant(Loc,
StringRef(Loc, Token.range().end() - Loc), C))
1247 const DataLayout &
DL = MF.getFunction()->getParent()->getDataLayout();
1248 unsigned AS =
APSInt(Token.range().drop_front()).getZExtValue();
1257 "expected unsized, pN, sN or <N x sM> for GlobalISel type");
1262 return error(Loc,
"expected <N x sM> for vctor type");
1263 uint64_t NumElements = Token.integerValue().getZExtValue();
1267 return error(Loc,
"expected '<N x sM>' for vector type");
1271 return error(Loc,
"expected '<N x sM>' for vector type");
1272 uint64_t ScalarSize =
APSInt(Token.range().drop_front()).getZExtValue();
1276 return error(Loc,
"expected '<N x sM>' for vector type");
1283 bool MIParser::parseTypedImmediateOperand(
MachineOperand &Dest) {
1285 auto Loc = Token.location();
1288 return error(
"expected an integer literal");
1290 if (parseIRConstant(Loc, C))
1297 auto Loc = Token.location();
1301 return error(
"expected a floating point literal");
1303 if (parseIRConstant(Loc, C))
1309 bool MIParser::getUnsigned(
unsigned &Result) {
1310 if (Token.hasIntegerValue()) {
1312 uint64_t Val64 = Token.integerValue().getLimitedValue(Limit);
1314 return error(
"expected 32-bit integer (too large)");
1323 return error(
"expected 32-bit integer (too large)");
1334 if (getUnsigned(Number))
1336 auto MBBInfo = PFS.MBBSlots.find(Number);
1337 if (MBBInfo == PFS.MBBSlots.end())
1338 return error(
Twine(
"use of undefined machine basic block #") +
1340 MBB = MBBInfo->second;
1341 if (!Token.stringValue().empty() && Token.stringValue() != MBB->
getName())
1342 return error(
Twine(
"the name of machine basic block #") +
Twine(Number) +
1343 " isn't '" + Token.stringValue() +
"'");
1356 bool MIParser::parseStackFrameIndex(
int &FI) {
1359 if (getUnsigned(ID))
1361 auto ObjectInfo = PFS.StackObjectSlots.find(ID);
1362 if (ObjectInfo == PFS.StackObjectSlots.end())
1363 return error(
Twine(
"use of undefined stack object '%stack.") +
Twine(ID) +
1366 if (
const auto *Alloca =
1367 MF.getFrameInfo().getObjectAllocation(ObjectInfo->second))
1368 Name = Alloca->getName();
1369 if (!Token.stringValue().empty() && Token.stringValue() !=
Name)
1370 return error(
Twine(
"the name of the stack object '%stack.") +
Twine(ID) +
1371 "' isn't '" + Token.stringValue() +
"'");
1373 FI = ObjectInfo->second;
1379 if (parseStackFrameIndex(FI))
1385 bool MIParser::parseFixedStackFrameIndex(
int &FI) {
1388 if (getUnsigned(ID))
1390 auto ObjectInfo = PFS.FixedStackObjectSlots.find(ID);
1391 if (ObjectInfo == PFS.FixedStackObjectSlots.end())
1392 return error(
Twine(
"use of undefined fixed stack object '%fixed-stack.") +
1395 FI = ObjectInfo->second;
1399 bool MIParser::parseFixedStackObjectOperand(
MachineOperand &Dest) {
1401 if (parseFixedStackFrameIndex(FI))
1407 bool MIParser::parseGlobalValue(
GlobalValue *&GV) {
1408 switch (Token.kind()) {
1413 return error(
Twine(
"use of undefined global value '") + Token.range() +
1419 if (getUnsigned(GVIdx))
1421 if (GVIdx >= PFS.IRSlots.GlobalValues.size())
1422 return error(
Twine(
"use of undefined global value '@") +
Twine(GVIdx) +
1424 GV = PFS.IRSlots.GlobalValues[GVIdx];
1435 if (parseGlobalValue(GV))
1439 if (parseOperandsOffset(Dest))
1444 bool MIParser::parseConstantPoolIndexOperand(
MachineOperand &Dest) {
1447 if (getUnsigned(ID))
1451 return error(
"use of undefined constant '%const." +
Twine(ID) +
"'");
1454 if (parseOperandsOffset(Dest))
1459 bool MIParser::parseJumpTableIndexOperand(
MachineOperand &Dest) {
1462 if (getUnsigned(ID))
1464 auto JumpTableEntryInfo = PFS.JumpTableSlots.find(ID);
1465 if (JumpTableEntryInfo == PFS.JumpTableSlots.end())
1466 return error(
"use of undefined jump table '%jump-table." +
Twine(ID) +
"'");
1472 bool MIParser::parseExternalSymbolOperand(
MachineOperand &Dest) {
1474 const char *
Symbol = MF.createExternalSymbolName(Token.stringValue());
1477 if (parseOperandsOffset(Dest))
1482 bool MIParser::parseSubRegisterIndexOperand(
MachineOperand &Dest) {
1485 unsigned SubRegIndex = getSubRegIndex(Token.stringValue());
1486 if (SubRegIndex == 0)
1487 return error(
Twine(
"unknown subregister index '") + Name +
"'");
1495 auto Loc = Token.location();
1498 return error(
"expected metadata id after '!'");
1500 if (getUnsigned(ID))
1502 auto NodeInfo = PFS.IRSlots.MetadataNodes.find(ID);
1503 if (NodeInfo == PFS.IRSlots.MetadataNodes.end())
1504 return error(Loc,
"use of undefined metadata '!" +
Twine(ID) +
"'");
1506 Node = NodeInfo->second.
get();
1518 bool MIParser::parseCFIOffset(
int &
Offset) {
1520 return error(
"expected a cfi offset");
1521 if (Token.integerValue().getMinSignedBits() > 32)
1522 return error(
"expected a 32 bit integer (the cfi offset is too large)");
1523 Offset = (int)Token.integerValue().getExtValue();
1528 bool MIParser::parseCFIRegister(
unsigned &Reg) {
1530 return error(
"expected a cfi register");
1532 if (parseNamedRegister(LLVMReg))
1534 const auto *TRI = MF.getSubtarget().getRegisterInfo();
1535 assert(TRI &&
"Expected target register info");
1538 return error(
"invalid DWARF register");
1545 auto Kind = Token.kind();
1552 if (parseCFIRegister(Reg))
1558 parseCFIOffset(Offset))
1564 if (parseCFIRegister(Reg))
1570 if (parseCFIOffset(Offset))
1573 CFIIndex = MF.addFrameInst(
1578 parseCFIOffset(Offset))
1593 switch (Token.kind()) {
1595 BB = dyn_cast_or_null<BasicBlock>(
1598 return error(
Twine(
"use of undefined IR block '") + Token.range() +
"'");
1602 unsigned SlotNumber = 0;
1603 if (getUnsigned(SlotNumber))
1605 BB =
const_cast<BasicBlock *
>(getIRBlock(SlotNumber, F));
1607 return error(
Twine(
"use of undefined IR block '%ir-block.") +
1608 Twine(SlotNumber) +
"'");
1624 return error(
"expected a global value");
1626 if (parseGlobalValue(GV))
1630 return error(
"expected an IR function reference");
1636 return error(
"expected an IR block reference");
1637 if (parseIRBlock(BB, *F))
1643 if (parseOperandsOffset(Dest))
1652 return error(
"expected syntax intrinsic(@llvm.whatever)");
1655 return error(
"expected syntax intrinsic(@llvm.whatever)");
1657 std::string Name = Token.stringValue();
1661 return error(
"expected ')' to terminate intrinsic name");
1671 return error(
"unknown intrinsic name");
1683 return error(
"expected syntax intpred(whatever) or floatpred(whatever");
1686 return error(
"whatever");
1709 return error(
"invalid floating-point predicate");
1724 return error(
"invalid integer predicate");
1730 return error(
"predicate should be terminated by ')'.");
1741 return error(
"expected the name of the target index");
1743 if (getTargetIndex(Token.stringValue(), Index))
1744 return error(
"use of undefined target index '" + Token.stringValue() +
"'");
1749 if (parseOperandsOffset(Dest))
1754 bool MIParser::parseCustomRegisterMaskOperand(
MachineOperand &Dest) {
1755 assert(Token.stringValue() ==
"CustomRegMask" &&
"Expected a custom RegMask");
1757 assert(TRI &&
"Expected target register info");
1762 uint32_t *Mask = MF.allocateRegisterMask(TRI->getNumRegs());
1765 return error(
"expected a named register");
1767 if (parseNamedRegister(Reg))
1770 Mask[Reg / 32] |= 1U << (Reg % 32);
1783 bool MIParser::parseLiveoutRegisterMaskOperand(
MachineOperand &Dest) {
1785 const auto *TRI = MF.getSubtarget().getRegisterInfo();
1786 assert(TRI &&
"Expected target register info");
1787 uint32_t *Mask = MF.allocateRegisterMask(TRI->getNumRegs());
1793 return error(
"expected a named register");
1795 if (parseNamedRegister(Reg))
1798 Mask[Reg / 32] |= 1U << (Reg % 32);
1812 switch (Token.kind()) {
1825 return parseRegisterOperand(Dest, TiedDefIdx);
1827 return parseImmediateOperand(Dest);
1829 return parseTypedImmediateOperand(Dest);
1836 return parseFPImmediateOperand(Dest);
1838 return parseMBBOperand(Dest);
1840 return parseStackObjectOperand(Dest);
1842 return parseFixedStackObjectOperand(Dest);
1845 return parseGlobalAddressOperand(Dest);
1847 return parseConstantPoolIndexOperand(Dest);
1849 return parseJumpTableIndexOperand(Dest);
1851 return parseExternalSymbolOperand(Dest);
1853 return parseSubRegisterIndexOperand(Dest);
1855 return parseMetadataOperand(Dest);
1861 return parseCFIOperand(Dest);
1863 return parseBlockAddressOperand(Dest);
1865 return parseIntrinsicOperand(Dest);
1867 return parseTargetIndexOperand(Dest);
1869 return parseLiveoutRegisterMaskOperand(Dest);
1872 return parsePredicateOperand(Dest);
1876 if (
const auto *RegMask = getRegMask(Token.stringValue())) {
1881 return parseCustomRegisterMaskOperand(Dest);
1884 return error(
"expected a machine operand");
1889 bool MIParser::parseMachineOperandAndTargetFlags(
1892 bool HasTargetFlags =
false;
1894 HasTargetFlags =
true;
1899 return error(
"expected the name of the target flag");
1900 if (getDirectTargetFlag(Token.stringValue(), TF)) {
1901 if (getBitmaskTargetFlag(Token.stringValue(), TF))
1902 return error(
"use of undefined target flag '" + Token.stringValue() +
1909 return error(
"expected the name of the target flag");
1910 unsigned BitFlag = 0;
1911 if (getBitmaskTargetFlag(Token.stringValue(), BitFlag))
1912 return error(
"use of undefined target flag '" + Token.stringValue() +
1921 auto Loc = Token.location();
1922 if (parseMachineOperand(Dest, TiedDefIdx))
1924 if (!HasTargetFlags)
1927 return error(Loc,
"register operands can't have target flags");
1932 bool MIParser::parseOffset(int64_t &Offset) {
1939 return error(
"expected an integer literal after '" + Sign +
"'");
1940 if (Token.integerValue().getMinSignedBits() > 64)
1941 return error(
"expected 64-bit integer (too large)");
1942 Offset = Token.integerValue().getExtValue();
1949 bool MIParser::parseAlignment(
unsigned &Alignment) {
1953 return error(
"expected an integer literal after 'align'");
1954 if (getUnsigned(Alignment))
1962 if (parseOffset(Offset))
1968 bool MIParser::parseIRValue(
const Value *&V) {
1969 switch (Token.kind()) {
1971 V = MF.getFunction()->getValueSymbolTable()->lookup(Token.stringValue());
1975 unsigned SlotNumber = 0;
1976 if (getUnsigned(SlotNumber))
1978 V = getIRValue(SlotNumber);
1984 if (parseGlobalValue(GV))
1991 if (parseIRConstant(Token.location(), Token.stringValue(),
C))
2000 return error(
Twine(
"use of undefined IR value '") + Token.range() +
"'");
2004 bool MIParser::getUint64(uint64_t &Result) {
2005 if (Token.hasIntegerValue()) {
2006 if (Token.integerValue().getActiveBits() > 64)
2007 return error(
"expected 64-bit integer (too large)");
2008 Result = Token.integerValue().getZExtValue();
2016 return error(
"expected 64-bit integer (too large)");
2023 bool MIParser::getHexUint(
APInt &Result) {
2026 assert(S[0] ==
'0' && tolower(S[1]) ==
'x');
2028 if (!isxdigit(S[2]))
2038 const auto OldFlags =
Flags;
2039 switch (Token.kind()) {
2054 if (getMMOTargetFlag(Token.stringValue(), TF))
2055 return error(
"use of undefined target MMO flag '" + Token.stringValue() +
2063 if (OldFlags == Flags)
2066 return error(
"duplicate '" + Token.stringValue() +
"' memory operand flag");
2072 switch (Token.kind()) {
2074 PSV = MF.getPSVManager().getStack();
2077 PSV = MF.getPSVManager().getGOT();
2080 PSV = MF.getPSVManager().getJumpTable();
2083 PSV = MF.getPSVManager().getConstantPool();
2087 if (parseFixedStackFrameIndex(FI))
2089 PSV = MF.getPSVManager().getFixedStack(FI);
2095 if (parseStackFrameIndex(FI))
2097 PSV = MF.getPSVManager().getFixedStack(FI);
2103 switch (Token.kind()) {
2107 if (parseGlobalValue(GV))
2109 PSV = MF.getPSVManager().getGlobalValueCallEntry(GV);
2113 PSV = MF.getPSVManager().getExternalSymbolCallEntry(
2114 MF.createExternalSymbolName(Token.stringValue()));
2118 "expected a global value or an external symbol after 'call-entry'");
2134 if (parseMemoryPseudoSourceValue(PSV))
2137 if (parseOffset(Offset))
2146 return error(
"expected an IR value reference");
2147 const Value *V =
nullptr;
2148 if (parseIRValue(V))
2151 return error(
"expected a pointer IR value");
2154 if (parseOffset(Offset))
2166 return error(
"expected '(' in syncscope");
2169 if (parseStringConstant(SSN))
2174 return error(
"expected ')' in syncscope");
2180 bool MIParser::parseOptionalAtomicOrdering(
AtomicOrdering &Order) {
2199 return error(
"expected an atomic scope, ordering or a size integer literal");
2206 while (Token.isMemoryOperandFlag()) {
2207 if (parseMemoryOperandFlag(Flags))
2211 (Token.stringValue() !=
"load" && Token.stringValue() !=
"store"))
2212 return error(
"expected 'load' or 'store' memory operation");
2213 if (Token.stringValue() ==
"load")
2221 if (parseOptionalScope(MF.getFunction()->getContext(), SSID))
2226 if (parseOptionalAtomicOrdering(Order))
2229 if (parseOptionalAtomicOrdering(FailureOrder))
2233 return error(
"expected the size integer literal after memory operation");
2235 if (getUint64(Size))
2242 if (Token.stringValue() !=
Word)
2243 return error(
Twine(
"expected '") + Word +
"'");
2246 if (parseMachinePointerInfo(Ptr))
2249 unsigned BaseAlignment =
Size;
2253 switch (Token.kind()) {
2255 if (parseAlignment(BaseAlignment))
2280 return error(
"expected 'align' or '!tbaa' or '!alias.scope' or "
2281 "'!noalias' or '!range'");
2286 Dest = MF.getMachineMemOperand(Ptr, Flags, Size, BaseAlignment, AAInfo, Range,
2287 SSID, Order, FailureOrder);
2291 void MIParser::initNames2InstrOpCodes() {
2292 if (!Names2InstrOpCodes.empty())
2294 const auto *TII = MF.getSubtarget().getInstrInfo();
2295 assert(TII &&
"Expected target instruction info");
2296 for (
unsigned I = 0,
E = TII->getNumOpcodes();
I <
E; ++
I)
2300 bool MIParser::parseInstrName(
StringRef InstrName,
unsigned &OpCode) {
2301 initNames2InstrOpCodes();
2302 auto InstrInfo = Names2InstrOpCodes.find(InstrName);
2303 if (InstrInfo == Names2InstrOpCodes.end())
2305 OpCode = InstrInfo->getValue();
2309 void MIParser::initNames2Regs() {
2310 if (!Names2Regs.empty())
2313 Names2Regs.insert(std::make_pair(
"noreg", 0));
2314 const auto *TRI = MF.getSubtarget().getRegisterInfo();
2315 assert(TRI &&
"Expected target register info");
2316 for (
unsigned I = 0, E = TRI->getNumRegs();
I <
E; ++
I) {
2318 Names2Regs.insert(std::make_pair(
StringRef(TRI->getName(
I)).lower(),
I))
2321 assert(WasInserted &&
"Expected registers to be unique case-insensitively");
2325 bool MIParser::getRegisterByName(
StringRef RegName,
unsigned &Reg) {
2327 auto RegInfo = Names2Regs.find(RegName);
2328 if (RegInfo == Names2Regs.end())
2330 Reg = RegInfo->getValue();
2334 void MIParser::initNames2RegMasks() {
2335 if (!Names2RegMasks.empty())
2337 const auto *TRI = MF.getSubtarget().getRegisterInfo();
2338 assert(TRI &&
"Expected target register info");
2342 for (
size_t I = 0, E = RegMasks.
size();
I <
E; ++
I)
2343 Names2RegMasks.insert(
2344 std::make_pair(
StringRef(RegMaskNames[
I]).lower(), RegMasks[I]));
2348 initNames2RegMasks();
2349 auto RegMaskInfo = Names2RegMasks.find(Identifier);
2350 if (RegMaskInfo == Names2RegMasks.end())
2352 return RegMaskInfo->getValue();
2355 void MIParser::initNames2SubRegIndices() {
2356 if (!Names2SubRegIndices.empty())
2360 Names2SubRegIndices.insert(
2364 unsigned MIParser::getSubRegIndex(
StringRef Name) {
2365 initNames2SubRegIndices();
2366 auto SubRegInfo = Names2SubRegIndices.find(Name);
2367 if (SubRegInfo == Names2SubRegIndices.end())
2369 return SubRegInfo->getValue();
2377 for (
auto &BB : F) {
2380 int Slot = MST.getLocalSlot(&BB);
2383 Slots2BasicBlocks.
insert(std::make_pair(
unsigned(Slot), &BB));
2390 auto BlockInfo = Slots2BasicBlocks.
find(Slot);
2391 if (BlockInfo == Slots2BasicBlocks.
end())
2393 return BlockInfo->second;
2396 const BasicBlock *MIParser::getIRBlock(
unsigned Slot) {
2397 if (Slots2BasicBlocks.empty())
2403 if (&F == MF.getFunction())
2404 return getIRBlock(Slot);
2415 Slots2Values.
insert(std::make_pair(
unsigned(Slot), V));
2423 for (
const auto &Arg : F.
args())
2425 for (
const auto &BB : F) {
2427 for (
const auto &I : BB)
2432 const Value *MIParser::getIRValue(
unsigned Slot) {
2433 if (Slots2Values.empty())
2435 auto ValueInfo = Slots2Values.find(Slot);
2441 void MIParser::initNames2TargetIndices() {
2442 if (!Names2TargetIndices.empty())
2444 const auto *TII = MF.getSubtarget().getInstrInfo();
2445 assert(TII &&
"Expected target instruction info");
2446 auto Indices = TII->getSerializableTargetIndices();
2447 for (
const auto &I : Indices)
2448 Names2TargetIndices.insert(std::make_pair(
StringRef(I.second), I.first));
2451 bool MIParser::getTargetIndex(
StringRef Name,
int &Index) {
2452 initNames2TargetIndices();
2453 auto IndexInfo = Names2TargetIndices.find(Name);
2454 if (IndexInfo == Names2TargetIndices.end())
2456 Index = IndexInfo->second;
2460 void MIParser::initNames2DirectTargetFlags() {
2461 if (!Names2DirectTargetFlags.empty())
2463 const auto *TII = MF.getSubtarget().getInstrInfo();
2464 assert(TII &&
"Expected target instruction info");
2465 auto Flags = TII->getSerializableDirectMachineOperandTargetFlags();
2466 for (
const auto &I : Flags)
2467 Names2DirectTargetFlags.insert(
2468 std::make_pair(
StringRef(I.second), I.first));
2471 bool MIParser::getDirectTargetFlag(
StringRef Name,
unsigned &
Flag) {
2472 initNames2DirectTargetFlags();
2473 auto FlagInfo = Names2DirectTargetFlags.find(Name);
2474 if (FlagInfo == Names2DirectTargetFlags.end())
2476 Flag = FlagInfo->second;
2480 void MIParser::initNames2BitmaskTargetFlags() {
2481 if (!Names2BitmaskTargetFlags.empty())
2483 const auto *TII = MF.getSubtarget().getInstrInfo();
2484 assert(TII &&
"Expected target instruction info");
2485 auto Flags = TII->getSerializableBitmaskMachineOperandTargetFlags();
2486 for (
const auto &I : Flags)
2487 Names2BitmaskTargetFlags.insert(
2488 std::make_pair(
StringRef(I.second), I.first));
2491 bool MIParser::getBitmaskTargetFlag(
StringRef Name,
unsigned &Flag) {
2492 initNames2BitmaskTargetFlags();
2493 auto FlagInfo = Names2BitmaskTargetFlags.find(Name);
2494 if (FlagInfo == Names2BitmaskTargetFlags.end())
2496 Flag = FlagInfo->second;
2500 void MIParser::initNames2MMOTargetFlags() {
2501 if (!Names2MMOTargetFlags.empty())
2503 const auto *TII = MF.getSubtarget().getInstrInfo();
2504 assert(TII &&
"Expected target instruction info");
2505 auto Flags = TII->getSerializableMachineMemOperandTargetFlags();
2506 for (
const auto &I : Flags)
2507 Names2MMOTargetFlags.insert(
2508 std::make_pair(
StringRef(I.second), I.first));
2511 bool MIParser::getMMOTargetFlag(
StringRef Name,
2513 initNames2MMOTargetFlags();
2514 auto FlagInfo = Names2MMOTargetFlags.find(Name);
2515 if (FlagInfo == Names2MMOTargetFlags.end())
2517 Flag = FlagInfo->second;
2521 bool MIParser::parseStringConstant(std::string &Result) {
2523 return error(
"expected string constant");
2524 Result = Token.stringValue();
2532 return MIParser(PFS, Error, Src).parseBasicBlockDefinitions(PFS.
MBBSlots);
2537 return MIParser(PFS, Error, Src).parseBasicBlocks();
2543 return MIParser(PFS, Error, Src).parseStandaloneMBB(MBB);
2549 return MIParser(PFS, Error, Src).parseStandaloneRegister(Reg);
2555 return MIParser(PFS, Error, Src).parseStandaloneNamedRegister(Reg);
2561 return MIParser(PFS, Error, Src).parseStandaloneVirtualRegister(Info);
2567 return MIParser(PFS, Error, Src).parseStandaloneStackObject(FI);
2572 return MIParser(PFS, Error, Src).parseStandaloneMDNode(Node);
void guessSuccessors(const MachineBasicBlock &MBB, SmallVectorImpl< MachineBasicBlock * > &Successors, bool &IsFallthrough)
Determine a possible list of successors of a basic block based on the basic block machine operand bei...
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.
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
A common definition of LaneBitmask for use in TableGen and CodeGen.
static MachineOperand CreateCImm(const ConstantInt *CI)
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
uint64_t getZExtValue() const
Get zero extended value.
LLT getType(unsigned VReg) const
Get the low-level type of VReg or LLT{} if VReg is not a generic (target independent) virtual registe...
MDNode * Scope
The tag for alias scope specification (used with noalias).
Atomic ordering constants.
const char * getBufferStart() const
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. ...
union llvm::VRegInfo::@284 D
static BranchProbability getRaw(uint32_t N)
static LaneBitmask getAll()
static MachineOperand CreateJTI(unsigned Idx, unsigned char TargetFlags=0)
Describe properties that are true of each instruction in the target description file.
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.
static void initSlots2BasicBlocks(const Function &F, DenseMap< unsigned, const BasicBlock * > &Slots2BasicBlocks)
0 1 0 0 True if ordered and less than
1 1 1 0 True if unordered or not equal
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.
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 MachineOperand CreateIntrinsicID(Intrinsic::ID ID)
static const BasicBlock * getIRBlockFromSlot(unsigned Slot, const DenseMap< unsigned, const BasicBlock * > &Slots2BasicBlocks)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
1 0 0 1 True if unordered or equal
unsigned getMainFileID() const
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
std::string str() const
Return the twine contents as a std::string.
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 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 isCall() const
Return true if the instruction is a call.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
support::ulittle32_t Word
LLVM_ATTRIBUTE_ALWAYS_INLINE R Default(const T &Value) const
Reg
All possible values of the reg field in the ModR/M byte.
0 1 0 1 True if ordered and less than or equal
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)
This file implements a class to represent arbitrary precision integral constant values and operations...
LLVM_NODISCARD bool empty() const
AtomicOrdering
Atomic ordering for LLVM's memory model.
static std::string getRegisterName(const TargetRegisterInfo *TRI, unsigned Reg)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(const char(&S)[N], const T &Value)
unsigned getNumSubRegIndices() const
Return the number of sub-register indices understood by the target.
StringRef getMessage() const
virtual unsigned lookupName(const char *Name, unsigned Len) const =0
Look up target intrinsic by name.
const MCPhysReg * getImplicitDefs() const
Return a list of registers that are potentially written by any instance of this machine instruction...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
unsigned getActiveBits() const
Compute the number of active bits in the value.
const char * getRegClassName(const TargetRegisterClass *Class) const
Returns the name of the register class.
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)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
size_t size() const
size - Get the array size.
void normalizeSuccProbs()
Normalize probabilities of all successors so that the sum of them becomes one.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
iterator find(const_arg_type_t< KeyT > Val)
VRegInfo & getVRegInfo(unsigned VReg)
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.
A switch()-like statement whose cases are string literals.
bool parseStackObjectReference(PerFunctionMIParsingState &PFS, int &FI, StringRef Src, SMDiagnostic &Error)
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
unsigned const MachineRegisterInfo * MRI
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...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find(char C, size_t From=0) const
Search for the first character C in the string.
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.
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)
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...
const MCPhysReg * ImplicitDefs
bool isIntPredicate() const
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.
unsigned createIncompleteVirtualRegister()
Creates a new virtual register that has no register class, register bank or size assigned yet...
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
unsigned getBitWidth() const
Return the number of bits in the APInt.
static const unsigned End
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)
0 1 1 1 True if ordered (no nans)
The memory access is non-temporal.
bool empty() const
empty - Check if the array is empty.
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)
void incorporateFunction(const Function &F)
Incorporate the given function.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
bool isPointerTy() const
True if this is an instance of PointerType.
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...
1 1 0 1 True if unordered, less than, or equal
const T & back() const
back - Get the last element.
static void initSlots2Values(const Function &F, DenseMap< unsigned, const Value * > &Slots2Values)
Creates the mapping from slot numbers to function's unnamed IR values.
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.
0 0 1 0 True if ordered and greater than
Synchronized with respect to all concurrently executing threads.
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.
Type * getType() const
All values are typed, get the type of this value.
static bool isImplicitOperandIn(const MachineOperand &ImplicitOperand, ArrayRef< ParsedMachineOperand > Operands)
Return true if the parsed machine operands contain a given machine operand.
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.
This class implements the register bank concept.
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.
virtual std::string getName(unsigned IID, Type **Tys=nullptr, unsigned numTys=0) const =0
Return the name of a target intrinsic, e.g.
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
Class for arbitrary precision integers.
virtual StringRef getBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
Special value supplied for machine level alias analysis.
static MachineOperand CreateES(const char *SymName, unsigned char TargetFlags=0)
const char * getSubRegIndexName(unsigned SubIdx) const
Return the human-readable symbolic target-specific name for the specified SubRegIndex.
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)
bool isFPPredicate() const
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static SMLoc getFromPointer(const char *Ptr)
Flags
Flags values. These may be or'd together.
llvm_unreachable("Unknown RegBank!")
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.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static std::vector< std::string > Flags
bool Explicit
VReg was explicitly specified in the .mir file.
Representation of each machine instruction.
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 MemoryBuffer * getMemoryBuffer(unsigned i) const
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
static MachineOperand CreateMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
unsigned greater or equal
static MachineOperand CreateCFIIndex(unsigned CFIIndex)
static MachineOperand CreateImm(int64_t Val)
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
The memory access always returns the same value (or traps).
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)
const MCPhysReg * getImplicitUses() const
Return a list of registers that are potentially read by any instance of this machine instruction...
1 0 1 0 True if unordered or greater than
const char * getBufferEnd() const
static void mapValueToSlot(const Value *V, ModuleSlotTracker &MST, DenseMap< unsigned, const Value * > &Slots2Values)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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
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.
const char * getName(unsigned RegNo) const
Return the human-readable symbolic target-specific name for the specified physical register...
StringRef - Represent a constant reference to a string, i.e.
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.
static LLT vector(uint16_t NumElements, unsigned ScalarSizeInBits)
Get a low-level vector of some number of elements and element width.
const RegisterBank * RegBank
bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
Represents a location in source code.
bool parseRegisterReference(PerFunctionMIParsingState &PFS, unsigned &Reg, StringRef Src, SMDiagnostic &Error)
0 0 1 1 True if ordered and greater than or equal
static MachineOperand CreateFI(int Idx)
void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd)
Assign this MachineInstr's memory reference descriptor list.
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type. ...
Value * lookup(StringRef Name) const
This method finds the value with the given Name in the the symbol table.
iterator_range< arg_iterator > args()
0 0 0 0 Always false (always folded)
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)
unsigned getNumWords() const
Get the number of words.
void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.