85 if (&Subtarget == &NewSubtarget)
88 Names2InstrOpCodes.clear();
90 Names2RegMasks.clear();
91 Names2SubRegIndices.clear();
92 Names2TargetIndices.clear();
93 Names2DirectTargetFlags.clear();
94 Names2BitmaskTargetFlags.clear();
95 Names2MMOTargetFlags.clear();
97 initNames2RegClasses();
101void PerTargetMIParsingState::initNames2Regs() {
102 if (!Names2Regs.empty())
106 Names2Regs.insert(std::make_pair(
"noreg", 0));
108 assert(
TRI &&
"Expected target register info");
110 for (
unsigned I = 0, E =
TRI->getNumRegs();
I < E; ++
I) {
115 assert(WasInserted &&
"Expected registers to be unique case-insensitively");
122 auto RegInfo = Names2Regs.find(
RegName);
123 if (RegInfo == Names2Regs.end())
125 Reg = RegInfo->getValue();
131 const auto *
TRI = Subtarget.getRegisterInfo();
132 std::optional<uint8_t> FV =
TRI->getVRegFlagValue(FlagName);
139void PerTargetMIParsingState::initNames2InstrOpCodes() {
140 if (!Names2InstrOpCodes.
empty())
143 assert(
TII &&
"Expected target instruction info");
144 for (
unsigned I = 0, E =
TII->getNumOpcodes();
I < E; ++
I)
150 initNames2InstrOpCodes();
151 auto InstrInfo = Names2InstrOpCodes.find(InstrName);
152 if (InstrInfo == Names2InstrOpCodes.end())
154 OpCode = InstrInfo->getValue();
158void PerTargetMIParsingState::initNames2RegMasks() {
159 if (!Names2RegMasks.
empty())
162 assert(
TRI &&
"Expected target register info");
166 for (
size_t I = 0, E = RegMasks.
size();
I < E; ++
I)
172 initNames2RegMasks();
173 auto RegMaskInfo = Names2RegMasks.find(Identifier);
174 if (RegMaskInfo == Names2RegMasks.end())
176 return RegMaskInfo->getValue();
179void PerTargetMIParsingState::initNames2SubRegIndices() {
180 if (!Names2SubRegIndices.
empty())
183 for (
unsigned I = 1, E =
TRI->getNumSubRegIndices();
I < E; ++
I)
184 Names2SubRegIndices.
insert(
185 std::make_pair(
TRI->getSubRegIndexName(
I),
I));
189 initNames2SubRegIndices();
190 auto SubRegInfo = Names2SubRegIndices.find(Name);
191 if (SubRegInfo == Names2SubRegIndices.end())
193 return SubRegInfo->getValue();
196void PerTargetMIParsingState::initNames2TargetIndices() {
197 if (!Names2TargetIndices.
empty())
200 assert(
TII &&
"Expected target instruction info");
201 auto Indices =
TII->getSerializableTargetIndices();
202 for (
const auto &
I : Indices)
207 initNames2TargetIndices();
208 auto IndexInfo = Names2TargetIndices.find(Name);
209 if (IndexInfo == Names2TargetIndices.end())
211 Index = IndexInfo->second;
215void PerTargetMIParsingState::initNames2DirectTargetFlags() {
216 if (!Names2DirectTargetFlags.
empty())
220 assert(
TII &&
"Expected target instruction info");
221 auto Flags =
TII->getSerializableDirectMachineOperandTargetFlags();
222 for (
const auto &
I : Flags)
223 Names2DirectTargetFlags.
insert(
229 initNames2DirectTargetFlags();
230 auto FlagInfo = Names2DirectTargetFlags.find(Name);
231 if (FlagInfo == Names2DirectTargetFlags.end())
233 Flag = FlagInfo->second;
237void PerTargetMIParsingState::initNames2BitmaskTargetFlags() {
238 if (!Names2BitmaskTargetFlags.
empty())
242 assert(
TII &&
"Expected target instruction info");
243 auto Flags =
TII->getSerializableBitmaskMachineOperandTargetFlags();
244 for (
const auto &
I : Flags)
245 Names2BitmaskTargetFlags.
insert(
251 initNames2BitmaskTargetFlags();
252 auto FlagInfo = Names2BitmaskTargetFlags.find(Name);
253 if (FlagInfo == Names2BitmaskTargetFlags.end())
255 Flag = FlagInfo->second;
259void PerTargetMIParsingState::initNames2MMOTargetFlags() {
260 if (!Names2MMOTargetFlags.
empty())
264 assert(
TII &&
"Expected target instruction info");
265 auto Flags =
TII->getSerializableMachineMemOperandTargetFlags();
266 for (
const auto &
I : Flags)
272 initNames2MMOTargetFlags();
273 auto FlagInfo = Names2MMOTargetFlags.find(Name);
274 if (FlagInfo == Names2MMOTargetFlags.end())
276 Flag = FlagInfo->second;
280void PerTargetMIParsingState::initNames2RegClasses() {
281 if (!Names2RegClasses.
empty())
285 for (
unsigned I = 0, E =
TRI->getNumRegClasses();
I < E; ++
I) {
286 const auto *RC =
TRI->getRegClass(
I);
292void PerTargetMIParsingState::initNames2RegBanks() {
293 if (!Names2RegBanks.empty())
296 const RegisterBankInfo *RBI = Subtarget.getRegBankInfo();
304 Names2RegBanks.insert(
305 std::make_pair(StringRef(RegBank.getName()).lower(), &RegBank));
311 auto RegClassInfo = Names2RegClasses.find(Name);
312 if (RegClassInfo == Names2RegClasses.end())
314 return RegClassInfo->getValue();
318 auto RegBankInfo = Names2RegBanks.find(Name);
319 if (RegBankInfo == Names2RegBanks.end())
321 return RegBankInfo->getValue();
334 Info->
VReg =
MRI.createIncompleteVirtualRegister();
335 I.first->second = Info;
337 return *
I.first->second;
346 Info->
VReg =
MF.getRegInfo().createIncompleteVirtualRegister(
RegName);
347 I.first->second = Info;
349 return *
I.first->second;
357 Slots2Values.
insert(std::make_pair(
unsigned(Slot),
V));
365 for (
const auto &Arg :
F.args())
367 for (
const auto &BB :
F) {
369 for (
const auto &
I : BB)
384struct ParsedMachineOperand {
388 std::optional<unsigned> TiedDefIdx;
392 std::optional<unsigned> &TiedDefIdx)
393 : Operand(Operand), Begin(Begin),
End(
End), TiedDefIdx(TiedDefIdx) {
396 "Only used register operands can be tied");
403 StringRef
Source, CurrentSource;
405 PerFunctionMIParsingState &PFS;
407 DenseMap<unsigned, const BasicBlock *> Slots2BasicBlocks;
410 MIParser(PerFunctionMIParsingState &PFS, SMDiagnostic &
Error,
415 void lex(
unsigned SkipChar = 0);
428 parseBasicBlockDefinitions(DenseMap<unsigned, MachineBasicBlock *> &MBBSlots);
429 bool parseBasicBlocks();
431 bool parseStandaloneMBB(MachineBasicBlock *&
MBB);
433 bool parseStandaloneVirtualRegister(VRegInfo *&Info);
435 bool parseStandaloneStackObject(
int &FI);
436 bool parseStandaloneMDNode(MDNode *&Node);
439 parseBasicBlockDefinition(DenseMap<unsigned, MachineBasicBlock *> &MBBSlots);
440 bool parseBasicBlock(MachineBasicBlock &
MBB,
441 MachineBasicBlock *&AddFalthroughFrom);
442 bool parseBasicBlockLiveins(MachineBasicBlock &
MBB);
443 bool parseBasicBlockSuccessors(MachineBasicBlock &
MBB);
446 bool parseVirtualRegister(VRegInfo *&Info);
447 bool parseNamedVirtualRegister(VRegInfo *&Info);
448 bool parseRegister(
Register &
Reg, VRegInfo *&VRegInfo);
449 bool parseRegisterFlag(
RegState &Flags);
450 bool parseRegisterClassOrBank(VRegInfo &RegInfo);
451 bool parseSubRegisterIndex(
unsigned &SubReg);
452 bool parseRegisterTiedDefIndex(
unsigned &TiedDefIdx);
453 bool parseRegisterOperand(MachineOperand &Dest,
454 std::optional<unsigned> &TiedDefIdx,
456 bool parseImmediateOperand(MachineOperand &Dest);
457 bool parseInlineAsmOperandCount(InlineAsm::Flag &
F);
458 bool parseSymbolicInlineAsmOperand(
unsigned OpIdx, MachineOperand &Dest);
463 bool parseTypedImmediateOperand(MachineOperand &Dest);
464 bool parseFPImmediateOperand(MachineOperand &Dest);
466 bool parseMBBOperand(MachineOperand &Dest);
467 bool parseStackFrameIndex(
int &FI);
468 bool parseStackObjectOperand(MachineOperand &Dest);
469 bool parseFixedStackFrameIndex(
int &FI);
470 bool parseFixedStackObjectOperand(MachineOperand &Dest);
472 bool parseGlobalAddressOperand(MachineOperand &Dest);
473 bool parseConstantPoolIndexOperand(MachineOperand &Dest);
474 bool parseSubRegisterIndexOperand(MachineOperand &Dest);
475 bool parseJumpTableIndexOperand(MachineOperand &Dest);
476 bool parseExternalSymbolOperand(MachineOperand &Dest);
477 bool parseMCSymbolOperand(MachineOperand &Dest);
479 bool parseDIExpression(MDNode *&Expr);
480 bool parseDILocation(MDNode *&Expr);
481 bool parseMetadataOperand(MachineOperand &Dest);
482 bool parseCFIOffset(int64_t &
Offset);
483 bool parseCFIUnsigned(
unsigned &
Value);
484 bool parseCFIRegister(
unsigned &
Reg);
486 bool parseCFIEscapeValues(std::string&
Values);
487 bool parseCFIOperand(MachineOperand &Dest);
488 bool parseIRBlock(BasicBlock *&BB,
const Function &
F);
489 bool parseBlockAddressOperand(MachineOperand &Dest);
490 bool parseIntrinsicOperand(MachineOperand &Dest);
491 bool parsePredicateOperand(MachineOperand &Dest);
492 bool parseShuffleMaskOperand(MachineOperand &Dest);
493 bool parseTargetIndexOperand(MachineOperand &Dest);
494 bool parseDbgInstrRefOperand(MachineOperand &Dest);
495 bool parseCustomRegisterMaskOperand(MachineOperand &Dest);
496 bool parseLaneMaskOperand(MachineOperand &Dest);
497 bool parseLiveoutRegisterMaskOperand(MachineOperand &Dest);
498 bool parseMachineOperand(
const unsigned OpCode,
const unsigned OpIdx,
499 MachineOperand &Dest,
500 std::optional<unsigned> &TiedDefIdx);
501 bool parseMachineOperandAndTargetFlags(
const unsigned OpCode,
502 const unsigned OpIdx,
503 MachineOperand &Dest,
504 std::optional<unsigned> &TiedDefIdx);
505 bool parseOffset(int64_t &
Offset);
506 bool parseIRBlockAddressTaken(BasicBlock *&BB);
508 bool parseAddrspace(
unsigned &Addrspace);
509 bool parseSectionID(std::optional<MBBSectionID> &SID);
510 bool parseBBID(std::optional<UniqueBBID> &BBID);
511 bool parseCallFrameSize(
unsigned &CallFrameSize);
512 bool parseMaxBytesForAlignment(
unsigned &MaxBytesForAlignment);
514 bool parseOperandsOffset(MachineOperand &
Op);
517 bool parseMemoryPseudoSourceValue(
const PseudoSourceValue *&PSV);
518 bool parseMachinePointerInfo(MachinePointerInfo &Dest);
521 bool parseMachineMemoryOperand(MachineMemOperand *&Dest);
522 bool parsePreOrPostInstrSymbol(MCSymbol *&Symbol);
523 bool parseHeapAllocMarker(MDNode *&Node);
524 bool parsePCSections(MDNode *&Node);
525 bool parseMMRA(MDNode *&Node);
527 bool parseTargetImmMnemonic(
const unsigned OpCode,
const unsigned OpIdx,
528 MachineOperand &Dest,
const MIRFormatter &MF);
555 bool parseInstruction(
unsigned &OpCode,
unsigned &Flags);
557 bool assignRegisterTies(MachineInstr &
MI,
561 const MCInstrDesc &MCID);
567 MCSymbol *getOrCreateMCSymbol(StringRef Name);
571 bool parseStringConstant(std::string &Result);
581void MIParser::lex(
unsigned SkipChar) {
583 CurrentSource.substr(SkipChar), Token,
587bool MIParser::error(
const Twine &
Msg) {
return error(Token.location(),
Msg); }
622 return "<unknown token>";
627 if (Token.isNot(TokenKind))
634 if (Token.isNot(TokenKind))
641bool MIParser::parseSectionID(std::optional<MBBSectionID> &SID) {
647 return error(
"Unknown Section ID");
650 const StringRef &S = Token.stringValue();
651 if (S ==
"Exception")
653 else if (S ==
"Cold")
656 return error(
"Unknown Section ID");
663bool MIParser::parseBBID(std::optional<UniqueBBID> &BBID) {
665 return error(
"expected 'bb_id'");
668 unsigned CloneID = 0;
671 auto Parts = S.
split(
'.');
672 if (Parts.first.getAsInteger(10, BaseID) ||
673 Parts.second.getAsInteger(10, CloneID))
674 return error(
"Unknown BB ID");
678 return error(
"Unknown BB ID");
683 return error(
"Unknown Clone ID");
687 return error(
"Unknown Clone ID");
691 BBID = {BaseID, CloneID};
696bool MIParser::parseCallFrameSize(
unsigned &CallFrameSize) {
701 return error(
"Unknown call frame size");
702 CallFrameSize =
Value;
709bool MIParser::parseMaxBytesForAlignment(
unsigned &MaxBytesForAlignment) {
713 return error(
"expected an integer literal after 'max-bytes-for-alignment'");
717 MaxBytesForAlignment =
Value;
724 std::optional<UniqueBBID> BBID;
733bool MIParser::parseBasicBlockDefinition(
739 auto Loc = Token.location();
740 auto Name = Token.stringValue();
742 bool MachineBlockAddressTaken =
false;
743 bool LabelMustBeEmitted =
false;
745 bool IsLandingPad =
false;
746 bool IsInlineAsmBrIndirectTarget =
false;
747 bool IsEHFuncletEntry =
false;
748 bool IsEHScopeEntry =
false;
749 bool IsCleanupFuncletEntry =
false;
750 bool IsEHContTarget =
false;
751 std::optional<MBBSectionID> SectionID;
753 unsigned MaxBytesForAlignment = 0;
754 std::optional<UniqueBBID> BBID;
755 unsigned CallFrameSize = 0;
760 switch (Token.kind()) {
762 MachineBlockAddressTaken =
true;
766 LabelMustBeEmitted =
true;
770 if (parseIRBlockAddressTaken(AddressTakenIRBlock))
778 IsInlineAsmBrIndirectTarget =
true;
782 IsEHFuncletEntry =
true;
786 IsEHScopeEntry =
true;
790 IsCleanupFuncletEntry =
true;
794 IsEHContTarget =
true;
802 if (parseMaxBytesForAlignment(MaxBytesForAlignment))
808 if (parseIRBlock(BB, MF.getFunction()))
813 if (parseSectionID(SectionID))
821 if (parseCallFrameSize(CallFrameSize))
836 MF.getFunction().getValueSymbolTable()->lookup(Name));
839 "' is not defined in the function '" +
842 auto *
MBB = MF.CreateMachineBasicBlock(BB, BBID);
844 bool WasInserted = MBBSlots.
insert(std::make_pair(ID,
MBB)).second;
846 return error(
Loc,
Twine(
"redefinition of machine basic block with id #") +
850 else if (MaxBytesForAlignment)
851 return error(
Loc,
"'max-bytes-for-alignment' requires 'align'");
853 if (MachineBlockAddressTaken)
855 if (LabelMustBeEmitted)
857 if (AddressTakenIRBlock)
873bool MIParser::parseBasicBlockDefinitions(
879 if (Token.isErrorOrEOF())
880 return Token.isError();
882 return error(
"expected a basic block definition before instructions");
883 unsigned BraceDepth = 0;
885 if (parseBasicBlockDefinition(MBBSlots))
887 bool IsAfterNewline =
false;
891 Token.isErrorOrEOF())
894 return error(
"basic block definition should be located at the start of "
897 IsAfterNewline =
true;
900 IsAfterNewline =
false;
905 return error(
"extraneous closing brace ('}')");
911 if (!Token.isError() && BraceDepth)
912 return error(
"expected '}'");
913 }
while (!Token.isErrorOrEOF());
914 return Token.isError();
922 if (Token.isNewlineOrEOF())
926 return error(
"expected a named register");
928 if (parseNamedRegister(
Reg))
936 return error(
"expected a lane mask");
938 "Use correct get-function for lane mask");
941 return error(
"invalid lane mask value");
955 if (Token.isNewlineOrEOF())
959 return error(
"expected a machine basic block reference");
968 return error(
"expected an integer literal after '('");
1002 bool ExplicitSuccessors =
false;
1005 if (parseBasicBlockSuccessors(
MBB))
1007 ExplicitSuccessors =
true;
1009 if (parseBasicBlockLiveins(
MBB))
1016 if (!Token.isNewlineOrEOF())
1017 return error(
"expected line break at the end of a list");
1022 bool IsInBundle =
false;
1046 return error(
"nested instruction bundles are not allowed");
1055 assert(Token.isNewlineOrEOF() &&
"MI is not fully parsed");
1060 if (!ExplicitSuccessors) {
1067 if (IsFallthrough) {
1068 AddFalthroughFrom = &
MBB;
1077bool MIParser::parseBasicBlocks() {
1082 if (Token.isErrorOrEOF())
1083 return Token.isError();
1092 if (AddFalthroughFrom) {
1096 AddFalthroughFrom =
nullptr;
1098 if (parseBasicBlock(*
MBB, AddFalthroughFrom))
1111 while (Token.isRegister() || Token.isRegisterFlag()) {
1112 auto Loc = Token.location();
1113 std::optional<unsigned> TiedDefIdx;
1114 if (parseRegisterOperand(MO, TiedDefIdx,
true))
1117 ParsedMachineOperand(MO,
Loc, Token.location(), TiedDefIdx));
1126 if (Token.isError() || parseInstruction(OpCode, Flags))
1139 auto Loc = Token.location();
1140 std::optional<unsigned> TiedDefIdx;
1141 if (parseMachineOperandAndTargetFlags(OpCode,
Operands.size(), MO, TiedDefIdx))
1144 ParsedMachineOperand(MO,
Loc, Token.location(), TiedDefIdx));
1149 return error(
"expected ',' before the next machine operand");
1153 MCSymbol *PreInstrSymbol =
nullptr;
1155 if (parsePreOrPostInstrSymbol(PreInstrSymbol))
1157 MCSymbol *PostInstrSymbol =
nullptr;
1159 if (parsePreOrPostInstrSymbol(PostInstrSymbol))
1161 MDNode *HeapAllocMarker =
nullptr;
1163 if (parseHeapAllocMarker(HeapAllocMarker))
1165 MDNode *PCSections =
nullptr;
1167 if (parsePCSections(PCSections))
1172 unsigned CFIType = 0;
1176 return error(
"expected an integer literal after 'cfi-type'");
1194 unsigned InstrNum = 0;
1198 return error(
"expected an integer literal after 'debug-instr-number'");
1215 if (parseDILocation(Node))
1218 return error(
"expected a metadata node after 'debug-location'");
1222 return error(
"referenced metadata is not a DILocation");
1229 while (!Token.isNewlineOrEOF()) {
1231 if (parseMachineMemoryOperand(
MemOp))
1234 if (Token.isNewlineOrEOF())
1239 return error(
"expected ',' before the next machine memory operand");
1244 const auto &
MCID = MF.getSubtarget().getInstrInfo()->get(OpCode);
1245 if (!
MCID.isVariadic()) {
1251 MI = MF.CreateMachineInstr(
MCID, DebugLocation,
true);
1252 MI->setFlags(Flags);
1256 for (
const auto &Operand :
Operands)
1257 MI->addOperand(MF, Operand.Operand);
1262 MI->setPreInstrSymbol(MF, PreInstrSymbol);
1263 if (PostInstrSymbol)
1264 MI->setPostInstrSymbol(MF, PostInstrSymbol);
1265 if (HeapAllocMarker)
1266 MI->setHeapAllocMarker(MF, HeapAllocMarker);
1268 MI->setPCSections(MF, PCSections);
1270 MI->setMMRAMetadata(MF, MMRA);
1272 MI->setCFIType(MF, CFIType);
1274 MI->setDeactivationSymbol(MF, DS);
1275 if (!MemOperands.
empty())
1276 MI->setMemRefs(MF, MemOperands);
1278 MI->setDebugInstrNum(InstrNum);
1285 return error(
"expected a machine basic block reference");
1291 "expected end of string after the machine basic block reference");
1295bool MIParser::parseStandaloneNamedRegister(
Register &
Reg) {
1298 return error(
"expected a named register");
1299 if (parseNamedRegister(
Reg))
1303 return error(
"expected end of string after the register reference");
1307bool MIParser::parseStandaloneVirtualRegister(
VRegInfo *&Info) {
1310 return error(
"expected a virtual register");
1311 if (parseVirtualRegister(Info))
1315 return error(
"expected end of string after the register reference");
1319bool MIParser::parseStandaloneRegister(
Register &
Reg) {
1323 return error(
"expected either a named or virtual register");
1326 if (parseRegister(
Reg, Info))
1331 return error(
"expected end of string after the register reference");
1335bool MIParser::parseStandaloneStackObject(
int &FI) {
1338 return error(
"expected a stack object");
1339 if (parseStackFrameIndex(FI))
1342 return error(
"expected end of string after the stack object reference");
1346bool MIParser::parseStandaloneMDNode(
MDNode *&Node) {
1352 if (parseDIExpression(Node))
1355 if (parseDILocation(Node))
1358 return error(
"expected a metadata node");
1361 return error(
"expected end of string after the metadata node");
1367 return MO.
isDef() ?
"implicit-def" :
"implicit";
1372 assert(
Reg.isPhysical() &&
"expected phys reg");
1400 const auto *
TRI = MF.getSubtarget().getRegisterInfo();
1401 assert(
TRI &&
"Expected target register info");
1402 for (
const auto &
I : ImplicitOperands) {
1406 Twine(
"missing implicit register operand '") +
1413bool MIParser::parseInstruction(
unsigned &OpCode,
unsigned &Flags) {
1488 return error(
"expected a machine instruction");
1489 StringRef InstrName = Token.stringValue();
1490 if (PFS.Target.parseInstrName(InstrName, OpCode))
1491 return error(
Twine(
"unknown machine instruction name '") + InstrName +
"'");
1499 if (PFS.Target.getRegisterByName(Name,
Reg))
1500 return error(
Twine(
"unknown register name '") + Name +
"'");
1504bool MIParser::parseNamedVirtualRegister(
VRegInfo *&Info) {
1509 Info = &PFS.getVRegInfoNamed(Name);
1513bool MIParser::parseVirtualRegister(
VRegInfo *&Info) {
1515 return parseNamedVirtualRegister(Info);
1520 Info = &PFS.getVRegInfo(ID);
1525 switch (Token.kind()) {
1530 return parseNamedRegister(
Reg);
1533 if (parseVirtualRegister(Info))
1543bool MIParser::parseRegisterClassOrBank(
VRegInfo &RegInfo) {
1545 return error(
"expected '_', register class, or register bank name");
1554 switch (RegInfo.
Kind) {
1560 return error(
Loc,
Twine(
"conflicting register classes, previously: ") +
1569 return error(
Loc,
"register class specification on generic register");
1577 RegBank = PFS.Target.getRegBank(Name);
1579 return error(
Loc,
"expected '_', register class, or register bank name");
1584 switch (RegInfo.
Kind) {
1590 return error(
Loc,
"conflicting generic register banks");
1596 return error(
Loc,
"register bank specification on normal register");
1601bool MIParser::parseRegisterFlag(
RegState &Flags) {
1603 switch (Token.kind()) {
1637 if (OldFlags == Flags)
1640 return error(
"duplicate '" + Token.stringValue() +
"' register flag");
1645bool MIParser::parseSubRegisterIndex(
unsigned &SubReg) {
1649 return error(
"expected a subregister index after '.'");
1650 auto Name = Token.stringValue();
1651 SubReg = PFS.Target.getSubRegIndex(Name);
1653 return error(
Twine(
"use of unknown subregister index '") + Name +
"'");
1658bool MIParser::parseRegisterTiedDefIndex(
unsigned &TiedDefIdx) {
1662 return error(
"expected an integer literal after 'tied-def'");
1677 unsigned DefIdx = *
Operands[
I].TiedDefIdx;
1680 Twine(
"use of invalid tied-def operand index '" +
1681 Twine(DefIdx) +
"'; instruction has only ") +
1683 const auto &DefOperand =
Operands[DefIdx].Operand;
1684 if (!DefOperand.isReg() || !DefOperand.isDef())
1687 Twine(
"use of invalid tied-def operand index '") +
1688 Twine(DefIdx) +
"'; the operand #" +
Twine(DefIdx) +
1689 " isn't a defined register");
1691 for (
const auto &TiedPair : TiedRegisterPairs) {
1692 if (TiedPair.first == DefIdx)
1694 Twine(
"the tied-def operand #") +
Twine(DefIdx) +
1695 " is already tied with another register operand");
1697 TiedRegisterPairs.push_back(std::make_pair(DefIdx,
I));
1701 for (
const auto &TiedPair : TiedRegisterPairs)
1702 MI.tieOperands(TiedPair.first, TiedPair.second);
1707 std::optional<unsigned> &TiedDefIdx,
1710 while (Token.isRegisterFlag()) {
1711 if (parseRegisterFlag(Flags))
1716 if (!Token.isRegister())
1717 return error(
"expected a register after register flags");
1720 if (parseRegister(
Reg, RegInfo))
1723 unsigned SubReg = 0;
1725 if (parseSubRegisterIndex(SubReg))
1728 return error(
"subregister index expects a virtual register");
1732 return error(
"register class specification expects a virtual register");
1734 if (parseRegisterClassOrBank(*RegInfo))
1743 return error(
"tied-def not supported for defs");
1745 if (parseRegisterTiedDefIndex(Idx))
1750 return error(
"unexpected type on physical register");
1754 if (parseLowLevelType(Token.location(), Ty))
1756 :
error(
"expected tied-def or low-level type after '('");
1763 return error(
"inconsistent type for generic virtual register");
1773 return error(
"generic virtual registers must have a type");
1778 return error(
"cannot have a killed def operand");
1781 return error(
"cannot have a dead use operand");
1798 const APSInt &
Int = Token.integerValue();
1799 if (
auto SImm =
Int.trySExtValue();
Int.isSigned() && SImm.has_value())
1801 else if (
auto UImm =
Int.tryZExtValue(); !
Int.isSigned() && UImm.has_value())
1804 return error(
"integer literal is too large to be an immediate operand");
1817 return error(
"expected ':' after 'ops'");
1821 return error(
"expected an operand count after 'ops:'");
1828 return error(
"invalid inline asm operand count");
1830 F.setNumOperandRegisters(
NumOps);
1835bool MIParser::parseSymbolicInlineAsmOperand(
unsigned OpIdx,
1839 "expected symbolic inline asm operand");
1843 unsigned ExtraInfo = 0;
1848 StringRef FlagName = Token.stringValue();
1856 .
Case(
"attdialect", 0)
1860 return error(
"unknown inline asm extra info flag '" + FlagName +
"'");
1872 StringRef KindStr = Token.stringValue();
1884 if (K == InvalidKind)
1885 return error(
"unknown inline asm operand kind '" + KindStr +
"'");
1896 return error(
"expected ':' after 'tiedto'");
1899 return error(
"expected '$N' operand number after 'tiedto:'");
1901 if (Token.stringValue().getAsInteger(10, OperandNo))
1902 return error(
"invalid operand number in tiedto constraint");
1905 F.setMatchingOp(OperandNo);
1906 if (parseInlineAsmOperandCount(
F))
1919 "expected register class or memory constraint name after ':'");
1921 StringRef ConstraintStr = Token.stringValue();
1922 if (
F.isMemKind() ||
F.isFuncKind()) {
1956 return error(
"unknown memory constraint '" + ConstraintStr +
"'");
1957 F.setMemConstraint(
CC);
1958 }
else if (
F.isRegDefKind() ||
F.isRegUseKind() ||
1959 F.isRegDefEarlyClobberKind()) {
1961 PFS.Target.getRegClass(ConstraintStr.
lower());
1963 return error(
"unknown register class '" + ConstraintStr +
"'");
1964 F.setRegClass(RC->
getID());
1974 if (!
F.isRegDefKind() && !
F.isRegUseKind() && !
F.isRegDefEarlyClobberKind())
1975 return error(
"only a register operand can be 'foldable'");
1977 F.setRegMayBeFolded(
true);
1981 if (parseInlineAsmOperandCount(
F))
1988bool MIParser::parseTargetImmMnemonic(
const unsigned OpCode,
1989 const unsigned OpIdx,
1993 auto Loc = Token.location();
1999 Len += Token.range().size();
2008 Src =
StringRef(
Loc, Len + Token.stringValue().size());
2013 ->
bool { return error(Loc, Msg); }))
2025 auto Source = StringValue.
str();
2030 return ErrCB(
Loc + Err.getColumnNo(), Err.getMessage());
2036 return ::parseIRConstant(
2037 Loc, StringValue, PFS,
C,
2057 return NumElts != 0 && (HasVScale || NumElts != 1) &&
isUInt<16>(NumElts);
2071 "expected integers after 's'/'i'/'f'/'bf'/'p' type identifier");
2074 bool Scalar = Token.range().starts_with(
"s");
2075 if (Scalar || Token.range().starts_with(
"i")) {
2084 return error(
"invalid size for scalar type");
2091 if (Token.range().starts_with(
"p")) {
2095 return error(
"invalid address space number");
2102 if (Token.range().starts_with(
"f") || Token.range().starts_with(
"bf")) {
2105 return error(
"invalid size for scalar type");
2107 if (Token.range().starts_with(
"bf") && ScalarSize != 16)
2108 return error(
"invalid size for bfloat");
2111 :
LLT::floatIEEE(ScalarSize);
2118 return error(
Loc,
"expected tN, pA, <M x tN>, <M x pA>, <vscale x M x tN>, "
2119 "or <vscale x M x pA> for GlobalISel type, "
2120 "where t = {'s', 'i', 'f', 'bf'}");
2129 "expected <vscale x M x tN>, where t = {'s', 'i', 'f', 'bf', 'p'}");
2133 auto GetError = [
this, &HasVScale,
Loc]() {
2135 return error(
Loc,
"expected <vscale x M x tN> for vector type, where t = "
2136 "{'s', 'i', 'f', 'bf', 'p'}");
2137 return error(
Loc,
"expected <M x tN> for vector type, where t = {'s', 'i', "
2143 uint64_t NumElements = Token.integerValue().getZExtValue();
2145 return error(
"invalid number of vector elements");
2153 StringRef VectorTyDigits = Token.range();
2162 "expected integers after 's'/'i'/'f'/'bf'/'p' type identifier");
2164 Scalar = Token.range().starts_with(
"s");
2165 if (Scalar || Token.range().starts_with(
"i")) {
2168 return error(
"invalid size for scalar element in vector");
2170 }
else if (Token.range().starts_with(
"p")) {
2174 return error(
"invalid address space number");
2177 }
else if (Token.range().starts_with(
"f")) {
2180 return error(
"invalid size for float element in vector");
2182 }
else if (Token.range().starts_with(
"bf")) {
2185 return error(
"invalid size for bfloat element in vector");
2207 return error(
"a typed immediate operand should start with one of 'i', "
2208 "'s', 'f', 'bf', or 'p'");
2211 "expected integers after 'i'/'s'/'f'/'bf'/'p' type identifier");
2213 auto Loc = Token.location();
2217 !(Token.range() ==
"true" || Token.range() ==
"false"))
2218 return error(
"expected an integer literal");
2228 auto Loc = Token.location();
2232 return error(
"expected a floating point literal");
2243 assert(S[0] ==
'0' && tolower(S[1]) ==
'x');
2245 if (!isxdigit(S[2]))
2252 unsigned NumBits = (
A == 0) ? 32 :
A.getActiveBits();
2263 return ErrCB(Token.
location(),
"expected unsigned integer");
2266 return ErrCB(Token.
location(),
"expected 32-bit integer (too large)");
2274 if (
A.getBitWidth() > 32)
2275 return ErrCB(Token.
location(),
"expected 32-bit integer (too large)");
2276 Result =
A.getZExtValue();
2282bool MIParser::getUnsigned(
unsigned &Result) {
2283 return ::getUnsigned(
2295 auto MBBInfo = PFS.MBBSlots.find(
Number);
2296 if (MBBInfo == PFS.MBBSlots.end())
2297 return error(
Twine(
"use of undefined machine basic block #") +
2299 MBB = MBBInfo->second;
2302 if (!Token.stringValue().empty() && Token.stringValue() !=
MBB->
getName())
2304 " isn't '" + Token.stringValue() +
"'");
2317bool MIParser::parseStackFrameIndex(
int &FI) {
2322 auto ObjectInfo = PFS.StackObjectSlots.find(ID);
2323 if (ObjectInfo == PFS.StackObjectSlots.end())
2324 return error(
Twine(
"use of undefined stack object '%stack.") +
Twine(ID) +
2327 if (
const auto *Alloca =
2328 MF.getFrameInfo().getObjectAllocation(ObjectInfo->second))
2329 Name = Alloca->getName();
2330 if (!Token.stringValue().empty() && Token.stringValue() != Name)
2331 return error(
Twine(
"the name of the stack object '%stack.") +
Twine(ID) +
2332 "' isn't '" + Token.stringValue() +
"'");
2334 FI = ObjectInfo->second;
2340 if (parseStackFrameIndex(FI))
2346bool MIParser::parseFixedStackFrameIndex(
int &FI) {
2351 auto ObjectInfo = PFS.FixedStackObjectSlots.find(ID);
2352 if (ObjectInfo == PFS.FixedStackObjectSlots.end())
2353 return error(
Twine(
"use of undefined fixed stack object '%fixed-stack.") +
2356 FI = ObjectInfo->second;
2360bool MIParser::parseFixedStackObjectOperand(
MachineOperand &Dest) {
2362 if (parseFixedStackFrameIndex(FI))
2371 switch (Token.
kind()) {
2376 return ErrCB(Token.
location(),
Twine(
"use of undefined global value '") +
2377 Token.
range() +
"'");
2386 return ErrCB(Token.
location(),
Twine(
"use of undefined global value '@") +
2387 Twine(GVIdx) +
"'");
2396bool MIParser::parseGlobalValue(
GlobalValue *&GV) {
2397 return ::parseGlobalValue(
2410 if (parseOperandsOffset(Dest))
2415bool MIParser::parseConstantPoolIndexOperand(
MachineOperand &Dest) {
2422 return error(
"use of undefined constant '%const." +
Twine(ID) +
"'");
2425 if (parseOperandsOffset(Dest))
2435 auto JumpTableEntryInfo = PFS.JumpTableSlots.find(ID);
2436 if (JumpTableEntryInfo == PFS.JumpTableSlots.end())
2437 return error(
"use of undefined jump table '%jump-table." +
Twine(ID) +
"'");
2445 const char *
Symbol = MF.createExternalSymbolName(Token.stringValue());
2448 if (parseOperandsOffset(Dest))
2458 if (parseOperandsOffset(Dest))
2463bool MIParser::parseSubRegisterIndexOperand(
MachineOperand &Dest) {
2466 unsigned SubRegIndex = PFS.Target.getSubRegIndex(Token.stringValue());
2467 if (SubRegIndex == 0)
2468 return error(
Twine(
"unknown subregister index '") + Name +
"'");
2474bool MIParser::parseMDNode(
MDNode *&Node) {
2477 auto Loc = Token.location();
2480 return error(
"expected metadata id after '!'");
2484 auto NodeInfo = PFS.IRSlots.MetadataNodes.find(ID);
2485 if (NodeInfo == PFS.IRSlots.MetadataNodes.end()) {
2486 NodeInfo = PFS.MachineMetadataNodes.find(ID);
2487 if (NodeInfo == PFS.MachineMetadataNodes.end())
2488 return error(
Loc,
"use of undefined metadata '!" +
Twine(ID) +
"'");
2491 Node = NodeInfo->second.get();
2495bool MIParser::parseDIExpression(
MDNode *&Expr) {
2498 CurrentSource,
Read,
Error, *PFS.MF.getFunction().getParent(),
2500 CurrentSource = CurrentSource.substr(
Read);
2507bool MIParser::parseDILocation(
MDNode *&
Loc) {
2511 bool HaveLine =
false;
2513 unsigned Column = 0;
2515 MDNode *InlinedAt =
nullptr;
2516 bool ImplicitCode =
false;
2519 MDNode *IRLayers =
nullptr;
2527 if (Token.stringValue() ==
"line") {
2532 Token.integerValue().isSigned())
2533 return error(
"expected unsigned integer");
2534 Line = Token.integerValue().getZExtValue();
2539 if (Token.stringValue() ==
"column") {
2544 Token.integerValue().isSigned())
2545 return error(
"expected unsigned integer");
2546 Column = Token.integerValue().getZExtValue();
2550 if (Token.stringValue() ==
"scope") {
2555 return error(
"expected metadata node");
2557 return error(
"expected DIScope node");
2560 if (Token.stringValue() ==
"inlinedAt") {
2568 if (parseDILocation(InlinedAt))
2571 return error(
"expected metadata node");
2574 return error(
"expected DILocation node");
2577 if (Token.stringValue() ==
"isImplicitCode") {
2582 return error(
"expected true/false");
2586 if (Token.stringValue() ==
"true")
2587 ImplicitCode =
true;
2588 else if (Token.stringValue() ==
"false")
2589 ImplicitCode =
false;
2591 return error(
"expected true/false");
2595 if (Token.stringValue() ==
"atomGroup") {
2600 Token.integerValue().isSigned())
2601 return error(
"expected unsigned integer");
2602 AtomGroup = Token.integerValue().getZExtValue();
2606 if (Token.stringValue() ==
"atomRank") {
2611 Token.integerValue().isSigned())
2612 return error(
"expected unsigned integer");
2613 AtomRank = Token.integerValue().getZExtValue();
2617 if (Token.stringValue() ==
"irlayers") {
2622 return error(
"expected metadata node");
2624 return error(
"expected DILayerLocList node");
2628 return error(
Twine(
"invalid DILocation argument '") +
2629 Token.stringValue() +
"'");
2637 return error(
"DILocation requires line number");
2639 return error(
"DILocation requires a scope");
2642 InlinedAt, ImplicitCode, AtomGroup, AtomRank, IRLayers);
2652 if (parseDIExpression(Node))
2659bool MIParser::parseCFIOffset(int64_t &
Offset) {
2661 return error(
"expected a cfi offset");
2662 if (!Token.integerValue().isRepresentableByInt64())
2663 return error(
"expected a 64 bit integer (the cfi offset is too large)");
2664 Offset = Token.integerValue().getExtValue();
2669bool MIParser::parseCFIUnsigned(
unsigned &
Value) {
2676bool MIParser::parseCFIRegister(
unsigned &
Reg) {
2678 return error(
"expected a cfi register");
2680 if (parseNamedRegister(LLVMReg))
2682 const auto *
TRI = MF.getSubtarget().getRegisterInfo();
2683 assert(
TRI &&
"Expected target register info");
2684 int DwarfReg =
TRI->getDwarfRegNum(LLVMReg,
true);
2686 return error(
"invalid DWARF register");
2687 Reg = (unsigned)DwarfReg;
2692bool MIParser::parseCFIAddressSpace(
unsigned &
AddressSpace) {
2694 return error(
"expected a cfi address space literal");
2698bool MIParser::parseCFIEscapeValues(std::string &
Values) {
2701 return error(
"expected a hexadecimal literal");
2705 if (
Value > UINT8_MAX)
2706 return error(
"expected a 8-bit integer (too large)");
2714 auto Kind = Token.kind();
2722 if (parseCFIRegister(
Reg))
2737 CFIIndex = MF.addFrameInst(
2741 if (parseCFIRegister(
Reg))
2747 if (parseCFIOffset(
Offset))
2753 if (parseCFIOffset(
Offset))
2755 CFIIndex = MF.addFrameInst(
2777 if (parseCFIRegister(
Reg))
2785 if (parseCFIRegister(
Reg))
2792 parseCFIRegister(Reg2))
2815 PACSym = getOrCreateMCSymbol(Token.stringValue());
2817 CFIIndex = MF.addFrameInst(
2821 if (parseCFIOffset(
Offset))
2823 CFIIndex = MF.addFrameInst(
2826 return error(
"expected '<mcsymbol ...>' or integer offset for "
2827 "cfi_set_ra_state");
2832 unsigned Reg, R1,
R2;
2833 unsigned R1Size, R2Size;
2838 parseCFIUnsigned(R2Size))
2842 nullptr,
Reg, R1, R1Size,
R2, R2Size));
2846 std::vector<MCCFIInstruction::VectorRegisterWithLane> VectorRegisters;
2851 unsigned Lane,
Size;
2854 parseCFIUnsigned(
Size))
2856 VectorRegisters.push_back({VR, Lane,
Size});
2860 nullptr,
Reg, std::move(VectorRegisters)));
2864 unsigned Reg, MaskReg;
2865 unsigned RegSize, MaskRegSize;
2871 parseCFIUnsigned(MaskRegSize) || expectAndConsume(
MIToken::comma) ||
2880 unsigned Reg, SpillReg, MaskReg;
2881 unsigned SpillRegLaneSize, MaskRegSize;
2884 parseCFIRegister(SpillReg) || expectAndConsume(
MIToken::comma) ||
2885 parseCFIUnsigned(SpillRegLaneSize) ||
2887 expectAndConsume(
MIToken::comma) || parseCFIUnsigned(MaskRegSize))
2891 nullptr,
Reg, SpillReg, SpillRegLaneSize, MaskReg, MaskRegSize));
2896 if (parseCFIEscapeValues(
Values))
2910 switch (Token.kind()) {
2913 F.getValueSymbolTable()->lookup(Token.stringValue()));
2915 return error(
Twine(
"use of undefined IR block '") + Token.range() +
"'");
2919 unsigned SlotNumber = 0;
2922 BB =
const_cast<BasicBlock *
>(getIRBlock(SlotNumber,
F));
2924 return error(
Twine(
"use of undefined IR block '%ir-block.") +
2925 Twine(SlotNumber) +
"'");
2941 return error(
"expected a global value");
2947 return error(
"expected an IR function reference");
2953 return error(
"expected an IR block reference");
2954 if (parseIRBlock(BB, *
F))
2960 if (parseOperandsOffset(Dest))
2969 return error(
"expected syntax intrinsic(@llvm.whatever)");
2972 return error(
"expected syntax intrinsic(@llvm.whatever)");
2974 std::string
Name = std::string(Token.stringValue());
2978 return error(
"expected ')' to terminate intrinsic name");
2983 return error(
"unknown intrinsic name");
2995 return error(
"expected syntax intpred(whatever) or floatpred(whatever");
2998 return error(
"whatever");
3021 return error(
"invalid floating-point predicate");
3036 return error(
"invalid integer predicate");
3042 return error(
"predicate should be terminated by ')'.");
3052 return error(
"expected syntax shufflemask(<integer or undef>, ...)");
3059 const APSInt &
Int = Token.integerValue();
3062 return error(
"expected integer constant");
3069 return error(
"shufflemask should be terminated by ')'.");
3071 if (ShufMask.
size() < 2)
3072 return error(
"shufflemask should have > 1 element");
3084 return error(
"expected syntax dbg-instr-ref(<unsigned>, <unsigned>)");
3087 return error(
"expected unsigned integer for instruction index");
3088 uint64_t InstrIdx = Token.integerValue().getZExtValue();
3089 assert(InstrIdx <= std::numeric_limits<unsigned>::max() &&
3090 "Instruction reference's instruction index is too large");
3094 return error(
"expected syntax dbg-instr-ref(<unsigned>, <unsigned>)");
3097 return error(
"expected unsigned integer for operand index");
3098 uint64_t OpIdx = Token.integerValue().getZExtValue();
3099 assert(OpIdx <= std::numeric_limits<unsigned>::max() &&
3100 "Instruction reference's operand index is too large");
3104 return error(
"expected syntax dbg-instr-ref(<unsigned>, <unsigned>)");
3116 return error(
"expected the name of the target index");
3118 if (PFS.Target.getTargetIndex(Token.stringValue(), Index))
3119 return error(
"use of undefined target index '" + Token.stringValue() +
"'");
3124 if (parseOperandsOffset(Dest))
3129bool MIParser::parseCustomRegisterMaskOperand(
MachineOperand &Dest) {
3130 assert(Token.stringValue() ==
"CustomRegMask" &&
"Expected a custom RegMask");
3135 uint32_t *
Mask = MF.allocateRegMask();
3139 return error(
"expected a named register");
3141 if (parseNamedRegister(
Reg))
3165 return error(
"expected a valid lane mask value");
3167 "Use correct get-function for lane mask.");
3181bool MIParser::parseLiveoutRegisterMaskOperand(
MachineOperand &Dest) {
3183 uint32_t *
Mask = MF.allocateRegMask();
3189 return error(
"expected a named register");
3191 if (parseNamedRegister(
Reg))
3206bool MIParser::parseMachineOperand(
const unsigned OpCode,
const unsigned OpIdx,
3208 std::optional<unsigned> &TiedDefIdx) {
3209 switch (Token.kind()) {
3224 return parseRegisterOperand(Dest, TiedDefIdx);
3228 return parseImmediateOperand(Dest);
3236 return parseFPImmediateOperand(Dest);
3238 return parseMBBOperand(Dest);
3240 return parseStackObjectOperand(Dest);
3242 return parseFixedStackObjectOperand(Dest);
3245 return parseGlobalAddressOperand(Dest);
3247 return parseConstantPoolIndexOperand(Dest);
3249 return parseJumpTableIndexOperand(Dest);
3251 return parseExternalSymbolOperand(Dest);
3253 return parseMCSymbolOperand(Dest);
3255 return parseSubRegisterIndexOperand(Dest);
3258 return parseMetadataOperand(Dest);
3281 return parseCFIOperand(Dest);
3283 return parseBlockAddressOperand(Dest);
3285 return parseIntrinsicOperand(Dest);
3287 return parseTargetIndexOperand(Dest);
3289 return parseLaneMaskOperand(Dest);
3291 return parseLiveoutRegisterMaskOperand(Dest);
3294 return parsePredicateOperand(Dest);
3296 return parseShuffleMaskOperand(Dest);
3298 return parseDbgInstrRefOperand(Dest);
3302 bool IsInlineAsm =
OpCode == TargetOpcode::INLINEASM ||
3303 OpCode == TargetOpcode::INLINEASM_BR;
3305 return parseSymbolicInlineAsmOperand(OpIdx, Dest);
3308 if (
const auto *RegMask = PFS.Target.getRegMask(Id)) {
3312 }
else if (Id ==
"CustomRegMask") {
3313 return parseCustomRegisterMaskOperand(Dest);
3315 return parseTypedImmediateOperand(Dest);
3319 const auto *
TII = MF.getSubtarget().getInstrInfo();
3320 if (
const auto *Formatter =
TII->getMIRFormatter()) {
3321 return parseTargetImmMnemonic(OpCode, OpIdx, Dest, *Formatter);
3327 return error(
"expected a machine operand");
3332bool MIParser::parseMachineOperandAndTargetFlags(
3333 const unsigned OpCode,
const unsigned OpIdx,
MachineOperand &Dest,
3334 std::optional<unsigned> &TiedDefIdx) {
3336 bool HasTargetFlags =
false;
3338 HasTargetFlags =
true;
3343 return error(
"expected the name of the target flag");
3344 if (PFS.Target.getDirectTargetFlag(Token.stringValue(), TF)) {
3345 if (PFS.Target.getBitmaskTargetFlag(Token.stringValue(), TF))
3346 return error(
"use of undefined target flag '" + Token.stringValue() +
3353 return error(
"expected the name of the target flag");
3354 unsigned BitFlag = 0;
3355 if (PFS.Target.getBitmaskTargetFlag(Token.stringValue(), BitFlag))
3356 return error(
"use of undefined target flag '" + Token.stringValue() +
3365 auto Loc = Token.location();
3366 if (parseMachineOperand(OpCode, OpIdx, Dest, TiedDefIdx))
3368 if (!HasTargetFlags)
3371 return error(
Loc,
"register operands can't have target flags");
3376bool MIParser::parseOffset(int64_t &
Offset) {
3383 return error(
"expected an integer literal after '" +
Sign +
"'");
3384 if (Token.integerValue().getSignificantBits() > 64)
3385 return error(
"expected 64-bit integer (too large)");
3386 Offset = Token.integerValue().getExtValue();
3393bool MIParser::parseIRBlockAddressTaken(
BasicBlock *&BB) {
3397 return error(
"expected basic block after 'ir_block_address_taken'");
3399 if (parseIRBlock(BB, MF.getFunction()))
3406bool MIParser::parseAlignment(
uint64_t &Alignment) {
3410 return error(
"expected an integer literal after 'align'");
3411 if (getUint64(Alignment))
3416 return error(
"expected a power-of-2 literal after 'align'");
3421bool MIParser::parseAddrspace(
unsigned &Addrspace) {
3425 return error(
"expected an integer literal after 'addrspace'");
3442 switch (Token.
kind()) {
3448 unsigned SlotNumber = 0;
3476 return ErrCB(Token.
location(),
Twine(
"use of undefined IR value '") + Token.
range() +
"'");
3480bool MIParser::parseIRValue(
const Value *&
V) {
3481 return ::parseIRValue(
3487bool MIParser::getUint64(
uint64_t &Result) {
3488 if (Token.hasIntegerValue()) {
3489 if (Token.integerValue().getActiveBits() > 64)
3490 return error(
"expected 64-bit integer (too large)");
3491 Result = Token.integerValue().getZExtValue();
3498 if (
A.getBitWidth() > 64)
3499 return error(
"expected 64-bit integer (too large)");
3506bool MIParser::getHexUint(
APInt &Result) {
3507 return ::getHexUint(Token, Result);
3511 const auto OldFlags =
Flags;
3512 switch (Token.kind()) {
3527 if (PFS.Target.getMMOTargetFlag(Token.stringValue(), TF))
3528 return error(
"use of undefined target MMO flag '" + Token.stringValue() +
3536 if (OldFlags == Flags)
3539 return error(
"duplicate '" + Token.stringValue() +
"' memory operand flag");
3545 switch (Token.kind()) {
3547 PSV = MF.getPSVManager().getStack();
3550 PSV = MF.getPSVManager().getGOT();
3553 PSV = MF.getPSVManager().getJumpTable();
3556 PSV = MF.getPSVManager().getConstantPool();
3560 if (parseFixedStackFrameIndex(FI))
3562 PSV = MF.getPSVManager().getFixedStack(FI);
3568 if (parseStackFrameIndex(FI))
3570 PSV = MF.getPSVManager().getFixedStack(FI);
3576 switch (Token.kind()) {
3582 PSV = MF.getPSVManager().getGlobalValueCallEntry(GV);
3586 PSV = MF.getPSVManager().getExternalSymbolCallEntry(
3587 MF.createExternalSymbolName(Token.stringValue()));
3591 "expected a global value or an external symbol after 'call-entry'");
3596 const auto *
TII = MF.getSubtarget().getInstrInfo();
3597 if (
const auto *Formatter =
TII->getMIRFormatter()) {
3598 if (Formatter->parseCustomPseudoSourceValue(
3599 Token.stringValue(), MF, PFS, PSV,
3601 return error(Loc, Msg);
3605 return error(
"unable to parse target custom pseudo source value");
3622 if (parseMemoryPseudoSourceValue(PSV))
3635 return error(
"expected an IR value reference");
3636 const Value *
V =
nullptr;
3639 if (
V && !
V->getType()->isPointerTy())
3640 return error(
"expected a pointer IR value");
3655 return error(
"expected '(' in syncscope");
3658 if (parseStringConstant(SSN))
3661 SSID =
Context.getOrInsertSyncScopeID(SSN);
3663 return error(
"expected ')' in syncscope");
3669bool MIParser::parseOptionalAtomicOrdering(
AtomicOrdering &Order) {
3688 return error(
"expected an atomic scope, ordering or a size specification");
3695 while (Token.isMemoryOperandFlag()) {
3696 if (parseMemoryOperandFlag(Flags))
3700 (Token.stringValue() !=
"load" && Token.stringValue() !=
"store"))
3701 return error(
"expected 'load' or 'store' memory operation");
3702 if (Token.stringValue() ==
"load")
3716 if (parseOptionalScope(MF.getFunction().getContext(), SSID))
3721 if (parseOptionalAtomicOrdering(Order))
3724 if (parseOptionalAtomicOrdering(FailureOrder))
3730 return error(
"expected memory LLT, the size integer literal or 'unknown-size' after "
3731 "memory operation");
3736 if (getUint64(
Size))
3747 if (parseLowLevelType(Token.location(), MemoryType))
3760 if (Token.stringValue() != Word)
3761 return error(
Twine(
"expected '") + Word +
"'");
3764 if (parseMachinePointerInfo(Ptr))
3773 MDNode *MemCacheHint =
nullptr;
3775 switch (Token.kind()) {
3781 if (Ptr.
Offset & (Alignment - 1)) {
3786 return error(
"specified alignment is more aligned than offset");
3832 return error(
"expected 'align' or '!tbaa' or '!alias.scope' or "
3833 "'!noalias' or '!range' or '!mem.cache_hint' or "
3834 "'!noalias.addrspace'");
3839 Dest = MF.getMachineMemOperand(Ptr, Flags, MemoryType,
Align(BaseAlignment),
3841 Order, FailureOrder);
3845bool MIParser::parsePreOrPostInstrSymbol(
MCSymbol *&Symbol) {
3848 "Invalid token for a pre- post-instruction symbol!");
3851 return error(
"expected a symbol after 'pre-instr-symbol'");
3852 Symbol = getOrCreateMCSymbol(Token.stringValue());
3858 return error(
"expected ',' before the next machine operand");
3863bool MIParser::parseHeapAllocMarker(
MDNode *&Node) {
3865 "Invalid token for a heap alloc marker!");
3870 return error(
"expected a MDNode after 'heap-alloc-marker'");
3875 return error(
"expected ',' before the next machine operand");
3880bool MIParser::parsePCSections(
MDNode *&Node) {
3882 "Invalid token for a PC sections!");
3887 return error(
"expected a MDNode after 'pcsections'");
3892 return error(
"expected ',' before the next machine operand");
3897bool MIParser::parseMMRA(
MDNode *&Node) {
3906 return error(
"expected ',' before the next machine operand");
3916 for (
const auto &BB :
F) {
3922 Slots2BasicBlocks.
insert(std::make_pair(
unsigned(Slot), &BB));
3929 return Slots2BasicBlocks.
lookup(Slot);
3932const BasicBlock *MIParser::getIRBlock(
unsigned Slot) {
3933 if (Slots2BasicBlocks.empty())
3939 if (&
F == &MF.getFunction())
3940 return getIRBlock(Slot);
3952 return MF.getContext().getOrCreateSymbol(Name);
3955bool MIParser::parseStringConstant(std::string &Result) {
3957 return error(
"expected string constant");
3958 Result = std::string(Token.stringValue());
3966 return MIParser(PFS,
Error, Src).parseBasicBlockDefinitions(PFS.
MBBSlots);
3971 return MIParser(PFS,
Error, Src).parseBasicBlocks();
3977 return MIParser(PFS,
Error, Src).parseStandaloneMBB(
MBB);
3983 return MIParser(PFS,
Error, Src).parseStandaloneRegister(Reg);
3989 return MIParser(PFS,
Error, Src).parseStandaloneNamedRegister(Reg);
3995 return MIParser(PFS,
Error, Src).parseStandaloneVirtualRegister(Info);
4000 return MIParser(PFS,
Error, Src).parseStandaloneStackObject(FI);
4006 return MIParser(PFS,
Error, Src).parsePrefetchTarget(
Target);
4010 return MIParser(PFS,
Error, Src).parseStandaloneMDNode(
Node);
4022 return ::parseIRValue(Token, PFS, V, ErrorCallback);
const AArch64Subtarget & Subtarget
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
This file implements a class to represent arbitrary precision integral constant values and operations...
This file implements the APSInt class, which is a simple class that represents an arbitrary sized int...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Atomic ordering constants.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static Error parseAlignment(StringRef Str, Align &Alignment, StringRef Name, bool AllowZero=false)
Attempts to parse an alignment component of a specification.
This file defines the DenseMap class.
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
A common definition of LaneBitmask for use in TableGen and CodeGen.
static llvm::Error parse(GsymDataExtractor &Data, uint64_t BaseAddr, LineEntryCallback const &Callback)
Implement a low-level type suitable for MachineInstr level instruction selection.
static const char * printImplicitRegisterFlag(const MachineOperand &MO)
static bool verifyVectorElementCount(uint64_t NumElts, bool HasVScale)
static const BasicBlock * getIRBlockFromSlot(unsigned Slot, const DenseMap< unsigned, const BasicBlock * > &Slots2BasicBlocks)
static std::string getRegisterName(const TargetRegisterInfo *TRI, Register Reg)
static bool parseIRConstant(StringRef::iterator Loc, StringRef StringValue, PerFunctionMIParsingState &PFS, const Constant *&C, ErrorCallbackType ErrCB)
static void initSlots2Values(const Function &F, DenseMap< unsigned, const Value * > &Slots2Values)
Creates the mapping from slot numbers to function's unnamed IR values.
static bool parseIRValue(const MIToken &Token, PerFunctionMIParsingState &PFS, const Value *&V, ErrorCallbackType ErrCB)
static bool verifyScalarSize(uint64_t Size)
static bool getUnsigned(const MIToken &Token, unsigned &Result, ErrorCallbackType ErrCB)
static bool getHexUint(const MIToken &Token, APInt &Result)
static void mapValueToSlot(const Value *V, ModuleSlotTracker &MST, DenseMap< unsigned, const Value * > &Slots2Values)
static void initSlots2BasicBlocks(const Function &F, DenseMap< unsigned, const BasicBlock * > &Slots2BasicBlocks)
function_ref< bool(StringRef::iterator Loc, const Twine &)> ErrorCallbackType
static bool isImplicitOperandIn(const MachineOperand &ImplicitOperand, ArrayRef< ParsedMachineOperand > Operands)
Return true if the parsed machine operands contain a given machine operand.
static bool parseGlobalValue(const MIToken &Token, PerFunctionMIParsingState &PFS, GlobalValue *&GV, ErrorCallbackType ErrCB)
static bool verifyAddrSpace(uint64_t AddrSpace)
Register const TargetRegisterInfo * TRI
Promote Memory to Register
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
MachineRegisterInfo & MRI
This file defines the SmallVector class.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Class for arbitrary precision integers.
uint64_t getZExtValue() const
Get zero extended value.
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value.
An arbitrary precision integer that knows its signedness.
bool isNegative() const
Determine sign of this APSInt.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
LLVM Basic Block Representation.
static LLVM_ABI BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
static constexpr BranchProbability getRaw(uint32_t N)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
@ ICMP_SLT
signed less than
@ ICMP_SLE
signed less or equal
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ ICMP_UGE
unsigned greater or equal
@ ICMP_UGT
unsigned greater than
@ ICMP_SGT
signed greater than
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ ICMP_ULT
unsigned less than
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
@ ICMP_SGE
signed greater or equal
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ ICMP_ULE
unsigned less or equal
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
static bool isFPPredicate(Predicate P)
static bool isIntPredicate(Predicate P)
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
ValueT lookup(const_arg_type_t< KeyT > Val) const
Return the entry for the specified key, or a default constructed value if no such entry exists.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
Lightweight error class with error context and mandatory checking.
ValueSymbolTable * getValueSymbolTable()
getSymbolTable() - Return the symbol table if any, otherwise nullptr.
Module * getParent()
Get the module that this global value is contained inside of...
static constexpr unsigned getMaxNumOperandRegisters()
The largest number of operands that a flag can describe.
static constexpr LLT vector(ElementCount EC, unsigned ScalarSizeInBits)
Get a low-level vector of some number of elements and element width.
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
constexpr bool isValid() const
static constexpr LLT pointer(unsigned AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space.
static constexpr LLT token()
Get a low-level token; just a scalar with zero bits (or no size).
static constexpr LLT bfloat16()
static LLT floatIEEE(unsigned SizeInBits)
This is an important class for using LLVM in a threaded context.
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_def_cfa_register modifies a rule for computing CFA.
static MCCFIInstruction createLLVMVectorOffset(MCSymbol *L, unsigned Register, unsigned RegisterSizeInBits, unsigned MaskRegister, unsigned MaskRegisterSizeInBits, int64_t Offset, SMLoc Loc={})
.cfi_llvm_vector_offset Previous value of Register is saved at Offset from CFA.
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_undefined From now on the previous value of Register can't be restored anymore.
static MCCFIInstruction createLLVMVectorRegisters(MCSymbol *L, unsigned Register, ArrayRef< VectorRegisterWithLane > VectorRegisters, SMLoc Loc={})
.cfi_llvm_vector_registers Previous value of Register is saved in lanes of vector registers.
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_restore says that the rule for Register is now the same as it was at the beginning of the functi...
static MCCFIInstruction createSetRAState(MCSymbol *L, unsigned State, MCSymbol *PACSym=nullptr, SMLoc Loc={})
.cfi_set_ra_state AArch64 set RA sign state,
static MCCFIInstruction createLLVMDefAspaceCfa(MCSymbol *L, unsigned Register, int64_t Offset, unsigned AddressSpace, SMLoc Loc)
.cfi_llvm_def_aspace_cfa defines the rule for computing the CFA to be the result of evaluating the DW...
static MCCFIInstruction createLLVMVectorRegisterMask(MCSymbol *L, unsigned Register, unsigned SpillRegister, unsigned SpillRegisterLaneSizeInBits, unsigned MaskRegister, unsigned MaskRegisterSizeInBits, SMLoc Loc={})
.cfi_llvm_vector_register_mask Previous value of Register is saved in SpillRegister,...
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2, SMLoc Loc={})
.cfi_register Previous value of Register1 is saved in register Register2.
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
static MCCFIInstruction createNegateRAStateWithPC(MCSymbol *L, SMLoc Loc={})
.cfi_negate_ra_state_with_pc AArch64 negate RA state with PC.
static MCCFIInstruction createNegateRAState(MCSymbol *L, SMLoc Loc={})
.cfi_negate_ra_state AArch64 negate RA state.
static MCCFIInstruction createRememberState(MCSymbol *L, SMLoc Loc={})
.cfi_remember_state Save all current rules for all registers.
static MCCFIInstruction createLLVMRegisterPair(MCSymbol *L, unsigned Register, unsigned R1, unsigned R1SizeInBits, unsigned R2, unsigned R2SizeInBits, SMLoc Loc={})
.cfi_llvm_register_pair Previous value of Register is saved in R1:R2.
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa_offset modifies a rule for computing CFA.
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals, SMLoc Loc={}, StringRef Comment="")
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
static MCCFIInstruction createWindowSave(MCSymbol *L, SMLoc Loc={})
.cfi_window_save SPARC register window is saved.
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int64_t Adjustment, SMLoc Loc={})
.cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but Offset is a relative value that is added/subt...
static MCCFIInstruction createRestoreState(MCSymbol *L, SMLoc Loc={})
.cfi_restore_state Restore the previously saved state.
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_same_value Current value of Register is the same as in the previous frame.
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_rel_offset Previous value of Register is saved at offset Offset from the current CFA register.
Describe properties that are true of each instruction in the target description file.
unsigned getID() const
getID() - Return the register class ID number.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
void normalizeSuccProbs()
Normalize probabilities of all successors so that the sum of them becomes one.
void setAddressTakenIRBlock(BasicBlock *BB)
Set this block to reflect that it corresponds to an IR-level basic block with a BlockAddress.
void setIsCleanupFuncletEntry(bool V=true)
Indicates if this is the entry block of a cleanup funclet.
void setLabelMustBeEmitted()
Set this block to reflect that, regardless how we flow to it, we need its label be emitted.
LLVM_ABI instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
void setCallFrameSize(unsigned N)
Set the call frame size on entry to this basic block.
void setMaxBytesForAlignment(unsigned MaxBytes)
Set the maximum amount of padding allowed for aligning the basic block.
void setAlignment(Align A)
Set alignment of the basic block.
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
void setSectionID(MBBSectionID V)
Sets the section ID for this basic block.
void setIsInlineAsmBrIndirectTarget(bool V=true)
Indicates if this is the indirect dest of an INLINEASM_BR.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
void setIsEHContTarget(bool V=true)
Indicates if this is a target of Windows EH Continuation Guard.
void setIsEHFuncletEntry(bool V=true)
Indicates if this is the entry block of an EH funclet.
LLVM_ABI bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
LLVM_ABI StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
void setIsEHScopeEntry(bool V=true)
Indicates if this is the entry block of an EH scope, i.e., the block that that used to have a catchpa...
void setMachineBlockAddressTaken()
Set this block to indicate that its address is used as something other than the target of a terminato...
void setIsEHPad(bool V=true)
Indicates the block is a landing pad.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
void setFlag(MIFlag Flag)
Set a MI flag.
A description of a memory reference used in the backend.
Flags
Flags values. These may be or'd together.
@ MOVolatile
The memory access is volatile.
@ MODereferenceable
The memory access is dereferenceable (i.e., doesn't trap).
@ MOLoad
The memory access reads data.
@ MONonTemporal
The memory access is non-temporal.
@ MOInvariant
The memory access always returns the same value (or traps).
@ MOStore
The memory access writes data.
MachineOperand class - Representation of each machine instruction operand.
static MachineOperand CreateMCSymbol(MCSymbol *Sym, unsigned TargetFlags=0)
static MachineOperand CreateES(const char *SymName, unsigned TargetFlags=0)
static MachineOperand CreateFPImm(const ConstantFP *CFP)
static MachineOperand CreateCFIIndex(unsigned CFIIndex)
static MachineOperand CreateRegMask(const uint32_t *Mask)
CreateRegMask - Creates a register mask operand referencing Mask.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
static MachineOperand CreateCImm(const ConstantInt *CI)
static MachineOperand CreateMetadata(const MDNode *Meta)
static MachineOperand CreatePredicate(unsigned Pred)
static MachineOperand CreateImm(int64_t Val)
static MachineOperand CreateShuffleMask(ArrayRef< int > Mask)
static MachineOperand CreateJTI(unsigned Idx, unsigned TargetFlags=0)
static MachineOperand CreateDbgInstrRef(unsigned InstrIdx, unsigned OpIdx)
static MachineOperand CreateRegLiveOut(const uint32_t *Mask)
static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset, unsigned TargetFlags=0)
static MachineOperand CreateBA(const BlockAddress *BA, int64_t Offset, unsigned TargetFlags=0)
void setTargetFlags(unsigned F)
static MachineOperand CreateLaneMask(LaneBitmask LaneMask)
LLVM_ABI bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
static MachineOperand CreateCPI(unsigned Idx, int Offset, unsigned TargetFlags=0)
static MachineOperand CreateReg(Register 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 MachineOperand CreateTargetIndex(unsigned Idx, int64_t Offset, unsigned TargetFlags=0)
static MachineOperand CreateMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0)
static MachineOperand CreateIntrinsicID(Intrinsic::ID ID)
static MachineOperand CreateFI(int Idx)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
void setRegClassOrRegBank(Register Reg, const RegClassOrRegBank &RCOrRB)
LLT getType(Register Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register.
LLVM_ABI void setType(Register VReg, LLT Ty)
Set the low-level type of VReg to Ty.
void noteNewVirtualRegister(Register Reg)
This interface provides simple read-only access to a block of memory, and provides simple methods for...
virtual StringRef getBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
const char * getBufferEnd() const
const char * getBufferStart() const
Manage lifetime of a slot tracker for printing IR.
int getLocalSlot(const Value *V)
Return the slot number of the specified local value.
void incorporateFunction(const Function &F)
Incorporate the given function.
A Module instance is used to store all the information related to an LLVM module.
Special value supplied for machine level alias analysis.
const RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
unsigned getNumRegBanks() const
Get the total number of register banks.
This class implements the register bank concept.
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
constexpr unsigned id() const
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Represents a location in source code.
static SMLoc getFromPointer(const char *Ptr)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
unsigned getMainFileID() const
const MemoryBuffer * getMemoryBuffer(unsigned i) const
LLVM_ABI SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges={}, ArrayRef< SMFixIt > FixIts={}) const
Return an SMDiagnostic at the specified location with the specified string.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
std::string str() const
Get the contents as an std::string.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
constexpr bool empty() const
Check if the string is empty.
LLVM_ABI std::string lower() const
bool consume_front(char Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TargetSubtargetInfo - Generic base class for all target subtargets.
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Value * lookup(StringRef Name) const
This method finds the value with the given Name in the the symbol table.
LLVM Value Representation.
An efficient, type-erasing, non-owning reference to a callable.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
@ BasicBlock
Various leaf nodes.
LLVM_ABI ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
@ System
Synchronized with respect to all concurrently executing threads.
support::ulittle32_t Word
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
NodeAddr< NodeBase * > Node
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool parseStackObjectReference(PerFunctionMIParsingState &PFS, int &FI, StringRef Src, SMDiagnostic &Error)
LLVM_ABI bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node, StringRef Src, SMDiagnostic &Error)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
RelativeUniformCounterPtr Values
RegState
Flags to represent properties of register accesses.
@ Implicit
Not emitted register (e.g. carry, or temporary result).
@ Kill
The last use of a register.
@ InternalRead
Register reads a value that is defined inside the same instruction or bundle.
@ Undef
Value of the register doesn't matter.
@ EarlyClobber
Register definition happens before uses.
@ Define
Register definition.
@ Renamable
Register that may be renamed.
@ Debug
Register 'use' is for debugging purpose.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
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...
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
LLVM_ABI bool parseMachineBasicBlockDefinitions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine basic block definitions, and skip the machine instructions.
LLVM_ABI bool parsePrefetchTarget(PerFunctionMIParsingState &PFS, CallsiteID &Target, StringRef Src, SMDiagnostic &Error)
LLVM_ABI 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...
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
LLVM_ABI bool parseMBBReference(PerFunctionMIParsingState &PFS, MachineBasicBlock *&MBB, StringRef Src, SMDiagnostic &Error)
uint64_t PowerOf2Ceil(uint64_t A)
Returns the power of two which is greater than or equal to the given value.
auto dyn_cast_or_null(const Y &Val)
LLVM_ABI DIExpression * parseDIExpressionBodyAtBeginning(StringRef Asm, unsigned &Read, SMDiagnostic &Err, const Module &M, const SlotMapping *Slots)
constexpr RegState getDefRegState(bool B)
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
constexpr bool hasRegState(RegState Value, RegState Test)
AtomicOrdering
Atomic ordering for LLVM's memory model.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
LLVM_ABI bool parseMachineInstructions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine instructions.
LLVM_ABI bool parseRegisterReference(PerFunctionMIParsingState &PFS, Register &Reg, StringRef Src, SMDiagnostic &Error)
LLVM_ABI Constant * parseConstantValue(StringRef Asm, SMDiagnostic &Err, const Module &M, const SlotMapping *Slots=nullptr)
Parse a type and a constant value in the given string.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool parseVirtualRegisterReference(PerFunctionMIParsingState &PFS, VRegInfo *&Info, StringRef Src, SMDiagnostic &Error)
@ End
Run the machine verifier once, at the end of the pipeline.
LLVM_ABI bool parseNamedRegisterReference(PerFunctionMIParsingState &PFS, Register &Reg, StringRef Src, SMDiagnostic &Error)
MCRegisterClass TargetRegisterClass
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
MDNode * NoAliasAddrSpace
The tag specifying the noalias address spaces.
MDNode * Scope
The tag for alias scope specification (used with noalias).
MDNode * TBAA
The tag for type-based alias analysis.
MDNode * NoAlias
The tag specifying the noalias scope.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static constexpr LaneBitmask getAll()
LLVM_ABI static const MBBSectionID ExceptionSectionID
LLVM_ABI static const MBBSectionID ColdSectionID
A token produced by the machine instruction lexer.
bool hasIntegerValue() const
bool is(TokenKind K) const
StringRef stringValue() const
Return the token's string value.
@ kw_cfi_aarch64_negate_ra_sign_state
@ kw_cfi_llvm_def_aspace_cfa
@ kw_cleanup_funclet_entry
@ kw_cfi_llvm_register_pair
@ kw_cfi_llvm_vector_offset
@ kw_inlineasm_br_indirect_target
@ kw_cfi_llvm_vector_registers
@ kw_label_must_be_emitted
@ kw_cfi_llvm_vector_register_mask
@ kw_cfi_aarch64_negate_ra_sign_state_with_pc
@ kw_cfi_def_cfa_register
@ kw_cfi_adjust_cfa_offset
@ kw_max_bytes_for_alignment
@ kw_machine_block_address_taken
@ kw_ir_block_address_taken
StringRef::iterator location() const
const APSInt & integerValue() const
This class contains a discriminated union of information about pointers in memory operands,...
int64_t Offset
Offset - This is an offset from the base Value*.
LLVM_ABI VRegInfo & getVRegInfo(Register Num)
const SlotMapping & IRSlots
LLVM_ABI const Value * getIRValue(unsigned Slot)
DenseMap< unsigned, MachineBasicBlock * > MBBSlots
StringMap< VRegInfo * > VRegInfosNamed
DenseMap< unsigned, const Value * > Slots2Values
Maps from slot numbers to function's unnamed values.
LLVM_ABI PerFunctionMIParsingState(MachineFunction &MF, SourceMgr &SM, const SlotMapping &IRSlots, PerTargetMIParsingState &Target)
PerTargetMIParsingState & Target
DenseMap< Register, VRegInfo * > VRegInfos
LLVM_ABI VRegInfo & getVRegInfoNamed(StringRef RegName)
BumpPtrAllocator Allocator
LLVM_ABI bool getVRegFlagValue(StringRef FlagName, uint8_t &FlagValue) const
LLVM_ABI bool getDirectTargetFlag(StringRef Name, unsigned &Flag)
Try to convert a name of a direct target flag to the corresponding target flag.
LLVM_ABI const RegisterBank * getRegBank(StringRef Name)
Check if the given identifier is a name of a register bank.
LLVM_ABI bool parseInstrName(StringRef InstrName, unsigned &OpCode)
Try to convert an instruction name to an opcode.
LLVM_ABI unsigned getSubRegIndex(StringRef Name)
Check if the given identifier is a name of a subregister index.
LLVM_ABI bool getTargetIndex(StringRef Name, int &Index)
Try to convert a name of target index to the corresponding target index.
LLVM_ABI void setTarget(const TargetSubtargetInfo &NewSubtarget)
LLVM_ABI bool getRegisterByName(StringRef RegName, Register &Reg)
Try to convert a register name to a register number.
LLVM_ABI bool getMMOTargetFlag(StringRef Name, MachineMemOperand::Flags &Flag)
Try to convert a name of a MachineMemOperand target flag to the corresponding target flag.
LLVM_ABI bool getBitmaskTargetFlag(StringRef Name, unsigned &Flag)
Try to convert a name of a bitmask target flag to the corresponding target flag.
LLVM_ABI const TargetRegisterClass * getRegClass(StringRef Name)
Check if the given identifier is a name of a register class.
LLVM_ABI const uint32_t * getRegMask(StringRef Identifier)
Check if the given identifier is a name of a register mask.
This struct contains the mappings from the slot numbers to unnamed metadata nodes,...
NumberedValues< GlobalValue * > GlobalValues
const RegisterBank * RegBank
union llvm::VRegInfo::@127225073067155374133234315364317264041071000132 D
const TargetRegisterClass * RC
enum llvm::VRegInfo::@374354327266250320012227113300214031244227062232 Kind
bool Explicit
VReg was explicitly specified in the .mir file.